1 | package fr.sii.ogham.sms.builder.ovh; | |
2 | ||
3 | import fr.sii.ogham.core.builder.Builder; | |
4 | import fr.sii.ogham.core.builder.configuration.ConfigurationValueBuilder; | |
5 | import fr.sii.ogham.core.builder.configuration.ConfigurationValueBuilderHelper; | |
6 | import fr.sii.ogham.core.builder.configurer.Configurer; | |
7 | import fr.sii.ogham.core.builder.context.BuildContext; | |
8 | import fr.sii.ogham.core.builder.env.EnvironmentBuilder; | |
9 | import fr.sii.ogham.core.fluent.AbstractParent; | |
10 | import fr.sii.ogham.sms.sender.impl.ovh.OvhOptions; | |
11 | import fr.sii.ogham.sms.sender.impl.ovh.SmsCoding; | |
12 | ||
13 | /** | |
14 | * Configures OVH SMS options: | |
15 | * <ul> | |
16 | * <li>Enable/disable the "STOP" indication at the end of the message (useful to | |
17 | * disable for non-commercial SMS)</li> | |
18 | * <li>Define the SMS encoding (see {@link SmsCoding}): 1 for 7bit encoding, 2 | |
19 | * for 16bit encoding (UTF-16). If you use UTF-16, your SMS will have a maximum | |
20 | * size of 70 characters instead of 160. If {@code null}, automatic detection is | |
21 | * used. Set the value to force a particular coding</li> | |
22 | * <li>Define a tag to mark sent messages (a 20 maximum character string)</li> | |
23 | * </ul> | |
24 | * | |
25 | * @author Aurélien Baudet | |
26 | * | |
27 | */ | |
28 | public class OvhOptionsBuilder extends AbstractParent<OvhSmsBuilder> implements Builder<OvhOptions> { | |
29 | private final BuildContext buildContext; | |
30 | private final ConfigurationValueBuilderHelper<OvhOptionsBuilder, Boolean> noStopValueBuilder; | |
31 | private final ConfigurationValueBuilderHelper<OvhOptionsBuilder, String> tagValueBuilder; | |
32 | private final ConfigurationValueBuilderHelper<OvhOptionsBuilder, SmsCoding> smsCodingValueBuilder; | |
33 | ||
34 | /** | |
35 | * Initializes the builder with a parent builder. The parent builder is used | |
36 | * when calling {@link #and()} method. The {@link EnvironmentBuilder} is | |
37 | * used to evaluate properties when {@link #build()} method is called. | |
38 | * | |
39 | * @param parent | |
40 | * the parent builder | |
41 | * @param buildContext | |
42 | * for registering instances and property evaluation | |
43 | */ | |
44 | public OvhOptionsBuilder(OvhSmsBuilder parent, BuildContext buildContext) { | |
45 | super(parent); | |
46 | this.buildContext = buildContext; | |
47 | noStopValueBuilder = buildContext.newConfigurationValueBuilder(this, Boolean.class); | |
48 | tagValueBuilder = buildContext.newConfigurationValueBuilder(this, String.class); | |
49 | smsCodingValueBuilder = buildContext.newConfigurationValueBuilder(this, SmsCoding.class); | |
50 | } | |
51 | ||
52 | /** | |
53 | * Enable/disable "STOP" indication at the end of the message (useful to | |
54 | * disable for non-commercial SMS). | |
55 | * | |
56 | * <p> | |
57 | * The value set using this method takes precedence over any property and | |
58 | * default value configured using {@link #noStop()}. | |
59 | * | |
60 | * <pre> | |
61 | * .noStop(true) | |
62 | * .noStop() | |
63 | * .properties("${custom.property.high-priority}", "${custom.property.low-priority}") | |
64 | * .defaultValue(false) | |
65 | * </pre> | |
66 | * | |
67 | * <pre> | |
68 | * .noStop(true) | |
69 | * .noStop() | |
70 | * .properties("${custom.property.high-priority}", "${custom.property.low-priority}") | |
71 | * .defaultValue(false) | |
72 | * </pre> | |
73 | * | |
74 | * In both cases, {@code noStop(true)} is used. | |
75 | * | |
76 | * <p> | |
77 | * If this method is called several times, only the last value is used. | |
78 | * | |
79 | * <p> | |
80 | * If {@code null} value is set, it is like not setting a value at all. The | |
81 | * property/default value configuration is applied. | |
82 | * | |
83 | * @param noStop | |
84 | * true to disable STOP message | |
85 | * @return this instance for fluent chaining | |
86 | */ | |
87 | public OvhOptionsBuilder noStop(Boolean noStop) { | |
88 |
2
1. noStop : removed call to fr/sii/ogham/core/builder/configuration/ConfigurationValueBuilderHelper::setValue → NO_COVERAGE 2. noStop : removed call to fr/sii/ogham/core/builder/configuration/ConfigurationValueBuilderHelper::setValue → KILLED |
noStopValueBuilder.setValue(noStop); |
89 |
2
1. noStop : replaced return value with null for fr/sii/ogham/sms/builder/ovh/OvhOptionsBuilder::noStop → NO_COVERAGE 2. noStop : replaced return value with null for fr/sii/ogham/sms/builder/ovh/OvhOptionsBuilder::noStop → TIMED_OUT |
return this; |
90 | } | |
91 | ||
92 | /** | |
93 | * Enable/disable "STOP" indication at the end of the message (useful to | |
94 | * disable for non-commercial SMS). | |
95 | * | |
96 | * <p> | |
97 | * This method is mainly used by {@link Configurer}s to register some | |
98 | * property keys and/or a default value. The aim is to let developer be able | |
99 | * to externalize its configuration (using system properties, configuration | |
100 | * file or anything else). If the developer doesn't configure any value for | |
101 | * the registered properties, the default value is used (if set). | |
102 | * | |
103 | * <pre> | |
104 | * .noStop() | |
105 | * .properties("${custom.property.high-priority}", "${custom.property.low-priority}") | |
106 | * .defaultValue(false) | |
107 | * </pre> | |
108 | * | |
109 | * <p> | |
110 | * Non-null value set using {@link #noStop(Boolean)} takes precedence over | |
111 | * property values and default value. | |
112 | * | |
113 | * <pre> | |
114 | * .noStop(true) | |
115 | * .noStop() | |
116 | * .properties("${custom.property.high-priority}", "${custom.property.low-priority}") | |
117 | * .defaultValue(false) | |
118 | * </pre> | |
119 | * | |
120 | * The value {@code true} is used regardless of the value of the properties | |
121 | * and default value. | |
122 | * | |
123 | * <p> | |
124 | * See {@link ConfigurationValueBuilder} for more information. | |
125 | * | |
126 | * | |
127 | * @return the builder to configure property keys/default value | |
128 | */ | |
129 | public ConfigurationValueBuilder<OvhOptionsBuilder, Boolean> noStop() { | |
130 |
4
1. noStop : replaced return value with null for fr/sii/ogham/sms/builder/ovh/OvhOptionsBuilder::noStop → NO_COVERAGE 2. noStop : replaced return value with null for fr/sii/ogham/sms/builder/ovh/OvhOptionsBuilder::noStop → KILLED 3. noStop : replaced return value with null for fr/sii/ogham/sms/builder/ovh/OvhOptionsBuilder::noStop → KILLED 4. noStop : replaced return value with null for fr/sii/ogham/sms/builder/ovh/OvhOptionsBuilder::noStop → KILLED |
return noStopValueBuilder; |
131 | } | |
132 | ||
133 | /** | |
134 | * Set a tag to mark sent messages (20 maximum character string). | |
135 | * | |
136 | * <p> | |
137 | * The value set using this method takes precedence over any property and | |
138 | * default value configured using {@link #tag()}. | |
139 | * | |
140 | * <pre> | |
141 | * .tag("my-tag") | |
142 | * .tag() | |
143 | * .properties("${custom.property.high-priority}", "${custom.property.low-priority}") | |
144 | * .defaultValue("default-tag") | |
145 | * </pre> | |
146 | * | |
147 | * <pre> | |
148 | * .tag("my-tag") | |
149 | * .tag() | |
150 | * .properties("${custom.property.high-priority}", "${custom.property.low-priority}") | |
151 | * .defaultValue("default-tag") | |
152 | * </pre> | |
153 | * | |
154 | * In both cases, {@code tag("my-tag")} is used. | |
155 | * | |
156 | * <p> | |
157 | * If this method is called several times, only the last value is used. | |
158 | * | |
159 | * <p> | |
160 | * If {@code null} value is set, it is like not setting a value at all. The | |
161 | * property/default value configuration is applied. | |
162 | * | |
163 | * @param tag | |
164 | * tag name to use | |
165 | * @return this instance for fluent chaining | |
166 | */ | |
167 | public OvhOptionsBuilder tag(String tag) { | |
168 |
2
1. tag : removed call to fr/sii/ogham/core/builder/configuration/ConfigurationValueBuilderHelper::setValue → NO_COVERAGE 2. tag : removed call to fr/sii/ogham/core/builder/configuration/ConfigurationValueBuilderHelper::setValue → KILLED |
tagValueBuilder.setValue(tag); |
169 |
2
1. tag : replaced return value with null for fr/sii/ogham/sms/builder/ovh/OvhOptionsBuilder::tag → NO_COVERAGE 2. tag : replaced return value with null for fr/sii/ogham/sms/builder/ovh/OvhOptionsBuilder::tag → SURVIVED |
return this; |
170 | } | |
171 | ||
172 | /** | |
173 | * Set a tag to mark sent messages (20 maximum character string). | |
174 | * | |
175 | * <p> | |
176 | * This method is mainly used by {@link Configurer}s to register some | |
177 | * property keys and/or a default value. The aim is to let developer be able | |
178 | * to externalize its configuration (using system properties, configuration | |
179 | * file or anything else). If the developer doesn't configure any value for | |
180 | * the registered properties, the default value is used (if set). | |
181 | * | |
182 | * <pre> | |
183 | * .tag() | |
184 | * .properties("${custom.property.high-priority}", "${custom.property.low-priority}") | |
185 | * .defaultValue("default-tag") | |
186 | * </pre> | |
187 | * | |
188 | * <p> | |
189 | * Non-null value set using {@link #tag(String)} takes precedence over | |
190 | * property values and default value. | |
191 | * | |
192 | * <pre> | |
193 | * .tag("my-tag") | |
194 | * .tag() | |
195 | * .properties("${custom.property.high-priority}", "${custom.property.low-priority}") | |
196 | * .defaultValue("default-tag") | |
197 | * </pre> | |
198 | * | |
199 | * The value {@code "my-tag"} is used regardless of the value of the | |
200 | * properties and default value. | |
201 | * | |
202 | * <p> | |
203 | * See {@link ConfigurationValueBuilder} for more information. | |
204 | * | |
205 | * | |
206 | * @return the builder to configure property keys/default value | |
207 | */ | |
208 | public ConfigurationValueBuilder<OvhOptionsBuilder, String> tag() { | |
209 |
4
1. tag : replaced return value with null for fr/sii/ogham/sms/builder/ovh/OvhOptionsBuilder::tag → NO_COVERAGE 2. tag : replaced return value with null for fr/sii/ogham/sms/builder/ovh/OvhOptionsBuilder::tag → KILLED 3. tag : replaced return value with null for fr/sii/ogham/sms/builder/ovh/OvhOptionsBuilder::tag → KILLED 4. tag : replaced return value with null for fr/sii/ogham/sms/builder/ovh/OvhOptionsBuilder::tag → KILLED |
return tagValueBuilder; |
210 | } | |
211 | ||
212 | /** | |
213 | * Set the message encoding: | |
214 | * <ul> | |
215 | * <li>"1" or "GSM7" for 7bit encoding</li> | |
216 | * <li>"2" or "UNICODE" for 16bit encoding</li> | |
217 | * </ul> | |
218 | * If you use Unicode, your SMS will have a maximum size of 70 characters | |
219 | * instead of 160. | |
220 | * | |
221 | * | |
222 | * <p> | |
223 | * The value set using this method takes precedence over any property and | |
224 | * default value configured using {@link #smsCoding()}. | |
225 | * | |
226 | * <pre> | |
227 | * .smsCoding(SmsCoding.UNICODE) | |
228 | * .smsCoding() | |
229 | * .properties("${custom.property.high-priority}", "${custom.property.low-priority}") | |
230 | * .defaultValue(SmsCoding.GSM7) | |
231 | * </pre> | |
232 | * | |
233 | * <pre> | |
234 | * .smsCoding(SmsCoding.UNICODE) | |
235 | * .smsCoding() | |
236 | * .properties("${custom.property.high-priority}", "${custom.property.low-priority}") | |
237 | * .defaultValue(SmsCoding.GSM7) | |
238 | * </pre> | |
239 | * | |
240 | * In both cases, {@code smsCoding(SmsCoding.UNICODE)} is used. | |
241 | * | |
242 | * <p> | |
243 | * If this method is called several times, only the last value is used. | |
244 | * | |
245 | * <p> | |
246 | * If {@code null} value is set, it is like not setting a value at all. The | |
247 | * property/default value configuration is applied. | |
248 | * | |
249 | * @param smsCoding | |
250 | * the coding for messages | |
251 | * @return this instance for fluent chaining | |
252 | */ | |
253 | public OvhOptionsBuilder smsCoding(SmsCoding smsCoding) { | |
254 |
2
1. smsCoding : removed call to fr/sii/ogham/core/builder/configuration/ConfigurationValueBuilderHelper::setValue → NO_COVERAGE 2. smsCoding : removed call to fr/sii/ogham/core/builder/configuration/ConfigurationValueBuilderHelper::setValue → KILLED |
smsCodingValueBuilder.setValue(smsCoding); |
255 |
2
1. smsCoding : replaced return value with null for fr/sii/ogham/sms/builder/ovh/OvhOptionsBuilder::smsCoding → SURVIVED 2. smsCoding : replaced return value with null for fr/sii/ogham/sms/builder/ovh/OvhOptionsBuilder::smsCoding → NO_COVERAGE |
return this; |
256 | } | |
257 | ||
258 | /** | |
259 | * Set the message encoding: | |
260 | * <ul> | |
261 | * <li>"1" or "GSM7" for 7bit encoding</li> | |
262 | * <li>"2" or "UNICODE" for 16bit encoding</li> | |
263 | * </ul> | |
264 | * If you use Unicode, your SMS will have a maximum size of 70 characters | |
265 | * instead of 160. | |
266 | * | |
267 | * | |
268 | * <p> | |
269 | * This method is mainly used by {@link Configurer}s to register some | |
270 | * property keys and/or a default value. The aim is to let developer be able | |
271 | * to externalize its configuration (using system properties, configuration | |
272 | * file or anything else). If the developer doesn't configure any value for | |
273 | * the registered properties, the default value is used (if set). | |
274 | * | |
275 | * <pre> | |
276 | * .smsCoding() | |
277 | * .properties("${custom.property.high-priority}", "${custom.property.low-priority}") | |
278 | * .defaultValue(SmsCoding.GSM7) | |
279 | * </pre> | |
280 | * | |
281 | * <p> | |
282 | * Non-null value set using {@link #smsCoding(SmsCoding)} takes precedence | |
283 | * over property values and default value. | |
284 | * | |
285 | * <pre> | |
286 | * .smsCoding(SmsCoding.UNICODE) | |
287 | * .smsCoding() | |
288 | * .properties("${custom.property.high-priority}", "${custom.property.low-priority}") | |
289 | * .defaultValue(SmsCoding.GSM7) | |
290 | * </pre> | |
291 | * | |
292 | * The value {@code SmsCoding.UNICODE} is used regardless of the value of | |
293 | * the properties and default value. | |
294 | * | |
295 | * <p> | |
296 | * See {@link ConfigurationValueBuilder} for more information. | |
297 | * | |
298 | * | |
299 | * @return the builder to configure property keys/default value | |
300 | */ | |
301 | public ConfigurationValueBuilder<OvhOptionsBuilder, SmsCoding> smsCoding() { | |
302 |
4
1. smsCoding : replaced return value with null for fr/sii/ogham/sms/builder/ovh/OvhOptionsBuilder::smsCoding → NO_COVERAGE 2. smsCoding : replaced return value with null for fr/sii/ogham/sms/builder/ovh/OvhOptionsBuilder::smsCoding → KILLED 3. smsCoding : replaced return value with null for fr/sii/ogham/sms/builder/ovh/OvhOptionsBuilder::smsCoding → KILLED 4. smsCoding : replaced return value with null for fr/sii/ogham/sms/builder/ovh/OvhOptionsBuilder::smsCoding → KILLED |
return smsCodingValueBuilder; |
303 | } | |
304 | ||
305 | @Override | |
306 | public OvhOptions build() { | |
307 | boolean builtNoStop = buildNoStop(); | |
308 | String builtTag = buildTag(); | |
309 | SmsCoding builtSmsCoding = buildSmsCoding(); | |
310 |
2
1. build : replaced return value with null for fr/sii/ogham/sms/builder/ovh/OvhOptionsBuilder::build → NO_COVERAGE 2. build : replaced return value with null for fr/sii/ogham/sms/builder/ovh/OvhOptionsBuilder::build → KILLED |
return buildContext.register(new OvhOptions(builtNoStop, builtTag, builtSmsCoding)); |
311 | } | |
312 | ||
313 | private boolean buildNoStop() { | |
314 |
4
1. buildNoStop : replaced boolean return with false for fr/sii/ogham/sms/builder/ovh/OvhOptionsBuilder::buildNoStop → NO_COVERAGE 2. buildNoStop : replaced boolean return with true for fr/sii/ogham/sms/builder/ovh/OvhOptionsBuilder::buildNoStop → NO_COVERAGE 3. buildNoStop : replaced boolean return with false for fr/sii/ogham/sms/builder/ovh/OvhOptionsBuilder::buildNoStop → TIMED_OUT 4. buildNoStop : replaced boolean return with true for fr/sii/ogham/sms/builder/ovh/OvhOptionsBuilder::buildNoStop → KILLED |
return noStopValueBuilder.getValue(false); |
315 | } | |
316 | ||
317 | private String buildTag() { | |
318 |
2
1. buildTag : replaced return value with "" for fr/sii/ogham/sms/builder/ovh/OvhOptionsBuilder::buildTag → NO_COVERAGE 2. buildTag : replaced return value with "" for fr/sii/ogham/sms/builder/ovh/OvhOptionsBuilder::buildTag → TIMED_OUT |
return tagValueBuilder.getValue(); |
319 | } | |
320 | ||
321 | private SmsCoding buildSmsCoding() { | |
322 |
2
1. buildSmsCoding : replaced return value with null for fr/sii/ogham/sms/builder/ovh/OvhOptionsBuilder::buildSmsCoding → NO_COVERAGE 2. buildSmsCoding : replaced return value with null for fr/sii/ogham/sms/builder/ovh/OvhOptionsBuilder::buildSmsCoding → KILLED |
return smsCodingValueBuilder.getValue(); |
323 | } | |
324 | } | |
Mutations | ||
88 |
1.1 2.2 |
|
89 |
1.1 2.2 |
|
130 |
1.1 2.2 3.3 4.4 |
|
168 |
1.1 2.2 |
|
169 |
1.1 2.2 |
|
209 |
1.1 2.2 3.3 4.4 |
|
254 |
1.1 2.2 |
|
255 |
1.1 2.2 |
|
302 |
1.1 2.2 3.3 4.4 |
|
310 |
1.1 2.2 |
|
314 |
1.1 2.2 3.3 4.4 |
|
318 |
1.1 2.2 |
|
322 |
1.1 2.2 |