| 1 | package fr.sii.ogham.core.condition; | |
| 2 | ||
| 3 | import java.util.ArrayList; | |
| 4 | import java.util.Arrays; | |
| 5 | import java.util.List; | |
| 6 | ||
| 7 | import fr.sii.ogham.core.util.EqualsBuilder; | |
| 8 | import fr.sii.ogham.core.util.HashCodeBuilder; | |
| 9 | ||
| 10 | /** | |
| 11 | * Base class for operators that handle several sub-conditions like AND operator | |
| 12 | * and OR operator. | |
| 13 | * | |
| 14 | * @author Aurélien Baudet | |
| 15 | * | |
| 16 | * @param <T> | |
| 17 | * the type of the object to test | |
| 18 | */ | |
| 19 | public abstract class CompositeCondition<T> implements Condition<T> { | |
| 20 | protected final List<Condition<T>> conditions; | |
| 21 | ||
| 22 | protected CompositeCondition(List<Condition<T>> conditions) { | |
| 23 | super(); | |
| 24 | this.conditions = conditions; | |
| 25 | } | |
| 26 | ||
| 27 | @SafeVarargs | |
| 28 | protected CompositeCondition(Condition<T>... conditions) { | |
| 29 | this(new ArrayList<>(Arrays.asList(conditions))); | |
| 30 | } | |
| 31 | ||
| 32 | protected List<Condition<T>> getConditions() { | |
| 33 |
7
1. getConditions : replaced return value with Collections.emptyList for fr/sii/ogham/core/condition/CompositeCondition::getConditions → NO_COVERAGE 2. getConditions : replaced return value with Collections.emptyList for fr/sii/ogham/core/condition/CompositeCondition::getConditions → SURVIVED 3. getConditions : replaced return value with Collections.emptyList for fr/sii/ogham/core/condition/CompositeCondition::getConditions → TIMED_OUT 4. getConditions : replaced return value with Collections.emptyList for fr/sii/ogham/core/condition/CompositeCondition::getConditions → KILLED 5. getConditions : replaced return value with Collections.emptyList for fr/sii/ogham/core/condition/CompositeCondition::getConditions → KILLED 6. getConditions : replaced return value with Collections.emptyList for fr/sii/ogham/core/condition/CompositeCondition::getConditions → KILLED 7. getConditions : replaced return value with Collections.emptyList for fr/sii/ogham/core/condition/CompositeCondition::getConditions → KILLED |
return conditions; |
| 34 | } | |
| 35 | ||
| 36 | protected CompositeCondition<T> addCondition(Condition<T> condition) { | |
| 37 | conditions.add(condition); | |
| 38 |
3
1. addCondition : replaced return value with null for fr/sii/ogham/core/condition/CompositeCondition::addCondition → NO_COVERAGE 2. addCondition : replaced return value with null for fr/sii/ogham/core/condition/CompositeCondition::addCondition → SURVIVED 3. addCondition : replaced return value with null for fr/sii/ogham/core/condition/CompositeCondition::addCondition → TIMED_OUT |
return this; |
| 39 | } | |
| 40 | ||
| 41 | protected CompositeCondition<T> addConditions(List<Condition<T>> conditions) { | |
| 42 | this.conditions.addAll(conditions); | |
| 43 |
1
1. addConditions : replaced return value with null for fr/sii/ogham/core/condition/CompositeCondition::addConditions → NO_COVERAGE |
return this; |
| 44 | } | |
| 45 | ||
| 46 | @Override | |
| 47 | public boolean equals(Object obj) { | |
| 48 |
2
1. equals : replaced boolean return with false for fr/sii/ogham/core/condition/CompositeCondition::equals → NO_COVERAGE 2. equals : replaced boolean return with true for fr/sii/ogham/core/condition/CompositeCondition::equals → NO_COVERAGE |
return new EqualsBuilder(this, obj).appendFields("conditions").isEqual(); |
| 49 | } | |
| 50 | ||
| 51 | @Override | |
| 52 | public int hashCode() { | |
| 53 |
1
1. hashCode : replaced int return with 0 for fr/sii/ogham/core/condition/CompositeCondition::hashCode → NO_COVERAGE |
return new HashCodeBuilder().append(conditions).hashCode(); |
| 54 | } | |
| 55 | ||
| 56 | @Override | |
| 57 | public String toString() { | |
| 58 |
1
1. toString : replaced return value with "" for fr/sii/ogham/core/condition/CompositeCondition::toString → NO_COVERAGE |
return conditions.toString(); |
| 59 | } | |
| 60 | ||
| 61 | } | |
Mutations | ||
| 33 |
1.1 2.2 3.3 4.4 5.5 6.6 7.7 |
|
| 38 |
1.1 2.2 3.3 |
|
| 43 |
1.1 |
|
| 48 |
1.1 2.2 |
|
| 53 |
1.1 |
|
| 58 |
1.1 |