Commit ad62940
committed
Allow omitting all optional SampledValue fields
According to the OCPP specification, all fields of the SampledValue
class except for "value" are optional and may be omitted.
However, the Java class implementation in this library initialized all
fields but "phase" to their default values, and prevented resetting all
but the enum fields to null. Most prominently, the "unit" field was
initialized to "Wh" and could not be reset, preventing the generation of
compliant messages for "Frequency" and "Power.Factor" measurands, for
which the "unit" field needs to be omitted.
Remove the initialization of fields to their default values from the
class constructors, so that they are left as null and will be omitted
when serializing the object.
Exempt null references from the validations in the field setter methods,
so that all fields can be set to null.
Add returning the default value in the field getter methods in case the
stored field value is null, where applicable.
Most importantly, for the "unit" field, only replace null with "Wh" for
"Energy" type measurands. This ensures the null is retained for the
"Frequency" and "Power.Factor" measurands, in compliance with the OCPP
specification.1 parent 9ce7411 commit ad62940
File tree
1 file changed
+12
-27
lines changed- ocpp-v1_6/src/main/java/eu/chargetime/ocpp/model/core
1 file changed
+12
-27
lines changedLines changed: 12 additions & 27 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
53 | 53 | | |
54 | 54 | | |
55 | 55 | | |
56 | | - | |
57 | | - | |
58 | | - | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
63 | | - | |
64 | | - | |
65 | | - | |
66 | | - | |
| 56 | + | |
67 | 57 | | |
68 | 58 | | |
69 | 59 | | |
| |||
73 | 63 | | |
74 | 64 | | |
75 | 65 | | |
76 | | - | |
77 | | - | |
78 | | - | |
79 | | - | |
80 | | - | |
81 | 66 | | |
82 | 67 | | |
83 | 68 | | |
| |||
117 | 102 | | |
118 | 103 | | |
119 | 104 | | |
120 | | - | |
| 105 | + | |
121 | 106 | | |
122 | 107 | | |
123 | 108 | | |
| |||
132 | 117 | | |
133 | 118 | | |
134 | 119 | | |
135 | | - | |
| 120 | + | |
136 | 121 | | |
137 | 122 | | |
138 | 123 | | |
| |||
159 | 144 | | |
160 | 145 | | |
161 | 146 | | |
162 | | - | |
| 147 | + | |
163 | 148 | | |
164 | 149 | | |
165 | 150 | | |
| |||
179 | 164 | | |
180 | 165 | | |
181 | 166 | | |
182 | | - | |
| 167 | + | |
183 | 168 | | |
184 | 169 | | |
185 | 170 | | |
| |||
188 | 173 | | |
189 | 174 | | |
190 | 175 | | |
191 | | - | |
| 176 | + | |
192 | 177 | | |
193 | 178 | | |
194 | 179 | | |
| |||
208 | 193 | | |
209 | 194 | | |
210 | 195 | | |
211 | | - | |
| 196 | + | |
212 | 197 | | |
213 | 198 | | |
214 | 199 | | |
| |||
265 | 250 | | |
266 | 251 | | |
267 | 252 | | |
268 | | - | |
| 253 | + | |
269 | 254 | | |
270 | 255 | | |
271 | 256 | | |
| |||
283 | 268 | | |
284 | 269 | | |
285 | 270 | | |
286 | | - | |
| 271 | + | |
287 | 272 | | |
288 | 273 | | |
289 | 274 | | |
| |||
303 | 288 | | |
304 | 289 | | |
305 | 290 | | |
306 | | - | |
| 291 | + | |
307 | 292 | | |
308 | 293 | | |
309 | 294 | | |
| |||
312 | 297 | | |
313 | 298 | | |
314 | 299 | | |
315 | | - | |
| 300 | + | |
316 | 301 | | |
317 | 302 | | |
318 | 303 | | |
| |||
328 | 313 | | |
329 | 314 | | |
330 | 315 | | |
331 | | - | |
| 316 | + | |
332 | 317 | | |
333 | 318 | | |
334 | 319 | | |
| |||
0 commit comments