| 1 | package fr.sii.ogham.core.builder.configuration; | |
| 2 | ||
| 3 | import java.util.Optional; | |
| 4 | ||
| 5 | import fr.sii.ogham.core.fluent.AbstractParent; | |
| 6 | ||
| 7 | /** | |
| 8 | * Implementation that just delegates all operations to another builder. | |
| 9 | * | |
| 10 | * <p> | |
| 11 | * This is useful when a {@link ConfigurationValueBuilder} is used for a | |
| 12 | * particular parent and it must be inherited. As the parent types are not the | |
| 13 | * same, you can't directly use the same reference. So this implementation wraps | |
| 14 | * the original reference but as it is a new instance, it can have a different | |
| 15 | * parent builder. | |
| 16 | * </p> | |
| 17 | * | |
| 18 | * @author Aurélien Baudet | |
| 19 | * | |
| 20 | * @param <P> | |
| 21 | * the type of the parent builder (when calling {@link #and()} | |
| 22 | * method) | |
| 23 | * @param <V> | |
| 24 | * the type of the value | |
| 25 | */ | |
| 26 | public class ConfigurationValueBuilderDelegate<P, V> extends AbstractParent<P> implements ConfigurationValueBuilder<P, V> { | |
| 27 | private final ConfigurationValueBuilder<?, V> delegate; | |
| 28 | ||
| 29 | /** | |
| 30 | * Wraps the delegate builder. The delegated builder parent is not used. | |
| 31 | * This instance uses the provided parent instead for chaining. | |
| 32 | * | |
| 33 | * @param parent | |
| 34 | * the new parent used for chaining | |
| 35 | * @param delegate | |
| 36 | * the instance that will really be updated | |
| 37 | */ | |
| 38 | public ConfigurationValueBuilderDelegate(P parent, ConfigurationValueBuilder<?, V> delegate) { | |
| 39 | super(parent); | |
| 40 | this.delegate = delegate; | |
| 41 | } | |
| 42 | ||
| 43 | @Override | |
| 44 | public ConfigurationValueBuilder<P, V> properties(String... properties) { | |
| 45 | delegate.properties(properties); | |
| 46 |
1
1. properties : replaced return value with null for fr/sii/ogham/core/builder/configuration/ConfigurationValueBuilderDelegate::properties → RUN_ERROR |
return this; |
| 47 | } | |
| 48 | ||
| 49 | @Override | |
| 50 | public ConfigurationValueBuilder<P, V> defaultValue(V value) { | |
| 51 | delegate.defaultValue(value); | |
| 52 |
1
1. defaultValue : replaced return value with null for fr/sii/ogham/core/builder/configuration/ConfigurationValueBuilderDelegate::defaultValue → NO_COVERAGE |
return this; |
| 53 | } | |
| 54 | ||
| 55 | @Override | |
| 56 | @SuppressWarnings("squid:S3553") | |
| 57 | public ConfigurationValueBuilder<P, V> value(Optional<V> optionalValue) { | |
| 58 | delegate.value(optionalValue); | |
| 59 |
1
1. value : replaced return value with null for fr/sii/ogham/core/builder/configuration/ConfigurationValueBuilderDelegate::value → NO_COVERAGE |
return this; |
| 60 | } | |
| 61 | ||
| 62 | @Override | |
| 63 | public ConfigurationValueBuilder<P, V> defaultValue(MayOverride<V> possibleNewValue) { | |
| 64 | delegate.defaultValue(possibleNewValue); | |
| 65 |
1
1. defaultValue : replaced return value with null for fr/sii/ogham/core/builder/configuration/ConfigurationValueBuilderDelegate::defaultValue → RUN_ERROR |
return this; |
| 66 | } | |
| 67 | ||
| 68 | } | |
Mutations | ||
| 46 |
1.1 |
|
| 52 |
1.1 |
|
| 59 |
1.1 |
|
| 65 |
1.1 |