1 | package fr.sii.ogham.core.condition; | |
2 | ||
3 | import fr.sii.ogham.core.util.EqualsBuilder; | |
4 | import fr.sii.ogham.core.util.HashCodeBuilder; | |
5 | ||
6 | /** | |
7 | * Condition that provides a logical NOT operation on manipulated condition. | |
8 | * | |
9 | * @author Aurélien Baudet | |
10 | * | |
11 | * @param <T> | |
12 | * the type of the object to test | |
13 | */ | |
14 | public class NotCondition<T> implements Condition<T> { | |
15 | ||
16 | /** | |
17 | * The condition to negate | |
18 | */ | |
19 | private final Condition<T> condition; | |
20 | ||
21 | /** | |
22 | * Initialize the condition with the condition to negate. | |
23 | * | |
24 | * @param condition | |
25 | * the condition to negate | |
26 | */ | |
27 | public NotCondition(Condition<T> condition) { | |
28 | super(); | |
29 | this.condition = condition; | |
30 | } | |
31 | ||
32 | @Override | |
33 | public boolean accept(T obj) { | |
34 |
4
1. accept : replaced boolean return with true for fr/sii/ogham/core/condition/NotCondition::accept → NO_COVERAGE 2. accept : negated conditional → NO_COVERAGE 3. accept : replaced boolean return with true for fr/sii/ogham/core/condition/NotCondition::accept → KILLED 4. accept : negated conditional → KILLED |
return !condition.accept(obj); |
35 | } | |
36 | ||
37 | @Override | |
38 | public boolean equals(Object obj) { | |
39 |
2
1. equals : replaced boolean return with false for fr/sii/ogham/core/condition/NotCondition::equals → NO_COVERAGE 2. equals : replaced boolean return with true for fr/sii/ogham/core/condition/NotCondition::equals → NO_COVERAGE |
return new EqualsBuilder(this, obj).appendFields("condition").isEqual(); |
40 | } | |
41 | | |
42 | @Override | |
43 | public int hashCode() { | |
44 |
1
1. hashCode : replaced int return with 0 for fr/sii/ogham/core/condition/NotCondition::hashCode → NO_COVERAGE |
return new HashCodeBuilder().append(condition).hashCode(); |
45 | } | |
46 | ||
47 | @Override | |
48 | public String toString() { | |
49 | StringBuilder builder = new StringBuilder(); | |
50 | builder.append("not [").append(condition).append("]"); | |
51 |
1
1. toString : replaced return value with "" for fr/sii/ogham/core/condition/NotCondition::toString → NO_COVERAGE |
return builder.toString(); |
52 | } | |
53 | } | |
Mutations | ||
34 |
1.1 2.2 3.3 4.4 |
|
39 |
1.1 2.2 |
|
44 |
1.1 |
|
51 |
1.1 |