fr.quatrevieux.araknemu.data.living.constraint.Not   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 11
dl 0
loc 16
ccs 5
cts 5
cp 1
rs 10
c 0
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A check(T) 0 4 1
A Not(EntityConstraint) 0 2 1
A error() 0 3 1
1
/*
2
 * This file is part of Araknemu.
3
 *
4
 * Araknemu is free software: you can redistribute it and/or modify
5
 * it under the terms of the GNU Lesser General Public License as published by
6
 * the Free Software Foundation, either version 3 of the License, or
7
 * (at your option) any later version.
8
 *
9
 * Araknemu is distributed in the hope that it will be useful,
10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
 * GNU Lesser General Public License for more details.
13
 *
14
 * You should have received a copy of the GNU Lesser General Public License
15
 * along with Araknemu.  If not, see <https://www.gnu.org/licenses/>.
16
 *
17
 * Copyright (c) 2017-2019 Vincent Quatrevieux
18
 */
19
20
package fr.quatrevieux.araknemu.data.living.constraint;
21
22
import org.checkerframework.checker.nullness.qual.NonNull;
23
import org.checkerframework.checker.nullness.qual.Nullable;
24
25
/**
26
 * Reverse constraint check result
27
 *
28
 * @param <T> The entity type
29
 * @param <E> The error type
30
 */
31
public final class Not<T, @NonNull E> implements EntityConstraint<T, E> {
32
    private final EntityConstraint<T, E> constraint;
33
34 1
    public Not(EntityConstraint<T, E> constraint) {
35 1
        this.constraint = constraint;
36 1
    }
37
38
    @Override
39
    @SuppressWarnings("contracts.conditional.postcondition")
40
    public boolean check(T entity) {
41 1
        return !constraint.check(entity);
42
    }
43
44
    @Override
45
    public @Nullable E error() {
46 1
        return constraint.error();
47
    }
48
}
49