| 1 | package fr.sii.ogham.core.condition; | |
| 2 | ||
| 3 | import fr.sii.ogham.core.util.ClasspathUtils; | |
| 4 | import fr.sii.ogham.core.util.EqualsBuilder; | |
| 5 | import fr.sii.ogham.core.util.HashCodeBuilder; | |
| 6 | ||
| 7 | /** | |
| 8 | * Condition that checks if the provided class is available in the classpath. | |
| 9 | * | |
| 10 | * @author Aurélien Baudet | |
| 11 | * | |
| 12 | * @param <T> | |
| 13 | * The type of the object to test for acceptance. Has no effect on | |
| 14 | * the acceptance | |
| 15 | */ | |
| 16 | public class RequiredClassCondition<T> implements Condition<T> { | |
| 17 | /** | |
| 18 | * The class to check if exists in the classpath | |
| 19 | */ | |
| 20 | private String className; | |
| 21 | ||
| 22 | /** | |
| 23 | * Initialize the condition with the class name | |
| 24 | * | |
| 25 | * @param className | |
| 26 | * The class to check availability for | |
| 27 | */ | |
| 28 | public RequiredClassCondition(String className) { | |
| 29 | super(); | |
| 30 | this.className = className; | |
| 31 | } | |
| 32 | ||
| 33 | @Override | |
| 34 | public boolean accept(T obj) { | |
| 35 |
4
1. accept : replaced boolean return with false for fr/sii/ogham/core/condition/RequiredClassCondition::accept → NO_COVERAGE 2. accept : replaced boolean return with true for fr/sii/ogham/core/condition/RequiredClassCondition::accept → NO_COVERAGE 3. accept : replaced boolean return with false for fr/sii/ogham/core/condition/RequiredClassCondition::accept → KILLED 4. accept : replaced boolean return with true for fr/sii/ogham/core/condition/RequiredClassCondition::accept → KILLED |
return ClasspathUtils.exists(className); |
| 36 | } | |
| 37 | | |
| 38 | @Override | |
| 39 | public boolean equals(Object obj) { | |
| 40 |
2
1. equals : replaced boolean return with false for fr/sii/ogham/core/condition/RequiredClassCondition::equals → NO_COVERAGE 2. equals : replaced boolean return with true for fr/sii/ogham/core/condition/RequiredClassCondition::equals → NO_COVERAGE |
return new EqualsBuilder(this, obj).appendFields("className").isEqual(); |
| 41 | } | |
| 42 | ||
| 43 | @Override | |
| 44 | public int hashCode() { | |
| 45 |
1
1. hashCode : replaced int return with 0 for fr/sii/ogham/core/condition/RequiredClassCondition::hashCode → NO_COVERAGE |
return new HashCodeBuilder().append(className).hashCode(); |
| 46 | } | |
| 47 | ||
| 48 | @Override | |
| 49 | public String toString() { | |
| 50 | StringBuilder builder = new StringBuilder(); | |
| 51 | builder.append("(Is").append(className).append(" in classpath ?)"); | |
| 52 |
1
1. toString : replaced return value with "" for fr/sii/ogham/core/condition/RequiredClassCondition::toString → NO_COVERAGE |
return builder.toString(); |
| 53 | } | |
| 54 | } | |
Mutations | ||
| 35 |
1.1 2.2 3.3 4.4 |
|
| 40 |
1.1 2.2 |
|
| 45 |
1.1 |
|
| 52 |
1.1 |