AbstractAutofillDefaultValueBuilder.java

1
package fr.sii.ogham.core.builder.filler;
2
3
import fr.sii.ogham.core.builder.configuration.ConfigurationValueBuilder;
4
import fr.sii.ogham.core.builder.configuration.ConfigurationValueBuilderHelper;
5
import fr.sii.ogham.core.builder.configurer.Configurer;
6
import fr.sii.ogham.core.builder.context.BuildContext;
7
import fr.sii.ogham.core.fluent.AbstractParent;
8
9
/**
10
 * Base class to configure a property key that will be used to automatically
11
 * fill a message. It registers the property keys only (no direct value).
12
 * 
13
 * @author Aurélien Baudet
14
 *
15
 * @param <MYSELF>
16
 *            The type of this instance. This is needed to have the right return
17
 *            type for fluent chaining with inheritance
18
 * @param <P>
19
 *            the type of the parent builder (when calling {@link #and()}
20
 *            method)
21
 * @param <V>
22
 *            The type of the value
23
 */
24
@SuppressWarnings("squid:S00119")
25
public abstract class AbstractAutofillDefaultValueBuilder<MYSELF, P, V> extends AbstractParent<P> {
26
	protected final MYSELF myself;
27
	protected final BuildContext buildContext;
28
	protected final ConfigurationValueBuilderHelper<MYSELF, V> defaultValueBuilder;
29
30
	/**
31
	 * Initializes the builder with the explicit type of this instance for
32
	 * chaining. This is mandatory in order to have a fluent chaining that
33
	 * doesn't loose sub-types. If we were using directly {@code this}, chaining
34
	 * would only give methods statically defined by
35
	 * {@link AbstractAutofillDefaultValueBuilder}. All methods defined by any
36
	 * specialized implementation that would add other methods won't be
37
	 * accessible directly.
38
	 * 
39
	 * The parent is used by the {@link #and()} method for chaining.
40
	 * 
41
	 * @param selfType
42
	 *            the real implementation class that helps compiler to chain
43
	 *            calls
44
	 * @param parent
45
	 *            the parent builder
46
	 * @param valueClass
47
	 *            the type of the value
48
	 * @param buildContext
49
	 *            for registering instances and property evaluation
50
	 */
51
	@SuppressWarnings("unchecked")
52
	public AbstractAutofillDefaultValueBuilder(Class<?> selfType, P parent, Class<V> valueClass, BuildContext buildContext) {
53
		super(parent);
54
		myself = (MYSELF) selfType.cast(this);
55
		this.buildContext = buildContext;
56
		defaultValueBuilder = buildContext.newConfigurationValueBuilder(myself, valueClass);
57
	}
58
59
	/**
60
	 * Register a default value to use if no value is specified on the message.
61
	 * 
62
	 * <p>
63
	 * The value set using this method takes precedence over any property and
64
	 * default value configured using {@link #defaultValue()}.
65
	 * 
66
	 * <pre>
67
	 * .defaultValue("my-value")
68
	 * .defaultValue()
69
	 *   .properties("${custom.property.high-priority}", "${custom.property.low-priority}")
70
	 *   .defaultValue("default")
71
	 * </pre>
72
	 * 
73
	 * <pre>
74
	 * .defaultValue("my-value")
75
	 * .defaultValue()
76
	 *   .properties("${custom.property.high-priority}", "${custom.property.low-priority}")
77
	 *   .defaultValue("default")
78
	 * </pre>
79
	 * 
80
	 * In both cases, {@code defaultValue("my-value")} is used.
81
	 * 
82
	 * <p>
83
	 * If this method is called several times, only the last value is used.
84
	 * 
85
	 * <p>
86
	 * If {@code null} value is set, it is like not setting a value at all. The
87
	 * property/default value configuration is applied.
88
	 * 
89
	 * @param value
90
	 *            the default value if no value is defined
91
	 * @return this instance for fluent chaining
92
	 */
93
	public MYSELF defaultValue(V value) {
94 1 1. defaultValue : removed call to fr/sii/ogham/core/builder/configuration/ConfigurationValueBuilderHelper::setValue → NO_COVERAGE
		defaultValueBuilder.setValue(value);
95 1 1. defaultValue : replaced return value with null for fr/sii/ogham/core/builder/filler/AbstractAutofillDefaultValueBuilder::defaultValue → NO_COVERAGE
		return myself;
96
	}
97
98
	/**
99
	 * Register a default value to use if no value is specified on the message.
100
	 * 
101
	 * <p>
102
	 * This method is mainly used by {@link Configurer}s to register some
103
	 * property keys and/or a default value. The aim is to let developer be able
104
	 * to externalize its configuration (using system properties, configuration
105
	 * file or anything else). If the developer doesn't configure any value for
106
	 * the registered properties, the default value is used (if set).
107
	 * 
108
	 * <pre>
109
	 * .defaultValue()
110
	 *   .properties("${custom.property.high-priority}", "${custom.property.low-priority}")
111
	 *   .defaultValue("default")
112
	 * </pre>
113
	 * 
114
	 * <p>
115
	 * Non-null value set using {@link #defaultValue(Object)} takes precedence
116
	 * over property values and default value.
117
	 * 
118
	 * <pre>
119
	 * .defaultValue("my-value")
120
	 * .defaultValue()
121
	 *   .properties("${custom.property.high-priority}", "${custom.property.low-priority}")
122
	 *   .defaultValue("default")
123
	 * </pre>
124
	 * 
125
	 * The value {@code "my-value"} is used regardless of the value of the
126
	 * properties and default value.
127
	 * 
128
	 * <p>
129
	 * See {@link ConfigurationValueBuilder} for more information.
130
	 * 
131
	 * 
132
	 * @return the builder to configure property keys/default value
133
	 */
134
	public ConfigurationValueBuilder<MYSELF, V> defaultValue() {
135 8 1. defaultValue : replaced return value with null for fr/sii/ogham/core/builder/filler/AbstractAutofillDefaultValueBuilder::defaultValue → NO_COVERAGE
2. defaultValue : replaced return value with null for fr/sii/ogham/core/builder/filler/AbstractAutofillDefaultValueBuilder::defaultValue → KILLED
3. defaultValue : replaced return value with null for fr/sii/ogham/core/builder/filler/AbstractAutofillDefaultValueBuilder::defaultValue → KILLED
4. defaultValue : replaced return value with null for fr/sii/ogham/core/builder/filler/AbstractAutofillDefaultValueBuilder::defaultValue → KILLED
5. defaultValue : replaced return value with null for fr/sii/ogham/core/builder/filler/AbstractAutofillDefaultValueBuilder::defaultValue → KILLED
6. defaultValue : replaced return value with null for fr/sii/ogham/core/builder/filler/AbstractAutofillDefaultValueBuilder::defaultValue → KILLED
7. defaultValue : replaced return value with null for fr/sii/ogham/core/builder/filler/AbstractAutofillDefaultValueBuilder::defaultValue → KILLED
8. defaultValue : replaced return value with null for fr/sii/ogham/core/builder/filler/AbstractAutofillDefaultValueBuilder::defaultValue → KILLED
		return defaultValueBuilder;
136
	}
137
}

