| 1 | package fr.sii.ogham.core.condition.provider; | |
| 2 | ||
| 3 | import fr.sii.ogham.core.builder.ActivableAtRuntime; | |
| 4 | import fr.sii.ogham.core.builder.condition.RequiredClass; | |
| 5 | import fr.sii.ogham.core.builder.condition.RequiredClasses; | |
| 6 | import fr.sii.ogham.core.builder.condition.RequiredProperties; | |
| 7 | import fr.sii.ogham.core.builder.condition.RequiredProperty; | |
| 8 | import fr.sii.ogham.core.condition.AndCondition; | |
| 9 | import fr.sii.ogham.core.condition.Condition; | |
| 10 | import fr.sii.ogham.core.env.PropertyResolver; | |
| 11 | import fr.sii.ogham.core.message.Message; | |
| 12 | ||
| 13 | /** | |
| 14 | * The aim is to look at the object and get defined conditions. Conditions may | |
| 15 | * be defined by several ways: | |
| 16 | * <ul> | |
| 17 | * <li>By using annotations (see {@link RequiredClass}, | |
| 18 | * {@link RequiredProperty}, {@link RequiredClasses} and | |
| 19 | * {@link RequiredProperties})</li> | |
| 20 | * <li>By implementing {@link ActivableAtRuntime} interface</li> | |
| 21 | * </ul> | |
| 22 | * | |
| 23 | * <p> | |
| 24 | * If both are defined, the final condition is a and between conditions bring by | |
| 25 | * annotations and condition returned by | |
| 26 | * {@link ActivableAtRuntime#getCondition()} method. | |
| 27 | * </p> | |
| 28 | * | |
| 29 | * @author Aurélien Baudet | |
| 30 | * | |
| 31 | */ | |
| 32 | public class ImplementationConditionProvider implements ConditionProvider<Object, Message> { | |
| 33 | private final AnnotationConditionProvider<Message> annotationProvider; | |
| 34 | private final ActivableAtRuntimeConditionProvider runtimeProvider; | |
| 35 | ||
| 36 | /** | |
| 37 | * Initializes with a {@link PropertyResolver} instance. The | |
| 38 | * {@link PropertyResolver} is used by the | |
| 39 | * {@link AnnotationConditionProvider} (specifically by | |
| 40 | * {@link RequiredPropertiesAnnotationProvider} and | |
| 41 | * {@link RequiredPropertyAnnotationProvider}) to check existence of | |
| 42 | * properties. | |
| 43 | * | |
| 44 | * @param propertyResolver | |
| 45 | * the property resolver used to check existence of properties | |
| 46 | */ | |
| 47 | public ImplementationConditionProvider(PropertyResolver propertyResolver) { | |
| 48 | super(); | |
| 49 | annotationProvider = new AnnotationConditionProvider<>(propertyResolver); | |
| 50 | runtimeProvider = new ActivableAtRuntimeConditionProvider(); | |
| 51 | } | |
| 52 | ||
| 53 | @Override | |
| 54 | public Condition<Message> provide(Object source) { | |
| 55 | AndCondition<Message> mainCondition = new AndCondition<>(); | |
| 56 | mainCondition.and(annotationProvider.provide(source.getClass())); | |
| 57 | mainCondition.and(runtimeProvider.provide(source)); | |
| 58 |
8
1. provide : replaced return value with null for fr/sii/ogham/core/condition/provider/ImplementationConditionProvider::provide → NO_COVERAGE 2. provide : replaced return value with null for fr/sii/ogham/core/condition/provider/ImplementationConditionProvider::provide → SURVIVED 3. provide : replaced return value with null for fr/sii/ogham/core/condition/provider/ImplementationConditionProvider::provide → KILLED 4. provide : replaced return value with null for fr/sii/ogham/core/condition/provider/ImplementationConditionProvider::provide → KILLED 5. provide : replaced return value with null for fr/sii/ogham/core/condition/provider/ImplementationConditionProvider::provide → KILLED 6. provide : replaced return value with null for fr/sii/ogham/core/condition/provider/ImplementationConditionProvider::provide → KILLED 7. provide : replaced return value with null for fr/sii/ogham/core/condition/provider/ImplementationConditionProvider::provide → KILLED 8. provide : replaced return value with null for fr/sii/ogham/core/condition/provider/ImplementationConditionProvider::provide → KILLED |
return mainCondition; |
| 59 | } | |
| 60 | ||
| 61 | } | |
Mutations | ||
| 58 |
1.1 2.2 3.3 4.4 5.5 6.6 7.7 8.8 |