1 | package fr.sii.ogham.core.builder.env; | |
2 | ||
3 | import java.util.Properties; | |
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 PropertiesBuilder} is used for a particular | |
12 | * parent and it must be inherited. As the parent types are not the same, you | |
13 | * can't directly use the same reference. So this implementation wraps the | |
14 | * 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 | */ | |
24 | public class PropertiesBuilderDelegate<P> extends AbstractParent<P> implements PropertiesBuilder<P> { | |
25 | private PropertiesBuilder<?> delegate; | |
26 | | |
27 | /** | |
28 | * Wraps the delegate builder. The delegated builder parent is not used. | |
29 | * This instance uses the provided parent instead for chaining. | |
30 | * | |
31 | * @param parent | |
32 | * the new parent used for chaining | |
33 | * @param delegate | |
34 | * the instance that will really be updated | |
35 | */ | |
36 | public PropertiesBuilderDelegate(P parent, PropertiesBuilder<?> delegate) { | |
37 | super(parent); | |
38 | this.delegate = delegate; | |
39 | } | |
40 | ||
41 | @Override | |
42 | public PropertiesBuilder<P> set(String key, String value) { | |
43 | delegate.set(key, value); | |
44 |
1
1. set : replaced return value with null for fr/sii/ogham/core/builder/env/PropertiesBuilderDelegate::set → NO_COVERAGE |
return this; |
45 | } | |
46 | ||
47 | @Override | |
48 | public PropertiesBuilder<P> set(String key, Object value) { | |
49 | delegate.set(key, value); | |
50 |
1
1. set : replaced return value with null for fr/sii/ogham/core/builder/env/PropertiesBuilderDelegate::set → NO_COVERAGE |
return this; |
51 | } | |
52 | ||
53 | @Override | |
54 | public Properties build() { | |
55 |
1
1. build : replaced return value with null for fr/sii/ogham/core/builder/env/PropertiesBuilderDelegate::build → NO_COVERAGE |
return delegate.build(); |
56 | } | |
57 | ||
58 | } | |
Mutations | ||
44 |
1.1 |
|
50 |
1.1 |
|
55 |
1.1 |