1 | package fr.sii.ogham.sms.builder.cloudhopper; | |
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.builder.cloudhopper.UserDataBuilder.UserDataPropValues; | |
11 | import fr.sii.ogham.sms.sender.impl.cloudhopper.preparator.MessagePreparator; | |
12 | ||
13 | /** | |
14 | * "User Data" represents the text message or data to be transmitted the | |
15 | * end-user. | |
16 | * | |
17 | * <p> | |
18 | * The length of the short message text (or user data) is defined in the | |
19 | * {@code sm_length} field of the {@code submit_sm}, {@code submit_multi}, | |
20 | * {@code deliver_sm} and {@code replace_sm} SMPP PDUs. The maximum message | |
21 | * length which can be specified in {@code sm_length} field is 254 octets. If an | |
22 | * ESME wishes to submit a message of length greater than 254 octets, the | |
23 | * {@code sm_length} field must be set to {@code NULL} and the | |
24 | * {@code message_payload} optional parameter must be populated with the message | |
25 | * length value and user data. SMPP supports extended message lengths in the | |
26 | * {@code submit_sm}, {@code submit_multi}, {@code data_sm} and | |
27 | * {@code deliver_sm} PDUs. Note: The actual short message length which can be | |
28 | * transmitted to a MS may vary according to the underlying network. | |
29 | * | |
30 | * <p> | |
31 | * This builder allows to select which field to use: | |
32 | * <ul> | |
33 | * <li>either {@code short_message} fields</li> | |
34 | * <li>or {@code message_payload} optional TLV (Tag-Length-Value) parameter</li> | |
35 | * </ul> | |
36 | * | |
37 | * @author Aurélien Baudet | |
38 | * | |
39 | */ | |
40 | public class UserDataBuilder extends AbstractParent<CloudhopperBuilder> implements Builder<UserDataPropValues> { | |
41 | private final ConfigurationValueBuilderHelper<UserDataBuilder, Boolean> useShortMessageValueBuilder; | |
42 | private final ConfigurationValueBuilderHelper<UserDataBuilder, Boolean> useTlvMessagePayloadValueBuilder; | |
43 | ||
44 | /** | |
45 | * Initializes the builder with a parent builder. The parent builder is used | |
46 | * when calling {@link #and()} method. The {@link EnvironmentBuilder} is | |
47 | * used to evaluate properties when {@link #build()} method is called. | |
48 | * | |
49 | * @param parent | |
50 | * the parent builder | |
51 | * @param buildContext | |
52 | * for registering instances and property evaluation | |
53 | */ | |
54 | public UserDataBuilder(CloudhopperBuilder parent, BuildContext buildContext) { | |
55 | super(parent); | |
56 | useShortMessageValueBuilder = buildContext.newConfigurationValueBuilder(this, Boolean.class); | |
57 | useTlvMessagePayloadValueBuilder = buildContext.newConfigurationValueBuilder(this, Boolean.class); | |
58 | } | |
59 | ||
60 | /** | |
61 | * Enable/disable use of {@code short_message} field. | |
62 | * | |
63 | * <p> | |
64 | * The value set using this method takes precedence over any property and | |
65 | * default value configured using {@link #useShortMessage()}. | |
66 | * | |
67 | * <pre> | |
68 | * .useShortMessage(true) | |
69 | * .useShortMessage() | |
70 | * .properties("${custom.property.high-priority}", "${custom.property.low-priority}") | |
71 | * .defaultValue(false) | |
72 | * </pre> | |
73 | * | |
74 | * <pre> | |
75 | * .useShortMessage(true) | |
76 | * .useShortMessage() | |
77 | * .properties("${custom.property.high-priority}", "${custom.property.low-priority}") | |
78 | * .defaultValue(false) | |
79 | * </pre> | |
80 | * | |
81 | * In both cases, {@code useShortMessage(true)} is used. | |
82 | * | |
83 | * <p> | |
84 | * If this method is called several times, only the last value is used. | |
85 | * | |
86 | * <p> | |
87 | * If {@code null} value is set, it is like not setting a value at all. The | |
88 | * property/default value configuration is applied. | |
89 | * | |
90 | * @param useShortMessage | |
91 | * enable (true) or disable (false) use of {@code short_message} | |
92 | * field | |
93 | * @return this instance for fluent chaining | |
94 | */ | |
95 | public UserDataBuilder useShortMessage(Boolean useShortMessage) { | |
96 |
2
1. useShortMessage : removed call to fr/sii/ogham/core/builder/configuration/ConfigurationValueBuilderHelper::setValue → SURVIVED 2. useShortMessage : removed call to fr/sii/ogham/core/builder/configuration/ConfigurationValueBuilderHelper::setValue → NO_COVERAGE |
useShortMessageValueBuilder.setValue(useShortMessage); |
97 |
3
1. useShortMessage : replaced return value with null for fr/sii/ogham/sms/builder/cloudhopper/UserDataBuilder::useShortMessage → NO_COVERAGE 2. useShortMessage : replaced return value with null for fr/sii/ogham/sms/builder/cloudhopper/UserDataBuilder::useShortMessage → KILLED 3. useShortMessage : replaced return value with null for fr/sii/ogham/sms/builder/cloudhopper/UserDataBuilder::useShortMessage → KILLED |
return this; |
98 | } | |
99 | ||
100 | /** | |
101 | * Enable/disable use of {@code short_message} field to carry text message | |
102 | * (named User Data). | |
103 | * | |
104 | * <p> | |
105 | * This method is mainly used by {@link Configurer}s to register some | |
106 | * property keys and/or a default value. The aim is to let developer be able | |
107 | * to externalize its configuration (using system properties, configuration | |
108 | * file or anything else). If the developer doesn't configure any value for | |
109 | * the registered properties, the default value is used (if set). | |
110 | * | |
111 | * <pre> | |
112 | * .useShortMessage() | |
113 | * .properties("${custom.property.high-priority}", "${custom.property.low-priority}") | |
114 | * .defaultValue(true) | |
115 | * </pre> | |
116 | * | |
117 | * <p> | |
118 | * Non-null value set using {@link #useShortMessage(Boolean)} takes | |
119 | * precedence over property values and default value: | |
120 | * | |
121 | * <pre> | |
122 | * .useShortMessage(false) | |
123 | * .useShortMessage() | |
124 | * .properties("${custom.property.high-priority}", "${custom.property.low-priority}") | |
125 | * .defaultValue(true) | |
126 | * </pre> | |
127 | * | |
128 | * The value {@code false} is used regardless of the value of the properties | |
129 | * and default value. | |
130 | * | |
131 | * <p> | |
132 | * See {@link ConfigurationValueBuilder} for more information. | |
133 | * | |
134 | * | |
135 | * @return the builder to configure property keys/default value | |
136 | */ | |
137 | public ConfigurationValueBuilder<UserDataBuilder, Boolean> useShortMessage() { | |
138 |
5
1. useShortMessage : replaced return value with null for fr/sii/ogham/sms/builder/cloudhopper/UserDataBuilder::useShortMessage → KILLED 2. useShortMessage : replaced return value with null for fr/sii/ogham/sms/builder/cloudhopper/UserDataBuilder::useShortMessage → KILLED 3. useShortMessage : replaced return value with null for fr/sii/ogham/sms/builder/cloudhopper/UserDataBuilder::useShortMessage → KILLED 4. useShortMessage : replaced return value with null for fr/sii/ogham/sms/builder/cloudhopper/UserDataBuilder::useShortMessage → KILLED 5. useShortMessage : replaced return value with null for fr/sii/ogham/sms/builder/cloudhopper/UserDataBuilder::useShortMessage → KILLED |
return useShortMessageValueBuilder; |
139 | } | |
140 | ||
141 | /** | |
142 | * Enable/disable use of {@code message_payload} optional TLV | |
143 | * (Tag-Value-Length) parameter to carry text message (named User Data). | |
144 | * | |
145 | * <strong>NOTE:</strong> The TLV optional parameters are available since | |
146 | * SMPP version 3.4. | |
147 | * | |
148 | * <p> | |
149 | * The value set using this method takes precedence over any property and | |
150 | * default value configured using {@link #useTlvMessagePayload()}. | |
151 | * | |
152 | * <pre> | |
153 | * .useTlvMessagePayload(false) | |
154 | * .useTlvMessagePayload() | |
155 | * .properties("${custom.property.high-priority}", "${custom.property.low-priority}") | |
156 | * .defaultValue(true) | |
157 | * </pre> | |
158 | * | |
159 | * <pre> | |
160 | * .useTlvMessagePayload(false) | |
161 | * .useTlvMessagePayload() | |
162 | * .properties("${custom.property.high-priority}", "${custom.property.low-priority}") | |
163 | * .defaultValue(true) | |
164 | * </pre> | |
165 | * | |
166 | * In both cases, {@code useTlvMessagePayload(false)} is used. | |
167 | * | |
168 | * <p> | |
169 | * If this method is called several times, only the last value is used. | |
170 | * | |
171 | * <p> | |
172 | * If {@code null} value is set, it is like not setting a value at all. The | |
173 | * property/default value configuration is applied. | |
174 | * | |
175 | * @param useTlvMessagePayload | |
176 | * enable (true) or disable (false) use of | |
177 | * {@code message_payload} optional parameter to carry text | |
178 | * message | |
179 | * @return this instance for fluent chaining | |
180 | */ | |
181 | public UserDataBuilder useTlvMessagePayload(Boolean useTlvMessagePayload) { | |
182 |
3
1. useTlvMessagePayload : removed call to fr/sii/ogham/core/builder/configuration/ConfigurationValueBuilderHelper::setValue → SURVIVED 2. useTlvMessagePayload : removed call to fr/sii/ogham/core/builder/configuration/ConfigurationValueBuilderHelper::setValue → NO_COVERAGE 3. useTlvMessagePayload : removed call to fr/sii/ogham/core/builder/configuration/ConfigurationValueBuilderHelper::setValue → KILLED |
useTlvMessagePayloadValueBuilder.setValue(useTlvMessagePayload); |
183 |
3
1. useTlvMessagePayload : replaced return value with null for fr/sii/ogham/sms/builder/cloudhopper/UserDataBuilder::useTlvMessagePayload → NO_COVERAGE 2. useTlvMessagePayload : replaced return value with null for fr/sii/ogham/sms/builder/cloudhopper/UserDataBuilder::useTlvMessagePayload → KILLED 3. useTlvMessagePayload : replaced return value with null for fr/sii/ogham/sms/builder/cloudhopper/UserDataBuilder::useTlvMessagePayload → KILLED |
return this; |
184 | } | |
185 | ||
186 | /** | |
187 | * Enable/disable use of {@code message_payload} optional TLV | |
188 | * (Tag-Value-Length) parameter to carry text message (named User Data). | |
189 | * | |
190 | * <p> | |
191 | * This method is mainly used by {@link Configurer}s to register some | |
192 | * property keys and/or a default value. The aim is to let developer be able | |
193 | * to externalize its configuration (using system properties, configuration | |
194 | * file or anything else). If the developer doesn't configure any value for | |
195 | * the registered properties, the default value is used (if set). | |
196 | * | |
197 | * <pre> | |
198 | * .useTlvMessagePayload() | |
199 | * .properties("${custom.property.high-priority}", "${custom.property.low-priority}") | |
200 | * .defaultValue(true) | |
201 | * </pre> | |
202 | * | |
203 | * <p> | |
204 | * Non-null value set using {@link #useTlvMessagePayload(Boolean)} takes | |
205 | * precedence over property values and default value. | |
206 | * | |
207 | * <pre> | |
208 | * .useTlvMessagePayload(false) | |
209 | * .useTlvMessagePayload() | |
210 | * .properties("${custom.property.high-priority}", "${custom.property.low-priority}") | |
211 | * .defaultValue(true) | |
212 | * </pre> | |
213 | * | |
214 | * The value {@code false} is used regardless of the value of the properties | |
215 | * and default value. | |
216 | * | |
217 | * <p> | |
218 | * See {@link ConfigurationValueBuilder} for more information. | |
219 | * | |
220 | * | |
221 | * @return the builder to configure property keys/default value | |
222 | */ | |
223 | public ConfigurationValueBuilder<UserDataBuilder, Boolean> useTlvMessagePayload() { | |
224 |
5
1. useTlvMessagePayload : replaced return value with null for fr/sii/ogham/sms/builder/cloudhopper/UserDataBuilder::useTlvMessagePayload → KILLED 2. useTlvMessagePayload : replaced return value with null for fr/sii/ogham/sms/builder/cloudhopper/UserDataBuilder::useTlvMessagePayload → KILLED 3. useTlvMessagePayload : replaced return value with null for fr/sii/ogham/sms/builder/cloudhopper/UserDataBuilder::useTlvMessagePayload → KILLED 4. useTlvMessagePayload : replaced return value with null for fr/sii/ogham/sms/builder/cloudhopper/UserDataBuilder::useTlvMessagePayload → KILLED 5. useTlvMessagePayload : replaced return value with null for fr/sii/ogham/sms/builder/cloudhopper/UserDataBuilder::useTlvMessagePayload → KILLED |
return useTlvMessagePayloadValueBuilder; |
225 | } | |
226 | ||
227 | @Override | |
228 | public UserDataPropValues build() { | |
229 | boolean useShort = useShortMessageValueBuilder.getValue(false); | |
230 | boolean useTlv = useTlvMessagePayloadValueBuilder.getValue(false); | |
231 |
5
1. build : replaced return value with null for fr/sii/ogham/sms/builder/cloudhopper/UserDataBuilder::build → KILLED 2. build : replaced return value with null for fr/sii/ogham/sms/builder/cloudhopper/UserDataBuilder::build → KILLED 3. build : replaced return value with null for fr/sii/ogham/sms/builder/cloudhopper/UserDataBuilder::build → KILLED 4. build : replaced return value with null for fr/sii/ogham/sms/builder/cloudhopper/UserDataBuilder::build → KILLED 5. build : replaced return value with null for fr/sii/ogham/sms/builder/cloudhopper/UserDataBuilder::build → KILLED |
return new UserDataPropValues(useShort, useTlv); |
232 | } | |
233 | ||
234 | /** | |
235 | * Simple data class to provide configured values. This is used by parent | |
236 | * builder to affect {@link MessagePreparator} strategy. | |
237 | * | |
238 | * @author Aurélien Baudet | |
239 | */ | |
240 | public static class UserDataPropValues { | |
241 | private final boolean useShortMessage; | |
242 | private final boolean useTlvMessagePayload; | |
243 | ||
244 | /** | |
245 | * Initializes with configured values. | |
246 | * | |
247 | * @param useShortMessage | |
248 | * true if {@code short_message} field should be used | |
249 | * @param useTlvMessagePayload | |
250 | * true {@code message_payload} optional parameter should be | |
251 | * used | |
252 | */ | |
253 | public UserDataPropValues(boolean useShortMessage, boolean useTlvMessagePayload) { | |
254 | super(); | |
255 | this.useShortMessage = useShortMessage; | |
256 | this.useTlvMessagePayload = useTlvMessagePayload; | |
257 | } | |
258 | ||
259 | /** | |
260 | * @return is the {@code short_message} field should be used | |
261 | */ | |
262 | public boolean isUseShortMessage() { | |
263 |
4
1. isUseShortMessage : replaced boolean return with false for fr/sii/ogham/sms/builder/cloudhopper/UserDataBuilder$UserDataPropValues::isUseShortMessage → SURVIVED 2. isUseShortMessage : replaced boolean return with true for fr/sii/ogham/sms/builder/cloudhopper/UserDataBuilder$UserDataPropValues::isUseShortMessage → SURVIVED 3. isUseShortMessage : replaced boolean return with true for fr/sii/ogham/sms/builder/cloudhopper/UserDataBuilder$UserDataPropValues::isUseShortMessage → KILLED 4. isUseShortMessage : replaced boolean return with true for fr/sii/ogham/sms/builder/cloudhopper/UserDataBuilder$UserDataPropValues::isUseShortMessage → KILLED |
return useShortMessage; |
264 | } | |
265 | ||
266 | /** | |
267 | * @return is the {@code message_payload} optional parameter should be | |
268 | * used | |
269 | */ | |
270 | public boolean isUseTlvMessagePayload() { | |
271 |
5
1. isUseTlvMessagePayload : replaced boolean return with false for fr/sii/ogham/sms/builder/cloudhopper/UserDataBuilder$UserDataPropValues::isUseTlvMessagePayload → NO_COVERAGE 2. isUseTlvMessagePayload : replaced boolean return with true for fr/sii/ogham/sms/builder/cloudhopper/UserDataBuilder$UserDataPropValues::isUseTlvMessagePayload → NO_COVERAGE 3. isUseTlvMessagePayload : replaced boolean return with true for fr/sii/ogham/sms/builder/cloudhopper/UserDataBuilder$UserDataPropValues::isUseTlvMessagePayload → SURVIVED 4. isUseTlvMessagePayload : replaced boolean return with false for fr/sii/ogham/sms/builder/cloudhopper/UserDataBuilder$UserDataPropValues::isUseTlvMessagePayload → KILLED 5. isUseTlvMessagePayload : replaced boolean return with false for fr/sii/ogham/sms/builder/cloudhopper/UserDataBuilder$UserDataPropValues::isUseTlvMessagePayload → KILLED |
return useTlvMessagePayload; |
272 | } | |
273 | ||
274 | } | |
275 | } | |
Mutations | ||
96 |
1.1 2.2 |
|
97 |
1.1 2.2 3.3 |
|
138 |
1.1 2.2 3.3 4.4 5.5 |
|
182 |
1.1 2.2 3.3 |
|
183 |
1.1 2.2 3.3 |
|
224 |
1.1 2.2 3.3 4.4 5.5 |
|
231 |
1.1 2.2 3.3 4.4 5.5 |
|
263 |
1.1 2.2 3.3 4.4 |
|
271 |
1.1 2.2 3.3 4.4 5.5 |