-
Notifications
You must be signed in to change notification settings - Fork 5
/
SystemParticipantValidationUtils.java
636 lines (590 loc) · 23.5 KB
/
SystemParticipantValidationUtils.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
/*
* © 2021. TU Dortmund University,
* Institute of Energy Systems, Energy Efficiency and Energy Economics,
* Research group Distribution grid planning and operation
*/
package edu.ie3.datamodel.utils.validation;
import static edu.ie3.datamodel.models.StandardUnits.*;
import edu.ie3.datamodel.exceptions.InvalidEntityException;
import edu.ie3.datamodel.exceptions.TryException;
import edu.ie3.datamodel.models.input.InputEntity;
import edu.ie3.datamodel.models.input.system.*;
import edu.ie3.datamodel.models.input.system.type.*;
import edu.ie3.datamodel.utils.Try;
import edu.ie3.datamodel.utils.Try.Failure;
import java.util.ArrayList;
import java.util.List;
import javax.measure.Quantity;
import javax.measure.quantity.Dimensionless;
import tech.units.indriya.ComparableQuantity;
import tech.units.indriya.quantity.Quantities;
import tech.units.indriya.unit.Units;
public class SystemParticipantValidationUtils extends ValidationUtils {
/** Private Constructor as this class is not meant to be instantiated */
private SystemParticipantValidationUtils() {
throw new IllegalStateException("Don't try and instantiate a Utility class.");
}
/**
* Validates a system participant if:
*
* <ul>
* <li>it is not null
* <li>its qCharacteristics are not null
* </ul>
*
* <p>A "distribution" method, that forwards the check request to specific implementations to
* fulfill the checking task, based on the class of the given object.
*
* @param systemParticipant systemParticipant to validate
* @return a list of try objects either containing an {@link InvalidEntityException} or an empty
* Success
*/
protected static List<Try<Void, InvalidEntityException>> check(
SystemParticipantInput systemParticipant) {
Try<Void, InvalidEntityException> isNull =
checkNonNull(systemParticipant, "a system participant");
if (isNull.isFailure()) {
return List.of(isNull);
}
List<Try<Void, InvalidEntityException>> exceptions = new ArrayList<>();
exceptions.add(
Try.ofVoid(
systemParticipant.getqCharacteristics() == null,
() ->
new InvalidEntityException(
"Reactive power characteristics of system participant is not defined",
systemParticipant)));
// Further checks for subclasses
if (BmInput.class.isAssignableFrom(systemParticipant.getClass())) {
exceptions.addAll(checkBm((BmInput) systemParticipant));
} else if (ChpInput.class.isAssignableFrom(systemParticipant.getClass())) {
exceptions.addAll(checkChp((ChpInput) systemParticipant));
} else if (EvInput.class.isAssignableFrom(systemParticipant.getClass())) {
exceptions.addAll(checkEv((EvInput) systemParticipant));
} else if (FixedFeedInInput.class.isAssignableFrom(systemParticipant.getClass())) {
exceptions.addAll(checkFixedFeedIn((FixedFeedInInput) systemParticipant));
} else if (HpInput.class.isAssignableFrom(systemParticipant.getClass())) {
exceptions.addAll(checkHp((HpInput) systemParticipant));
} else if (LoadInput.class.isAssignableFrom(systemParticipant.getClass())) {
exceptions.addAll(checkLoad((LoadInput) systemParticipant));
} else if (PvInput.class.isAssignableFrom(systemParticipant.getClass())) {
exceptions.addAll(checkPv((PvInput) systemParticipant));
} else if (StorageInput.class.isAssignableFrom(systemParticipant.getClass())) {
exceptions.addAll(checkStorage((StorageInput) systemParticipant));
} else if (WecInput.class.isAssignableFrom(systemParticipant.getClass())) {
exceptions.addAll(checkWec((WecInput) systemParticipant));
} else if (EvcsInput.class.isAssignableFrom(systemParticipant.getClass())) {
exceptions.addAll(checkEvcs((EvcsInput) systemParticipant));
} else {
logNotImplemented(systemParticipant);
}
return exceptions;
}
/**
* Validates a system participant type if:
*
* <ul>
* <li>it is not null
* <li>capex is not null and not negative
* <li>opex is not null and not negative
* <li>sRated is not null and not negative
* <li>cosphiRated is between zero and one
* </ul>
*
* <p>A "distribution" method, that forwards the check request to specific implementations to
* fulfill the checking task, based on the class of the given object.
*
* @param systemParticipantTypeInput systemParticipant Type to validate
* @return a list of try objects either containing an {@link InvalidEntityException} or an empty
* Success
*/
protected static List<Try<Void, InvalidEntityException>> checkType(
SystemParticipantTypeInput systemParticipantTypeInput) {
Try<Void, InvalidEntityException> isNull =
checkNonNull(systemParticipantTypeInput, "a system participant type");
if (isNull.isFailure()) {
return List.of(isNull);
}
List<Try<Void, InvalidEntityException>> exceptions = new ArrayList<>();
exceptions.add(
Try.ofVoid(
(systemParticipantTypeInput.getCapex() == null)
|| (systemParticipantTypeInput.getOpex() == null)
|| (systemParticipantTypeInput.getsRated() == null),
() ->
new InvalidEntityException(
"At least one of capex, opex, or sRated is null", systemParticipantTypeInput)));
try {
exceptions.add(
Try.ofVoid(
() ->
detectNegativeQuantities(
new Quantity<?>[] {
systemParticipantTypeInput.getCapex(),
systemParticipantTypeInput.getOpex(),
systemParticipantTypeInput.getsRated()
},
systemParticipantTypeInput),
InvalidEntityException.class));
} catch (TryException e) {
Throwable wronglyCaught = e.getCause();
exceptions.add(
Failure.ofVoid(new InvalidEntityException(wronglyCaught.getMessage(), wronglyCaught)));
}
exceptions.add(
Try.ofVoid(
() ->
checkRatedPowerFactor(
systemParticipantTypeInput, systemParticipantTypeInput.getCosPhiRated()),
InvalidEntityException.class));
if (BmTypeInput.class.isAssignableFrom(systemParticipantTypeInput.getClass())) {
exceptions.addAll(checkBmType((BmTypeInput) systemParticipantTypeInput));
} else if (ChpTypeInput.class.isAssignableFrom(systemParticipantTypeInput.getClass())) {
exceptions.addAll(checkChpType((ChpTypeInput) systemParticipantTypeInput));
} else if (EvTypeInput.class.isAssignableFrom(systemParticipantTypeInput.getClass())) {
exceptions.add(checkEvType((EvTypeInput) systemParticipantTypeInput));
} else if (HpTypeInput.class.isAssignableFrom(systemParticipantTypeInput.getClass())) {
exceptions.add(checkHpType((HpTypeInput) systemParticipantTypeInput));
} else if (StorageTypeInput.class.isAssignableFrom(systemParticipantTypeInput.getClass())) {
exceptions.addAll(checkStorageType((StorageTypeInput) systemParticipantTypeInput));
} else if (WecTypeInput.class.isAssignableFrom(systemParticipantTypeInput.getClass())) {
exceptions.addAll(checkWecType((WecTypeInput) systemParticipantTypeInput));
} else {
logNotImplemented(systemParticipantTypeInput);
}
return exceptions;
}
/**
* Validates a bmInput if: <br>
*
* <ul>
* <li>{@link SystemParticipantValidationUtils#checkBmType(BmTypeInput)} confirms a valid type
* properties
* </ul>
*
* @param bmInput BmInput to validate
* @return a list of try objects either containing an {@link InvalidEntityException} or an empty
* Success
*/
private static List<Try<Void, InvalidEntityException>> checkBm(BmInput bmInput) {
return checkType(bmInput.getType());
}
/**
* Validates a bmTypeInput if:
*
* <ul>
* <li>its active power gradient is not negative#
* <li>its efficiency of assets inverter is between 0% and 100%
* </ul>
*
* @param bmTypeInput BmTypeInput to validate
* @return a list of try objects either containing an {@link InvalidEntityException} or an empty
* Success
*/
private static List<Try<Void, InvalidEntityException>> checkBmType(BmTypeInput bmTypeInput) {
return Try.ofVoid(
InvalidEntityException.class,
() ->
detectNegativeQuantities(
new Quantity<?>[] {bmTypeInput.getActivePowerGradient()}, bmTypeInput),
() ->
isBetweenZeroAndHundredPercent(
bmTypeInput, bmTypeInput.getEtaConv(), "Efficiency of inverter"));
}
/**
* Validates a chpInput if:
*
* <ul>
* <li>{@link SystemParticipantValidationUtils#checkChpType(ChpTypeInput)} confirms a valid type
* properties
* </ul>
*
* @param chpInput ChpInput to validate
* @return a list of try objects either containing an {@link InvalidEntityException} or an empty
* Success
*/
private static List<Try<Void, InvalidEntityException>> checkChp(ChpInput chpInput) {
return checkType(chpInput.getType());
}
/**
* Validates a chpTypeInput if:
*
* <ul>
* <li>its efficiency of the electrical inverter is between 0% and 100%
* <li>its thermal efficiency of the system is between 0% and 100%
* <li>its rated thermal power is positive
* <li>its needed self-consumption is not negative
* </ul>
*
* @param chpTypeInput ChpTypeInput to validate
* @return a list of try objects either containing an {@link InvalidEntityException} or an empty
* Success
*/
private static List<Try<Void, InvalidEntityException>> checkChpType(ChpTypeInput chpTypeInput) {
return Try.ofVoid(
InvalidEntityException.class,
() -> detectNegativeQuantities(new Quantity<?>[] {chpTypeInput.getpOwn()}, chpTypeInput),
() ->
detectZeroOrNegativeQuantities(
new Quantity<?>[] {chpTypeInput.getpThermal()}, chpTypeInput),
() ->
isBetweenZeroAndHundredPercent(
chpTypeInput, chpTypeInput.getEtaEl(), "Electrical efficiency"),
() ->
isBetweenZeroAndHundredPercent(
chpTypeInput, chpTypeInput.getEtaThermal(), "Thermal efficiency"));
}
/**
* Validates a EvInput if:
*
* <ul>
* <li>{@link SystemParticipantValidationUtils#checkEvType(EvTypeInput)} confirms a valid type
* properties
* </ul>
*
* @param evInput EvInput to validate
* @return a list of try objects either containing an {@link InvalidEntityException} or an empty
* Success
*/
private static List<Try<Void, InvalidEntityException>> checkEv(EvInput evInput) {
return checkType(evInput.getType());
}
/**
* Validates a EvTypeInput if:
*
* <ul>
* <li>its available battery capacity is positive
* <li>its energy consumption per driven kilometre is positive
* </ul>
*
* @param evTypeInput EvTypeInput to validate
* @return a try object either containing an {@link InvalidEntityException} or an empty Success
*/
private static Try<Void, InvalidEntityException> checkEvType(EvTypeInput evTypeInput) {
return Try.ofVoid(
() ->
detectZeroOrNegativeQuantities(
new Quantity<?>[] {evTypeInput.geteStorage(), evTypeInput.geteCons()}, evTypeInput),
InvalidEntityException.class);
}
/**
* Validates a FixedFeedInInput if:
*
* <ul>
* <li>its rated apparent power is not negative
* <li>its rated power factor is between 0 and 1
* </ul>
*
* @param fixedFeedInInput FixedFeedInInput to validate
* @return a list of try objects either containing an {@link InvalidEntityException} or an empty
* Success
*/
private static List<Try<Void, InvalidEntityException>> checkFixedFeedIn(
FixedFeedInInput fixedFeedInInput) {
return Try.ofVoid(
InvalidEntityException.class,
() ->
detectNegativeQuantities(
new Quantity<?>[] {fixedFeedInInput.getsRated()}, fixedFeedInInput),
() -> checkRatedPowerFactor(fixedFeedInInput, fixedFeedInInput.getCosPhiRated()));
}
/**
* Validates a HpInput if:
*
* <ul>
* <li>{@link SystemParticipantValidationUtils#checkHpType(HpTypeInput)} confirms a valid type
* properties
* </ul>
*
* @param hpInput HpInput to validate
* @return a list of try objects either containing an {@link InvalidEntityException} or an empty
* Success
*/
private static List<Try<Void, InvalidEntityException>> checkHp(HpInput hpInput) {
return checkType(hpInput.getType());
}
/**
* Validates a HpTypeInput if:
*
* <ul>
* <li>its rated thermal power is positive
* </ul>
*
* @param hpTypeInput HpTypeInput to validate
* @return a try object either containing an {@link InvalidEntityException} or an empty Success
*/
private static Try<Void, InvalidEntityException> checkHpType(HpTypeInput hpTypeInput) {
return Try.ofVoid(
() ->
detectZeroOrNegativeQuantities(
new Quantity<?>[] {hpTypeInput.getpThermal()}, hpTypeInput),
InvalidEntityException.class);
}
/**
* Validates a LoadInput if:
*
* <ul>
* <li>its standard load profile is not null
* <li>its rated apparent power is not negative
* <li>its annual energy consumption is not negative
* <li>its rated power factor is between 0 and 1
* </ul>
*
* @param loadInput LoadInput to validate
* @return a list of try objects either containing an {@link InvalidEntityException} or an empty
* Success
*/
private static List<Try<Void, InvalidEntityException>> checkLoad(LoadInput loadInput) {
List<Try<Void, InvalidEntityException>> exceptions = new ArrayList<>();
exceptions.add(
Try.ofVoid(
loadInput.getLoadProfile() == null,
() ->
new InvalidEntityException(
"No standard load profile defined for load", loadInput)));
exceptions.addAll(
Try.ofVoid(
InvalidEntityException.class,
() ->
detectNegativeQuantities(
new Quantity<?>[] {loadInput.getsRated(), loadInput.geteConsAnnual()},
loadInput),
() -> checkRatedPowerFactor(loadInput, loadInput.getCosPhiRated())));
return exceptions;
}
/**
* Validates a PvInput if:
*
* <ul>
* <li>its rated apparent power is not negative
* <li>its albedo value of the plant's surrounding is between 0 and 1
* <li>its inclination in a compass direction (azimuth) is between -90° and 90°
* <li>its efficiency of the asset's inverter (etaConv) is between 0% and 100%
* <li>its tilted inclination from horizontal (elevation angle) is between 0° and 90°
* <li>its rated power factor is between 0 and 1
* </ul>
*
* @param pvInput PvInput to validate
* @return a list of try objects either containing an {@link InvalidEntityException} or an empty
* Success
*/
private static List<Try<Void, InvalidEntityException>> checkPv(PvInput pvInput) {
return Try.ofVoid(
InvalidEntityException.class,
() -> detectNegativeQuantities(new Quantity<?>[] {pvInput.getsRated()}, pvInput),
() -> checkAlbedo(pvInput),
() -> checkAzimuth(pvInput),
() ->
isBetweenZeroAndHundredPercent(
pvInput, pvInput.getEtaConv(), "Efficiency of the converter"),
() -> checkElevationAngle(pvInput),
() -> checkRatedPowerFactor(pvInput, pvInput.getCosPhiRated()));
}
/**
* Check if albedo of pvInput is between 0 and 1
*
* @param pvInput PvInput to validate
*/
private static void checkAlbedo(PvInput pvInput) throws InvalidEntityException {
if (pvInput.getAlbedo() < 0d || pvInput.getAlbedo() > 1d)
throw new InvalidEntityException(
"Albedo of the plant's surrounding of "
+ pvInput.getClass().getSimpleName()
+ " must be between 0 and 1",
pvInput);
}
/**
* Check if azimuth angle of pvInput is between -90° and 90°
*
* @param pvInput PvInput to validate
*/
private static void checkAzimuth(PvInput pvInput) throws InvalidEntityException {
if (pvInput.getAzimuth().isLessThan(Quantities.getQuantity(-90d, AZIMUTH))
|| pvInput.getAzimuth().isGreaterThan(Quantities.getQuantity(90d, AZIMUTH)))
throw new InvalidEntityException(
"Azimuth angle of "
+ pvInput.getClass().getSimpleName()
+ " must be between -90° (east) and 90° (west)",
pvInput);
}
/**
* Check if tilted inclination from horizontal of pvInput is between 0° and 90°
*
* @param pvInput PvInput to validate
*/
private static void checkElevationAngle(PvInput pvInput) throws InvalidEntityException {
if (pvInput.getElevationAngle().isLessThan(Quantities.getQuantity(0d, SOLAR_ELEVATION_ANGLE))
|| pvInput
.getElevationAngle()
.isGreaterThan(Quantities.getQuantity(90d, SOLAR_ELEVATION_ANGLE)))
throw new InvalidEntityException(
"Tilted inclination from horizontal of "
+ pvInput.getClass().getSimpleName()
+ " must be between 0° and 90°",
pvInput);
}
/**
* Validates a StorageInput if:
*
* <ul>
* <li>{@link SystemParticipantValidationUtils#checkStorageType(StorageTypeInput)} confirms a
* valid type properties
* </ul>
*
* @param storageInput StorageInput to validate
* @return a list of try objects either containing an {@link InvalidEntityException} or an empty
* Success
*/
private static List<Try<Void, InvalidEntityException>> checkStorage(StorageInput storageInput) {
return checkType(storageInput.getType());
}
/**
* Validates a StorageTypeInput if:
*
* <ul>
* <li>its permissible amount of full cycles is not negative
* <li>its efficiency of the electrical converter is between 0% and 100%
* <li>its maximum permissible depth of discharge is between 0% and 100%
* <li>its active power gradient is not negative
* <li>its battery capacity is positive
* <li>its maximum permissible active power (in-feed or consumption) is not negative
* <li>its permissible hours of full use is not negative
* </ul>
*
* @param storageTypeInput StorageTypeInput to validate
* @return a list of try objects either containing an {@link InvalidEntityException} or an empty
* Success
*/
private static List<Try<Void, InvalidEntityException>> checkStorageType(
StorageTypeInput storageTypeInput) {
List<Try<Void, InvalidEntityException>> exceptions = new ArrayList<>();
exceptions.add(
Try.ofVoid(
storageTypeInput.getLifeCycle() < 0,
() ->
new InvalidEntityException(
"Permissible amount of life cycles of the storage type must be zero or positive",
storageTypeInput)));
exceptions.addAll(
Try.ofVoid(
InvalidEntityException.class,
() ->
isBetweenZeroAndHundredPercent(
storageTypeInput,
storageTypeInput.getEta(),
"Efficiency of the electrical converter"),
() ->
isBetweenZeroAndHundredPercent(
storageTypeInput,
storageTypeInput.getDod(),
"Maximum permissible depth of discharge"),
() ->
detectNegativeQuantities(
new Quantity<?>[] {
storageTypeInput.getpMax(),
storageTypeInput.getActivePowerGradient(),
storageTypeInput.getLifeTime()
},
storageTypeInput),
() ->
detectZeroOrNegativeQuantities(
new Quantity<?>[] {storageTypeInput.geteStorage()}, storageTypeInput)));
return exceptions;
}
/**
* Validates a WecInput if:
* <li>{@link SystemParticipantValidationUtils#checkWecType(WecTypeInput)} confirms a valid type
* properties
*
* @param wecInput WecInput to validate
* @return a list of try objects either containing an {@link InvalidEntityException} or an empty
* Success
*/
private static List<Try<Void, InvalidEntityException>> checkWec(WecInput wecInput) {
return checkType(wecInput.getType());
}
/**
* Validates a WecTypeInput if:
*
* <ul>
* <li>its efficiency of the assets converter is between 0% and 100%
* <li>its rotor area is not negative
* <li>its height of the rotor hub is not negative
* </ul>
*
* @param wecTypeInput WecTypeInput to validate
* @return a list of try objects either containing an {@link InvalidEntityException} or an empty
* Success
*/
private static List<Try<Void, InvalidEntityException>> checkWecType(WecTypeInput wecTypeInput) {
return Try.ofVoid(
InvalidEntityException.class,
() ->
isBetweenZeroAndHundredPercent(
wecTypeInput, wecTypeInput.getEtaConv(), "Efficiency of the converter"),
() ->
detectNegativeQuantities(
new Quantity<?>[] {wecTypeInput.getRotorArea(), wecTypeInput.getHubHeight()},
wecTypeInput));
}
/**
* Validates a EvcsInput if:
*
* <ul>
* <li>its number of charging points is < 1
* <li>its rated power factor is between 0 and 1
* <li>its rated apparent power is not negative
* </ul>
*
* @param evcsInput EvcsInput to validate
* @return a list of try objects either containing an {@link InvalidEntityException} or an empty
* Success
*/
private static List<Try<Void, InvalidEntityException>> checkEvcs(EvcsInput evcsInput) {
Try.VoidSupplier<InvalidEntityException> chargingPointValidation =
() -> {
if (evcsInput.getChargingPoints() < 1)
throw new InvalidEntityException(
"Invalid number of charging points: '"
+ evcsInput.getChargingPoints()
+ "'. At least one charging point is needed.",
evcsInput);
};
return Try.ofVoid(
InvalidEntityException.class,
chargingPointValidation,
() -> checkRatedPowerFactor(evcsInput, evcsInput.getCosPhiRated()),
() ->
detectNegativeQuantities(new Quantity[] {evcsInput.getType().getsRated()}, evcsInput));
}
/**
* Validates if the rated power factor is between 0 and 1, otherwise throws an {@link
* InvalidEntityException}
*
* @param input entity to validate
* @param cosPhiRated rated power factor to check
*/
private static void checkRatedPowerFactor(InputEntity input, double cosPhiRated)
throws InvalidEntityException {
if (cosPhiRated < 0d || cosPhiRated > 1d)
throw new InvalidEntityException(
"Rated power factor of " + input.getClass().getSimpleName() + " must be between 0 and 1",
input);
}
/**
* Validates if a value (e.g. an efficiency) is between 0% and 100%, otherwise throws an {@link
* InvalidEntityException}
*
* @param input entity to validate
* @param value value of entity to check
*/
private static void isBetweenZeroAndHundredPercent(
InputEntity input, ComparableQuantity<Dimensionless> value, String string)
throws InvalidEntityException {
if (value.isLessThan(Quantities.getQuantity(0d, Units.PERCENT))
|| value.isGreaterThan(Quantities.getQuantity(100d, Units.PERCENT)))
throw new InvalidEntityException(
string + " of " + input.getClass().getSimpleName() + " must be between 0% and 100%",
input);
}
}