Mutations

94

1.1
Location : defaultValue
Killed by : none
removed call to fr/sii/ogham/core/builder/configuration/ConfigurationValueBuilderHelper::setValue → NO_COVERAGE

95

1.1
Location : defaultValue
Killed by : none
replaced return value with null for fr/sii/ogham/core/builder/filler/AbstractAutofillDefaultValueBuilder::defaultValue → NO_COVERAGE

135

1.1
Location : defaultValue
Killed by : oghamcloudhopper.it.AutoRetryExtensionTest.smsNotRetriedDueToCloudhopperError(oghamcloudhopper.it.AutoRetryExtensionTest)
replaced return value with null for fr/sii/ogham/core/builder/filler/AbstractAutofillDefaultValueBuilder::defaultValue → KILLED

2.2
Location : defaultValue
Killed by : oghamspringbootv1autoconfigure.it.OghamSpringBoot1JavaMailAutoConfigurationTests.oghamAloneShouldUseOghamProperties(oghamspringbootv1autoconfigure.it.OghamSpringBoot1JavaMailAutoConfigurationTests)
replaced return value with null for fr/sii/ogham/core/builder/filler/AbstractAutofillDefaultValueBuilder::defaultValue → KILLED

3.3
Location : defaultValue
Killed by : oghamall.it.html.translator.JsoupInlineCssTranslatorTest.notHtml(oghamall.it.html.translator.JsoupInlineCssTranslatorTest)
replaced return value with null for fr/sii/ogham/core/builder/filler/AbstractAutofillDefaultValueBuilder::defaultValue → KILLED

4.4
Location : defaultValue
Killed by : oghamsmsglobal.it.SmsglobalServiceProviderConfigurerSpec
replaced return value with null for fr/sii/ogham/core/builder/filler/AbstractAutofillDefaultValueBuilder::defaultValue → KILLED

5.5
Location : defaultValue
Killed by : oghamjavamail.it.UnreadableAttachmentTest.attachmentUnreadable(oghamjavamail.it.UnreadableAttachmentTest)
replaced return value with null for fr/sii/ogham/core/builder/filler/AbstractAutofillDefaultValueBuilder::defaultValue → KILLED

6.6
Location : defaultValue
Killed by : oghamspringbootv2autoconfigure.it.OghamSpringBoot2JavaMailAutoConfigurationTests.oghamPropertiesWithSpringPropsShouldUseOghamPropertiesPrecedence(oghamspringbootv2autoconfigure.it.OghamSpringBoot2JavaMailAutoConfigurationTests)
replaced return value with null for fr/sii/ogham/core/builder/filler/AbstractAutofillDefaultValueBuilder::defaultValue → KILLED

7.7
Location : defaultValue
Killed by : oghamcore.it.core.service.CleanupTest.manualCleanupShouldAutomaticallyCleanTheSenders(oghamcore.it.core.service.CleanupTest)
replaced return value with null for fr/sii/ogham/core/builder/filler/AbstractAutofillDefaultValueBuilder::defaultValue → KILLED

8.8
Location : defaultValue
Killed by : none
replaced return value with null for fr/sii/ogham/core/builder/filler/AbstractAutofillDefaultValueBuilder::defaultValue → NO_COVERAGE

Active mutators

Tests examined


Report generated by PIT OGHAM