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 package com.helger.jcodemodel.util;
42
43 import java.math.BigDecimal;
44 import java.math.BigInteger;
45 import java.util.Collection;
46 import java.util.Map;
47 import java.util.concurrent.atomic.AtomicBoolean;
48 import java.util.function.Supplier;
49
50 import javax.annotation.Nonnegative;
51 import javax.annotation.Nonnull;
52 import javax.annotation.Nullable;
53 import javax.annotation.concurrent.Immutable;
54
55 @Immutable
56 public final class JCValueEnforcer
57 {
58 private static final AtomicBoolean s_aEnabled = new AtomicBoolean (true);
59
60 private JCValueEnforcer ()
61 {}
62
63
64
65
66
67 public static boolean isEnabled ()
68 {
69 return s_aEnabled.get ();
70 }
71
72
73
74
75
76
77
78 public static void setEnabled (final boolean bEnabled)
79 {
80 s_aEnabled.set (bEnabled);
81 }
82
83
84
85
86
87
88
89
90
91
92
93 public static void isTrue (final boolean bValue, final String sMsg)
94 {
95 isTrue (bValue, () -> sMsg);
96 }
97
98
99
100
101
102
103
104
105
106
107
108 public static void isTrue (final boolean bValue, @Nonnull final Supplier <? extends String> aMsg)
109 {
110 if (isEnabled ())
111 if (!bValue)
112 throw new IllegalArgumentException ("The expression must be true but it is not: " + aMsg.get ());
113 }
114
115
116
117
118
119
120
121
122
123
124
125 public static void isFalse (final boolean bValue, final String sMsg)
126 {
127 isFalse (bValue, () -> sMsg);
128 }
129
130
131
132
133
134
135
136
137
138
139
140 public static void isFalse (final boolean bValue, @Nonnull final Supplier <? extends String> aMsg)
141 {
142 if (isEnabled ())
143 if (bValue)
144 throw new IllegalArgumentException ("The expression must be false but it is not: " + aMsg.get ());
145 }
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162 public static <T> void isInstanceOf (@Nullable final T aValue,
163 @Nonnull final Class <? extends T> aClass,
164 final String sMsg)
165 {
166 isInstanceOf (aValue, aClass, () -> sMsg);
167 }
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184 public static <T> void isInstanceOf (@Nullable final T aValue,
185 @Nonnull final Class <? extends T> aClass,
186 @Nonnull final Supplier <? extends String> aMsg)
187 {
188 notNull (aClass, "Class");
189 if (isEnabled ())
190 if (!aClass.isInstance (aValue))
191 throw new IllegalArgumentException (aMsg.get () +
192 " must be of class " +
193 aClass.getName () +
194 " but is of type " +
195 aValue.getClass ().getName ());
196 }
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211 public static <T> T notNull (final T aValue, final String sName)
212 {
213 if (isEnabled ())
214 if (aValue == null)
215 throw new NullPointerException ("The value of '" + sName + "' may not be null!");
216 return aValue;
217 }
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232 public static <T> T notNull (final T aValue, @Nonnull final Supplier <? extends String> aName)
233 {
234 if (isEnabled ())
235 if (aValue == null)
236 throw new NullPointerException ("The value of '" + aName.get () + "' may not be null!");
237 return aValue;
238 }
239
240
241
242
243
244
245
246
247
248
249
250 public static void isNull (final Object aValue, final String sName)
251 {
252 isNull (aValue, () -> sName);
253 }
254
255
256
257
258
259
260
261
262
263
264
265 public static void isNull (final Object aValue, @Nonnull final Supplier <? extends String> aName)
266 {
267 if (isEnabled ())
268 if (aValue != null)
269 throw new IllegalArgumentException ("The value of '" + aName.get () + "' must be null but is " + aValue);
270 }
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285 public static <T extends CharSequence> T notEmpty (final T aValue, final String sName)
286 {
287 return notEmpty (aValue, () -> sName);
288 }
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303 public static <T extends CharSequence> T notEmpty (final T aValue, @Nonnull final Supplier <? extends String> aName)
304 {
305 notNull (aValue, aName);
306 if (isEnabled ())
307 if (aValue.length () == 0)
308 throw new IllegalArgumentException ("The value of the string '" + aName.get () + "' may not be empty!");
309 return aValue;
310 }
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325 public static <T> T [] notEmpty (final T [] aValue, final String sName)
326 {
327 return notEmpty (aValue, () -> sName);
328 }
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343 public static <T> T [] notEmpty (final T [] aValue, @Nonnull final Supplier <? extends String> aName)
344 {
345 notNull (aValue, aName);
346 if (isEnabled ())
347 if (aValue.length == 0)
348 throw new IllegalArgumentException ("The value of the array '" + aName.get () + "' may not be empty!");
349 return aValue;
350 }
351
352
353
354
355
356
357
358
359
360
361
362
363 public static boolean [] notEmpty (final boolean [] aValue, final String sName)
364 {
365 return notEmpty (aValue, () -> sName);
366 }
367
368
369
370
371
372
373
374
375
376
377
378
379 public static boolean [] notEmpty (final boolean [] aValue, @Nonnull final Supplier <? extends String> aName)
380 {
381 notNull (aValue, aName);
382 if (isEnabled ())
383 if (aValue.length == 0)
384 throw new IllegalArgumentException ("The value of the array '" + aName.get () + "' may not be empty!");
385 return aValue;
386 }
387
388
389
390
391
392
393
394
395
396
397
398
399 public static byte [] notEmpty (final byte [] aValue, final String sName)
400 {
401 return notEmpty (aValue, () -> sName);
402 }
403
404
405
406
407
408
409
410
411
412
413
414
415 public static byte [] notEmpty (final byte [] aValue, @Nonnull final Supplier <? extends String> aName)
416 {
417 notNull (aValue, aName);
418 if (isEnabled ())
419 if (aValue.length == 0)
420 throw new IllegalArgumentException ("The value of the array '" + aName.get () + "' may not be empty!");
421 return aValue;
422 }
423
424
425
426
427
428
429
430
431
432
433
434
435 public static char [] notEmpty (final char [] aValue, final String sName)
436 {
437 return notEmpty (aValue, () -> sName);
438 }
439
440
441
442
443
444
445
446
447
448
449
450
451 public static char [] notEmpty (final char [] aValue, @Nonnull final Supplier <? extends String> aName)
452 {
453 notNull (aValue, aName);
454 if (isEnabled ())
455 if (aValue.length == 0)
456 throw new IllegalArgumentException ("The value of the array '" + aName.get () + "' may not be empty!");
457 return aValue;
458 }
459
460
461
462
463
464
465
466
467
468
469
470
471 public static double [] notEmpty (final double [] aValue, final String sName)
472 {
473 return notEmpty (aValue, () -> sName);
474 }
475
476
477
478
479
480
481
482
483
484
485
486
487 public static double [] notEmpty (final double [] aValue, @Nonnull final Supplier <? extends String> aName)
488 {
489 notNull (aValue, aName);
490 if (isEnabled ())
491 if (aValue.length == 0)
492 throw new IllegalArgumentException ("The value of the array '" + aName.get () + "' may not be empty!");
493 return aValue;
494 }
495
496
497
498
499
500
501
502
503
504
505
506
507 public static float [] notEmpty (final float [] aValue, final String sName)
508 {
509 return notEmpty (aValue, () -> sName);
510 }
511
512
513
514
515
516
517
518
519
520
521
522
523 public static float [] notEmpty (final float [] aValue, @Nonnull final Supplier <? extends String> aName)
524 {
525 notNull (aValue, aName);
526 if (isEnabled ())
527 if (aValue.length == 0)
528 throw new IllegalArgumentException ("The value of the array '" + aName.get () + "' may not be empty!");
529 return aValue;
530 }
531
532
533
534
535
536
537
538
539
540
541
542
543 public static int [] notEmpty (final int [] aValue, final String sName)
544 {
545 return notEmpty (aValue, () -> sName);
546 }
547
548
549
550
551
552
553
554
555
556
557
558
559 public static int [] notEmpty (final int [] aValue, @Nonnull final Supplier <? extends String> aName)
560 {
561 notNull (aValue, aName);
562 if (isEnabled ())
563 if (aValue.length == 0)
564 throw new IllegalArgumentException ("The value of the array '" + aName.get () + "' may not be empty!");
565 return aValue;
566 }
567
568
569
570
571
572
573
574
575
576
577
578
579 public static long [] notEmpty (final long [] aValue, final String sName)
580 {
581 return notEmpty (aValue, () -> sName);
582 }
583
584
585
586
587
588
589
590
591
592
593
594
595 public static long [] notEmpty (final long [] aValue, @Nonnull final Supplier <? extends String> aName)
596 {
597 notNull (aValue, aName);
598 if (isEnabled ())
599 if (aValue.length == 0)
600 throw new IllegalArgumentException ("The value of the array '" + aName.get () + "' may not be empty!");
601 return aValue;
602 }
603
604
605
606
607
608
609
610
611
612
613
614
615 public static short [] notEmpty (final short [] aValue, final String sName)
616 {
617 return notEmpty (aValue, () -> sName);
618 }
619
620
621
622
623
624
625
626
627
628
629
630
631 public static short [] notEmpty (final short [] aValue, @Nonnull final Supplier <? extends String> aName)
632 {
633 notNull (aValue, aName);
634 if (isEnabled ())
635 if (aValue.length == 0)
636 throw new IllegalArgumentException ("The value of the array '" + aName.get () + "' may not be empty!");
637 return aValue;
638 }
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654 public static <T extends Collection <?>> T notEmpty (final T aValue, final String sName)
655 {
656 return notEmpty (aValue, () -> sName);
657 }
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673 public static <T extends Collection <?>> T notEmpty (final T aValue, @Nonnull final Supplier <? extends String> aName)
674 {
675 notNull (aValue, aName);
676 if (isEnabled ())
677 if (aValue.isEmpty ())
678 throw new IllegalArgumentException ("The value of the collection '" + aName.get () + "' may not be empty!");
679 return aValue;
680 }
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696 public static <T extends Iterable <?>> T notEmpty (final T aValue, final String sName)
697 {
698 return notEmpty (aValue, () -> sName);
699 }
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715 public static <T extends Iterable <?>> T notEmpty (final T aValue, @Nonnull final Supplier <? extends String> aName)
716 {
717 notNull (aValue, aName);
718 if (isEnabled ())
719 if (!aValue.iterator ().hasNext ())
720 throw new IllegalArgumentException ("The value of the iterable '" + aName.get () + "' may not be empty!");
721 return aValue;
722 }
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737 public static <T extends Map <?, ?>> T notEmpty (final T aValue, final String sName)
738 {
739 return notEmpty (aValue, () -> sName);
740 }
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755 public static <T extends Map <?, ?>> T notEmpty (final T aValue, @Nonnull final Supplier <? extends String> aName)
756 {
757 notNull (aValue, aName);
758 if (isEnabled ())
759 if (aValue.isEmpty ())
760 throw new IllegalArgumentException ("The value of the map '" + aName.get () + "' may not be empty!");
761 return aValue;
762 }
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779 @Nullable
780 public static <T> T [] noNullValue (final T [] aValue, final String sName)
781 {
782 return noNullValue (aValue, () -> sName);
783 }
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800 @Nullable
801 public static <T> T [] noNullValue (final T [] aValue, @Nonnull final Supplier <? extends String> aName)
802 {
803 if (isEnabled ())
804 if (aValue != null)
805 {
806 int nIndex = 0;
807 for (final T aItem : aValue)
808 {
809 if (aItem == null)
810 throw new IllegalArgumentException ("Item " + nIndex + " of array '" + aName.get () + "' may not be null!");
811 ++nIndex;
812 }
813 }
814 return aValue;
815 }
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832 @Nullable
833 public static <T extends Iterable <?>> T noNullValue (final T aValue, final String sName)
834 {
835 return noNullValue (aValue, () -> sName);
836 }
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853 @Nullable
854 public static <T extends Iterable <?>> T noNullValue (final T aValue,
855 @Nonnull final Supplier <? extends String> aName)
856 {
857 if (isEnabled ())
858 if (aValue != null)
859 {
860 int nIndex = 0;
861 for (final Object aItem : aValue)
862 {
863 if (aItem == null)
864 throw new IllegalArgumentException ("Item " +
865 nIndex +
866 " of iterable '" +
867 aName.get () +
868 "' may not be null!");
869 ++nIndex;
870 }
871 }
872 return aValue;
873 }
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890 @Nullable
891 public static <T extends Map <?, ?>> T noNullValue (final T aValue, final String sName)
892 {
893 return noNullValue (aValue, () -> sName);
894 }
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911 @Nullable
912 public static <T extends Map <?, ?>> T noNullValue (final T aValue, @Nonnull final Supplier <? extends String> aName)
913 {
914 if (isEnabled ())
915 if (aValue != null)
916 {
917 for (final Map.Entry <?, ?> aEntry : aValue.entrySet ())
918 {
919 if (aEntry.getKey () == null)
920 throw new IllegalArgumentException ("A key of map '" + aName.get () + "' may not be null!");
921 if (aEntry.getValue () == null)
922 throw new IllegalArgumentException ("A value of map '" + aName.get () + "' may not be null!");
923 }
924 }
925 return aValue;
926 }
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943 public static <T> T [] notNullNoNullValue (final T [] aValue, final String sName)
944 {
945 return notNullNoNullValue (aValue, () -> sName);
946 }
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963 public static <T> T [] notNullNoNullValue (final T [] aValue, @Nonnull final Supplier <? extends String> aName)
964 {
965 notNull (aValue, aName);
966 noNullValue (aValue, aName);
967 return aValue;
968 }
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985 public static <T extends Iterable <?>> T notNullNoNullValue (final T aValue, final String sName)
986 {
987 return notNullNoNullValue (aValue, () -> sName);
988 }
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005 public static <T extends Iterable <?>> T notNullNoNullValue (final T aValue,
1006 @Nonnull final Supplier <? extends String> aName)
1007 {
1008 notNull (aValue, aName);
1009 noNullValue (aValue, aName);
1010 return aValue;
1011 }
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028 public static <T extends Map <?, ?>> T notNullNoNullValue (final T aValue, final String sName)
1029 {
1030 return notNullNoNullValue (aValue, () -> sName);
1031 }
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048 public static <T extends Map <?, ?>> T notNullNoNullValue (final T aValue,
1049 @Nonnull final Supplier <? extends String> aName)
1050 {
1051 notNull (aValue, aName);
1052 noNullValue (aValue, aName);
1053 return aValue;
1054 }
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071 public static <T> T [] notEmptyNoNullValue (final T [] aValue, final String sName)
1072 {
1073 return notEmptyNoNullValue (aValue, () -> sName);
1074 }
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091 public static <T> T [] notEmptyNoNullValue (final T [] aValue, @Nonnull final Supplier <? extends String> aName)
1092 {
1093 notEmpty (aValue, aName);
1094 noNullValue (aValue, aName);
1095 return aValue;
1096 }
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113 public static <T extends Iterable <?>> T notEmptyNoNullValue (final T aValue, final String sName)
1114 {
1115 return notEmptyNoNullValue (aValue, () -> sName);
1116 }
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133 public static <T extends Iterable <?>> T notEmptyNoNullValue (final T aValue,
1134 @Nonnull final Supplier <? extends String> aName)
1135 {
1136 notEmpty (aValue, aName);
1137 noNullValue (aValue, aName);
1138 return aValue;
1139 }
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156 public static <T extends Map <?, ?>> T notEmptyNoNullValue (final T aValue, final String sName)
1157 {
1158 return notEmptyNoNullValue (aValue, () -> sName);
1159 }
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176 public static <T extends Map <?, ?>> T notEmptyNoNullValue (final T aValue,
1177 @Nonnull final Supplier <? extends String> aName)
1178 {
1179 notEmpty (aValue, aName);
1180 noNullValue (aValue, aName);
1181 return aValue;
1182 }
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199 public static <T> T notNullNotEquals (final T aValue, final String sName, @Nonnull final T aUnexpectedValue)
1200 {
1201 return notNullNotEquals (aValue, () -> sName, aUnexpectedValue);
1202 }
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219 public static <T> T notNullNotEquals (final T aValue,
1220 @Nonnull final Supplier <? extends String> aName,
1221 @Nonnull final T aUnexpectedValue)
1222 {
1223 notNull (aValue, aName);
1224 notNull (aUnexpectedValue, "UnexpectedValue");
1225 if (isEnabled ())
1226 if (aValue.equals (aUnexpectedValue))
1227 throw new IllegalArgumentException ("The value of '" +
1228 aName.get () +
1229 "' may not be equal to " +
1230 aUnexpectedValue +
1231 "!");
1232 return aValue;
1233 }
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251 public static <T> T notNullAndEquals (final T aValue, final String sName, @Nonnull final T aExpectedValue)
1252 {
1253 return notNullAndEquals (aValue, () -> sName, aExpectedValue);
1254 }
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272 public static <T> T notNullAndEquals (final T aValue,
1273 @Nonnull final Supplier <? extends String> aName,
1274 @Nonnull final T aExpectedValue)
1275 {
1276 notNull (aValue, aName);
1277 if (isEnabled ())
1278 if (!aValue.equals (aExpectedValue))
1279 throw new IllegalArgumentException ("The value of '" +
1280 aName.get () +
1281 "' does not match the expected value. Passed value: " +
1282 aValue +
1283 " -- Expected value: " +
1284 aExpectedValue);
1285 return aValue;
1286 }
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305 public static <T> T isSame (final T aValue, final String sName, @Nullable final T aExpectedValue)
1306 {
1307 return isSame (aValue, () -> sName, aExpectedValue);
1308 }
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327 public static <T> T isSame (final T aValue,
1328 @Nonnull final Supplier <? extends String> aName,
1329 @Nullable final T aExpectedValue)
1330 {
1331 if (isEnabled ())
1332 if (aValue != aExpectedValue)
1333 throw new IllegalArgumentException ("The value of '" +
1334 aName.get () +
1335 "' does not match the expected value. Passed value: " +
1336 aValue +
1337 " -- Expected value: " +
1338 aExpectedValue);
1339 return aValue;
1340 }
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359 public static <T> T isEqual (final T aValue, @Nullable final T aExpectedValue, final String sName)
1360 {
1361 return isSame (aValue, () -> sName, aExpectedValue);
1362 }
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381 public static <T> T isEqual (final T aValue,
1382 @Nullable final T aExpectedValue,
1383 @Nonnull final Supplier <? extends String> aName)
1384 {
1385 if (isEnabled ())
1386 if (aValue != aExpectedValue)
1387 throw new IllegalArgumentException ("The value of '" +
1388 aName.get () +
1389 "' does not match the expected value. Passed value: " +
1390 aValue +
1391 " -- Expected value: " +
1392 aExpectedValue);
1393 return aValue;
1394 }
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409 public static void isEqual (final int nValue, final int nExpectedValue, final String sName)
1410 {
1411 isEqual (nValue, nExpectedValue, () -> sName);
1412 }
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427 public static void isEqual (final int nValue,
1428 final int nExpectedValue,
1429 @Nonnull final Supplier <? extends String> aName)
1430 {
1431 if (isEnabled ())
1432 if (nValue != nExpectedValue)
1433 throw new IllegalArgumentException ("The value of '" +
1434 aName.get () +
1435 "' does not match the expected value. Passed value: " +
1436 nValue +
1437 " -- Expected value: " +
1438 nExpectedValue);
1439 }
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454 public static void isEqual (final long nValue, final long nExpectedValue, final String sName)
1455 {
1456 isEqual (nValue, nExpectedValue, () -> sName);
1457 }
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472 public static void isEqual (final long nValue,
1473 final long nExpectedValue,
1474 @Nonnull final Supplier <? extends String> aName)
1475 {
1476 if (isEnabled ())
1477 if (nValue != nExpectedValue)
1478 throw new IllegalArgumentException ("The value of '" +
1479 aName.get () +
1480 "' does not match the expected value. Passed value: " +
1481 nValue +
1482 " -- Expected value: " +
1483 nExpectedValue);
1484 }
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499 public static void isEqual (final double dValue, final double dExpectedValue, final String sName)
1500 {
1501 isEqual (dValue, dExpectedValue, () -> sName);
1502 }
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517 public static void isEqual (final double dValue,
1518 final double dExpectedValue,
1519 @Nonnull final Supplier <? extends String> aName)
1520 {
1521 if (isEnabled ())
1522 if (Double.compare (dValue, dExpectedValue) != 0)
1523 throw new IllegalArgumentException ("The value of '" +
1524 aName.get () +
1525 "' does not match the expected value. Passed value: " +
1526 dValue +
1527 " -- Expected value: " +
1528 dExpectedValue);
1529 }
1530
1531 public static int isGE0 (final int nValue, final String sName)
1532 {
1533 return isGE0 (nValue, () -> sName);
1534 }
1535
1536 public static int isGE0 (final int nValue, @Nonnull final Supplier <? extends String> aName)
1537 {
1538 if (isEnabled ())
1539 if (nValue < 0)
1540 throw new IllegalArgumentException ("The value of '" +
1541 aName.get () +
1542 "' must be >= 0! The current value is: " +
1543 nValue);
1544 return nValue;
1545 }
1546
1547 public static long isGE0 (final long nValue, final String sName)
1548 {
1549 return isGE0 (nValue, () -> sName);
1550 }
1551
1552 public static long isGE0 (final long nValue, @Nonnull final Supplier <? extends String> aName)
1553 {
1554 if (isEnabled ())
1555 if (nValue < 0)
1556 throw new IllegalArgumentException ("The value of '" +
1557 aName.get () +
1558 "' must be >= 0! The current value is: " +
1559 nValue);
1560 return nValue;
1561 }
1562
1563 public static short isGE0 (final short nValue, final String sName)
1564 {
1565 return isGE0 (nValue, () -> sName);
1566 }
1567
1568 public static short isGE0 (final short nValue, @Nonnull final Supplier <? extends String> aName)
1569 {
1570 if (isEnabled ())
1571 if (nValue < 0)
1572 throw new IllegalArgumentException ("The value of '" +
1573 aName.get () +
1574 "' must be >= 0! The current value is: " +
1575 nValue);
1576 return nValue;
1577 }
1578
1579 public static double isGE0 (final double dValue, final String sName)
1580 {
1581 return isGE0 (dValue, () -> sName);
1582 }
1583
1584 public static double isGE0 (final double dValue, @Nonnull final Supplier <? extends String> aName)
1585 {
1586 if (isEnabled ())
1587 if (dValue < 0)
1588 throw new IllegalArgumentException ("The value of '" +
1589 aName.get () +
1590 "' must be >= 0! The current value is: " +
1591 dValue);
1592 return dValue;
1593 }
1594
1595 public static float isGE0 (final float fValue, final String sName)
1596 {
1597 return isGE0 (fValue, () -> sName);
1598 }
1599
1600 public static float isGE0 (final float fValue, @Nonnull final Supplier <? extends String> aName)
1601 {
1602 if (isEnabled ())
1603 if (fValue < 0)
1604 throw new IllegalArgumentException ("The value of '" +
1605 aName.get () +
1606 "' must be >= 0! The current value is: " +
1607 fValue);
1608 return fValue;
1609 }
1610
1611 public static BigDecimal isGE0 (final BigDecimal aValue, final String sName)
1612 {
1613 return isGE0 (aValue, () -> sName);
1614 }
1615
1616 public static BigDecimal isGE0 (final BigDecimal aValue, @Nonnull final Supplier <? extends String> aName)
1617 {
1618 notNull (aValue, aName);
1619 if (isEnabled ())
1620 if (aValue.compareTo (BigDecimal.ZERO) < 0)
1621 throw new IllegalArgumentException ("The value of '" +
1622 aName.get () +
1623 "' must be >= 0! The current value is: " +
1624 aValue);
1625 return aValue;
1626 }
1627
1628 public static BigInteger isGE0 (final BigInteger aValue, final String sName)
1629 {
1630 return isGE0 (aValue, () -> sName);
1631 }
1632
1633 public static BigInteger isGE0 (final BigInteger aValue, @Nonnull final Supplier <? extends String> aName)
1634 {
1635 notNull (aValue, aName);
1636 if (isEnabled ())
1637 if (aValue.compareTo (BigInteger.ZERO) < 0)
1638 throw new IllegalArgumentException ("The value of '" +
1639 aName.get () +
1640 "' must be >= 0! The current value is: " +
1641 aValue);
1642 return aValue;
1643 }
1644
1645 public static int isGT0 (final int nValue, final String sName)
1646 {
1647 return isGT0 (nValue, () -> sName);
1648 }
1649
1650 public static int isGT0 (final int nValue, @Nonnull final Supplier <? extends String> aName)
1651 {
1652 if (isEnabled ())
1653 if (nValue <= 0)
1654 throw new IllegalArgumentException ("The value of '" +
1655 aName.get () +
1656 "' must be > 0! The current value is: " +
1657 nValue);
1658 return nValue;
1659 }
1660
1661 public static long isGT0 (final long nValue, final String sName)
1662 {
1663 return isGT0 (nValue, () -> sName);
1664 }
1665
1666 public static long isGT0 (final long nValue, @Nonnull final Supplier <? extends String> aName)
1667 {
1668 if (isEnabled ())
1669 if (nValue <= 0)
1670 throw new IllegalArgumentException ("The value of '" +
1671 aName.get () +
1672 "' must be > 0! The current value is: " +
1673 nValue);
1674 return nValue;
1675 }
1676
1677 public static short isGT0 (final short nValue, final String sName)
1678 {
1679 return isGT0 (nValue, () -> sName);
1680 }
1681
1682 public static short isGT0 (final short nValue, @Nonnull final Supplier <? extends String> aName)
1683 {
1684 if (isEnabled ())
1685 if (nValue <= 0)
1686 throw new IllegalArgumentException ("The value of '" +
1687 aName.get () +
1688 "' must be > 0! The current value is: " +
1689 nValue);
1690 return nValue;
1691 }
1692
1693 public static double isGT0 (final double dValue, final String sName)
1694 {
1695 return isGT0 (dValue, () -> sName);
1696 }
1697
1698 public static double isGT0 (final double dValue, @Nonnull final Supplier <? extends String> aName)
1699 {
1700 if (isEnabled ())
1701 if (dValue <= 0)
1702 throw new IllegalArgumentException ("The value of '" +
1703 aName.get () +
1704 "' must be > 0! The current value is: " +
1705 dValue);
1706 return dValue;
1707 }
1708
1709 public static float isGT0 (final float fValue, final String sName)
1710 {
1711 return isGT0 (fValue, () -> sName);
1712 }
1713
1714 public static float isGT0 (final float fValue, @Nonnull final Supplier <? extends String> aName)
1715 {
1716 if (isEnabled ())
1717 if (fValue <= 0)
1718 throw new IllegalArgumentException ("The value of '" +
1719 aName.get () +
1720 "' must be > 0! The current value is: " +
1721 fValue);
1722 return fValue;
1723 }
1724
1725 public static BigDecimal isGT0 (final BigDecimal aValue, final String sName)
1726 {
1727 return isGT0 (aValue, () -> sName);
1728 }
1729
1730 public static BigDecimal isGT0 (final BigDecimal aValue, @Nonnull final Supplier <? extends String> aName)
1731 {
1732 notNull (aValue, aName);
1733 if (isEnabled ())
1734 if (aValue.compareTo (BigDecimal.ZERO) <= 0)
1735 throw new IllegalArgumentException ("The value of '" +
1736 aName.get () +
1737 "' must be > 0! The current value is: " +
1738 aValue);
1739 return aValue;
1740 }
1741
1742 public static BigInteger isGT0 (final BigInteger aValue, final String sName)
1743 {
1744 return isGT0 (aValue, () -> sName);
1745 }
1746
1747 public static BigInteger isGT0 (final BigInteger aValue, @Nonnull final Supplier <? extends String> aName)
1748 {
1749 notNull (aValue, aName);
1750 if (isEnabled ())
1751 if (aValue.compareTo (BigInteger.ZERO) <= 0)
1752 throw new IllegalArgumentException ("The value of '" +
1753 aName.get () +
1754 "' must be > 0! The current value is: " +
1755 aValue);
1756 return aValue;
1757 }
1758
1759 public static int isLE0 (final int nValue, final String sName)
1760 {
1761 return isLE0 (nValue, () -> sName);
1762 }
1763
1764 public static int isLE0 (final int nValue, @Nonnull final Supplier <? extends String> aName)
1765 {
1766 if (isEnabled ())
1767 if (nValue > 0)
1768 throw new IllegalArgumentException ("The value of '" +
1769 aName.get () +
1770 "' must be <= 0! The current value is: " +
1771 nValue);
1772 return nValue;
1773 }
1774
1775 public static long isLE0 (final long nValue, final String sName)
1776 {
1777 return isLE0 (nValue, () -> sName);
1778 }
1779
1780 public static long isLE0 (final long nValue, @Nonnull final Supplier <? extends String> aName)
1781 {
1782 if (isEnabled ())
1783 if (nValue > 0)
1784 throw new IllegalArgumentException ("The value of '" +
1785 aName.get () +
1786 "' must be <= 0! The current value is: " +
1787 nValue);
1788 return nValue;
1789 }
1790
1791 public static short isLE0 (final short nValue, final String sName)
1792 {
1793 return isLE0 (nValue, () -> sName);
1794 }
1795
1796 public static short isLE0 (final short nValue, @Nonnull final Supplier <? extends String> aName)
1797 {
1798 if (isEnabled ())
1799 if (nValue > 0)
1800 throw new IllegalArgumentException ("The value of '" +
1801 aName.get () +
1802 "' must be <= 0! The current value is: " +
1803 nValue);
1804 return nValue;
1805 }
1806
1807 public static double isLE0 (final double dValue, final String sName)
1808 {
1809 return isLE0 (dValue, () -> sName);
1810 }
1811
1812 public static double isLE0 (final double dValue, @Nonnull final Supplier <? extends String> aName)
1813 {
1814 if (isEnabled ())
1815 if (dValue > 0)
1816 throw new IllegalArgumentException ("The value of '" +
1817 aName.get () +
1818 "' must be <= 0! The current value is: " +
1819 dValue);
1820 return dValue;
1821 }
1822
1823 public static float isLE0 (final float fValue, final String sName)
1824 {
1825 return isLE0 (fValue, () -> sName);
1826 }
1827
1828 public static float isLE0 (final float fValue, @Nonnull final Supplier <? extends String> aName)
1829 {
1830 if (isEnabled ())
1831 if (fValue > 0)
1832 throw new IllegalArgumentException ("The value of '" +
1833 aName.get () +
1834 "' must be <= 0! The current value is: " +
1835 fValue);
1836 return fValue;
1837 }
1838
1839 public static BigDecimal isLE0 (final BigDecimal aValue, final String sName)
1840 {
1841 return isLE0 (aValue, () -> sName);
1842 }
1843
1844 public static BigDecimal isLE0 (final BigDecimal aValue, @Nonnull final Supplier <? extends String> aName)
1845 {
1846 notNull (aValue, aName);
1847 if (isEnabled ())
1848 if (aValue.compareTo (BigDecimal.ZERO) > 0)
1849 throw new IllegalArgumentException ("The value of '" +
1850 aName.get () +
1851 "' must be <= 0! The current value is: " +
1852 aValue);
1853 return aValue;
1854 }
1855
1856 public static BigInteger isLE0 (final BigInteger aValue, final String sName)
1857 {
1858 return isLE0 (aValue, () -> sName);
1859 }
1860
1861 public static BigInteger isLE0 (final BigInteger aValue, @Nonnull final Supplier <? extends String> aName)
1862 {
1863 notNull (aValue, aName);
1864 if (isEnabled ())
1865 if (aValue.compareTo (BigInteger.ZERO) > 0)
1866 throw new IllegalArgumentException ("The value of '" +
1867 aName.get () +
1868 "' must be <= 0! The current value is: " +
1869 aValue);
1870 return aValue;
1871 }
1872
1873 public static int isLT0 (final int nValue, final String sName)
1874 {
1875 return isLT0 (nValue, () -> sName);
1876 }
1877
1878 public static int isLT0 (final int nValue, @Nonnull final Supplier <? extends String> aName)
1879 {
1880 if (isEnabled ())
1881 if (nValue >= 0)
1882 throw new IllegalArgumentException ("The value of '" +
1883 aName.get () +
1884 "' must be < 0! The current value is: " +
1885 nValue);
1886 return nValue;
1887 }
1888
1889 public static long isLT0 (final long nValue, final String sName)
1890 {
1891 return isLT0 (nValue, () -> sName);
1892 }
1893
1894 public static long isLT0 (final long nValue, @Nonnull final Supplier <? extends String> aName)
1895 {
1896 if (isEnabled ())
1897 if (nValue >= 0)
1898 throw new IllegalArgumentException ("The value of '" +
1899 aName.get () +
1900 "' must be < 0! The current value is: " +
1901 nValue);
1902 return nValue;
1903 }
1904
1905 public static short isLT0 (final short nValue, final String sName)
1906 {
1907 return isLT0 (nValue, () -> sName);
1908 }
1909
1910 public static short isLT0 (final short nValue, @Nonnull final Supplier <? extends String> aName)
1911 {
1912 if (isEnabled ())
1913 if (nValue >= 0)
1914 throw new IllegalArgumentException ("The value of '" +
1915 aName.get () +
1916 "' must be < 0! The current value is: " +
1917 nValue);
1918 return nValue;
1919 }
1920
1921 public static double isLT0 (final double dValue, final String sName)
1922 {
1923 return isLT0 (dValue, () -> sName);
1924 }
1925
1926 public static double isLT0 (final double dValue, @Nonnull final Supplier <? extends String> aName)
1927 {
1928 if (isEnabled ())
1929 if (dValue >= 0)
1930 throw new IllegalArgumentException ("The value of '" +
1931 aName.get () +
1932 "' must be < 0! The current value is: " +
1933 dValue);
1934 return dValue;
1935 }
1936
1937 public static float isLT0 (final float fValue, final String sName)
1938 {
1939 return isLT0 (fValue, () -> sName);
1940 }
1941
1942 public static float isLT0 (final float fValue, @Nonnull final Supplier <? extends String> aName)
1943 {
1944 if (isEnabled ())
1945 if (fValue >= 0)
1946 throw new IllegalArgumentException ("The value of '" +
1947 aName.get () +
1948 "' must be < 0! The current value is: " +
1949 fValue);
1950 return fValue;
1951 }
1952
1953 public static BigDecimal isLT0 (final BigDecimal aValue, final String sName)
1954 {
1955 return isLT0 (aValue, () -> sName);
1956 }
1957
1958 public static BigDecimal isLT0 (final BigDecimal aValue, @Nonnull final Supplier <? extends String> aName)
1959 {
1960 notNull (aValue, aName);
1961 if (isEnabled ())
1962 if (aValue.compareTo (BigDecimal.ZERO) >= 0)
1963 throw new IllegalArgumentException ("The value of '" +
1964 aName.get () +
1965 "' must be < 0! The current value is: " +
1966 aValue);
1967 return aValue;
1968 }
1969
1970 public static BigInteger isLT0 (final BigInteger aValue, final String sName)
1971 {
1972 return isLT0 (aValue, () -> sName);
1973 }
1974
1975 public static BigInteger isLT0 (final BigInteger aValue, @Nonnull final Supplier <? extends String> aName)
1976 {
1977 notNull (aValue, aName);
1978 if (isEnabled ())
1979 if (aValue.compareTo (BigInteger.ZERO) >= 0)
1980 throw new IllegalArgumentException ("The value of '" +
1981 aName.get () +
1982 "' must be < 0! The current value is: " +
1983 aValue);
1984 return aValue;
1985 }
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001 public static int isBetweenInclusive (final int nValue,
2002 final String sName,
2003 final int nLowerBoundInclusive,
2004 final int nUpperBoundInclusive)
2005 {
2006 return isBetweenInclusive (nValue, () -> sName, nLowerBoundInclusive, nUpperBoundInclusive);
2007 }
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023 public static int isBetweenInclusive (final int nValue,
2024 @Nonnull final Supplier <? extends String> aName,
2025 final int nLowerBoundInclusive,
2026 final int nUpperBoundInclusive)
2027 {
2028 if (isEnabled ())
2029 if (nValue < nLowerBoundInclusive || nValue > nUpperBoundInclusive)
2030 throw new IllegalArgumentException ("The value of '" +
2031 aName.get () +
2032 "' must be >= " +
2033 nLowerBoundInclusive +
2034 " and <= " +
2035 nUpperBoundInclusive +
2036 "! The current value is: " +
2037 nValue);
2038 return nValue;
2039 }
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055 public static long isBetweenInclusive (final long nValue,
2056 final String sName,
2057 final long nLowerBoundInclusive,
2058 final long nUpperBoundInclusive)
2059 {
2060 return isBetweenInclusive (nValue, () -> sName, nLowerBoundInclusive, nUpperBoundInclusive);
2061 }
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077 public static long isBetweenInclusive (final long nValue,
2078 @Nonnull final Supplier <? extends String> aName,
2079 final long nLowerBoundInclusive,
2080 final long nUpperBoundInclusive)
2081 {
2082 if (isEnabled ())
2083 if (nValue < nLowerBoundInclusive || nValue > nUpperBoundInclusive)
2084 throw new IllegalArgumentException ("The value of '" +
2085 aName.get () +
2086 "' must be >= " +
2087 nLowerBoundInclusive +
2088 " and <= " +
2089 nUpperBoundInclusive +
2090 "! The current value is: " +
2091 nValue);
2092 return nValue;
2093 }
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109 public static short isBetweenInclusive (final short nValue,
2110 final String sName,
2111 final short nLowerBoundInclusive,
2112 final short nUpperBoundInclusive)
2113 {
2114 return isBetweenInclusive (nValue, () -> sName, nLowerBoundInclusive, nUpperBoundInclusive);
2115 }
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131 public static short isBetweenInclusive (final short nValue,
2132 @Nonnull final Supplier <? extends String> aName,
2133 final short nLowerBoundInclusive,
2134 final short nUpperBoundInclusive)
2135 {
2136 if (isEnabled ())
2137 if (nValue < nLowerBoundInclusive || nValue > nUpperBoundInclusive)
2138 throw new IllegalArgumentException ("The value of '" +
2139 aName.get () +
2140 "' must be >= " +
2141 nLowerBoundInclusive +
2142 " and <= " +
2143 nUpperBoundInclusive +
2144 "! The current value is: " +
2145 nValue);
2146 return nValue;
2147 }
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163 public static double isBetweenInclusive (final double dValue,
2164 final String sName,
2165 final double dLowerBoundInclusive,
2166 final double dUpperBoundInclusive)
2167 {
2168 return isBetweenInclusive (dValue, () -> sName, dLowerBoundInclusive, dUpperBoundInclusive);
2169 }
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185 public static double isBetweenInclusive (final double dValue,
2186 @Nonnull final Supplier <? extends String> aName,
2187 final double dLowerBoundInclusive,
2188 final double dUpperBoundInclusive)
2189 {
2190 if (isEnabled ())
2191 if (dValue < dLowerBoundInclusive || dValue > dUpperBoundInclusive)
2192 throw new IllegalArgumentException ("The value of '" +
2193 aName.get () +
2194 "' must be >= " +
2195 dLowerBoundInclusive +
2196 " and <= " +
2197 dUpperBoundInclusive +
2198 "! The current value is: " +
2199 dValue);
2200 return dValue;
2201 }
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217 public static float isBetweenInclusive (final float fValue,
2218 final String sName,
2219 final float fLowerBoundInclusive,
2220 final float fUpperBoundInclusive)
2221 {
2222 return isBetweenInclusive (fValue, () -> sName, fLowerBoundInclusive, fUpperBoundInclusive);
2223 }
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239 public static float isBetweenInclusive (final float fValue,
2240 @Nonnull final Supplier <? extends String> aName,
2241 final float fLowerBoundInclusive,
2242 final float fUpperBoundInclusive)
2243 {
2244 if (isEnabled ())
2245 if (fValue < fLowerBoundInclusive || fValue > fUpperBoundInclusive)
2246 throw new IllegalArgumentException ("The value of '" +
2247 aName.get () +
2248 "' must be >= " +
2249 fLowerBoundInclusive +
2250 " and <= " +
2251 fUpperBoundInclusive +
2252 "! The current value is: " +
2253 fValue);
2254 return fValue;
2255 }
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271 public static BigDecimal isBetweenInclusive (final BigDecimal aValue,
2272 final String sName,
2273 @Nonnull final BigDecimal aLowerBoundInclusive,
2274 @Nonnull final BigDecimal aUpperBoundInclusive)
2275 {
2276 return isBetweenInclusive (aValue, () -> sName, aLowerBoundInclusive, aUpperBoundInclusive);
2277 }
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293 public static BigDecimal isBetweenInclusive (final BigDecimal aValue,
2294 @Nonnull final Supplier <? extends String> aName,
2295 @Nonnull final BigDecimal aLowerBoundInclusive,
2296 @Nonnull final BigDecimal aUpperBoundInclusive)
2297 {
2298 notNull (aValue, aName);
2299 notNull (aLowerBoundInclusive, "LowerBoundInclusive");
2300 notNull (aUpperBoundInclusive, "UpperBoundInclusive");
2301 if (isEnabled ())
2302 if (aValue.compareTo (aLowerBoundInclusive) < 0 || aValue.compareTo (aUpperBoundInclusive) > 0)
2303 throw new IllegalArgumentException ("The value of '" +
2304 aName.get () +
2305 "' must be >= " +
2306 aLowerBoundInclusive +
2307 " and <= " +
2308 aUpperBoundInclusive +
2309 "! The current value is: " +
2310 aValue);
2311 return aValue;
2312 }
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328 public static BigInteger isBetweenInclusive (final BigInteger aValue,
2329 final String sName,
2330 @Nonnull final BigInteger aLowerBoundInclusive,
2331 @Nonnull final BigInteger aUpperBoundInclusive)
2332 {
2333 return isBetweenInclusive (aValue, () -> sName, aLowerBoundInclusive, aUpperBoundInclusive);
2334 }
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350 public static BigInteger isBetweenInclusive (final BigInteger aValue,
2351 @Nonnull final Supplier <? extends String> aName,
2352 @Nonnull final BigInteger aLowerBoundInclusive,
2353 @Nonnull final BigInteger aUpperBoundInclusive)
2354 {
2355 notNull (aValue, aName);
2356 notNull (aLowerBoundInclusive, "LowerBoundInclusive");
2357 notNull (aUpperBoundInclusive, "UpperBoundInclusive");
2358 if (isEnabled ())
2359 if (aValue.compareTo (aLowerBoundInclusive) < 0 || aValue.compareTo (aUpperBoundInclusive) > 0)
2360 throw new IllegalArgumentException ("The value of '" +
2361 aName.get () +
2362 "' must be >= " +
2363 aLowerBoundInclusive +
2364 " and <= " +
2365 aUpperBoundInclusive +
2366 "! The current value is: " +
2367 aValue);
2368 return aValue;
2369 }
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385 public static int isBetweenExclusive (final int nValue,
2386 final String sName,
2387 final int nLowerBoundExclusive,
2388 final int nUpperBoundExclusive)
2389 {
2390 return isBetweenExclusive (nValue, () -> sName, nLowerBoundExclusive, nUpperBoundExclusive);
2391 }
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407 public static int isBetweenExclusive (final int nValue,
2408 @Nonnull final Supplier <? extends String> aName,
2409 final int nLowerBoundExclusive,
2410 final int nUpperBoundExclusive)
2411 {
2412 if (isEnabled ())
2413 if (nValue <= nLowerBoundExclusive || nValue >= nUpperBoundExclusive)
2414 throw new IllegalArgumentException ("The value of '" +
2415 aName.get () +
2416 "' must be > " +
2417 nLowerBoundExclusive +
2418 " and < " +
2419 nUpperBoundExclusive +
2420 "! The current value is: " +
2421 nValue);
2422 return nValue;
2423 }
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439 public static long isBetweenExclusive (final long nValue,
2440 final String sName,
2441 final long nLowerBoundExclusive,
2442 final long nUpperBoundExclusive)
2443 {
2444 return isBetweenExclusive (nValue, () -> sName, nLowerBoundExclusive, nUpperBoundExclusive);
2445 }
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461 public static long isBetweenExclusive (final long nValue,
2462 @Nonnull final Supplier <? extends String> aName,
2463 final long nLowerBoundExclusive,
2464 final long nUpperBoundExclusive)
2465 {
2466 if (isEnabled ())
2467 if (nValue <= nLowerBoundExclusive || nValue >= nUpperBoundExclusive)
2468 throw new IllegalArgumentException ("The value of '" +
2469 aName.get () +
2470 "' must be > " +
2471 nLowerBoundExclusive +
2472 " and < " +
2473 nUpperBoundExclusive +
2474 "! The current value is: " +
2475 nValue);
2476 return nValue;
2477 }
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493 public static short isBetweenExclusive (final short nValue,
2494 final String sName,
2495 final short nLowerBoundExclusive,
2496 final short nUpperBoundExclusive)
2497 {
2498 return isBetweenExclusive (nValue, () -> sName, nLowerBoundExclusive, nUpperBoundExclusive);
2499 }
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515 public static short isBetweenExclusive (final short nValue,
2516 @Nonnull final Supplier <? extends String> aName,
2517 final short nLowerBoundExclusive,
2518 final short nUpperBoundExclusive)
2519 {
2520 if (isEnabled ())
2521 if (nValue <= nLowerBoundExclusive || nValue >= nUpperBoundExclusive)
2522 throw new IllegalArgumentException ("The value of '" +
2523 aName.get () +
2524 "' must be > " +
2525 nLowerBoundExclusive +
2526 " and < " +
2527 nUpperBoundExclusive +
2528 "! The current value is: " +
2529 nValue);
2530 return nValue;
2531 }
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547 public static double isBetweenExclusive (final double dValue,
2548 final String sName,
2549 final double dLowerBoundExclusive,
2550 final double dUpperBoundExclusive)
2551 {
2552 return isBetweenExclusive (dValue, () -> sName, dLowerBoundExclusive, dUpperBoundExclusive);
2553 }
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569 public static double isBetweenExclusive (final double dValue,
2570 @Nonnull final Supplier <? extends String> aName,
2571 final double dLowerBoundExclusive,
2572 final double dUpperBoundExclusive)
2573 {
2574 if (isEnabled ())
2575 if (dValue <= dLowerBoundExclusive || dValue >= dUpperBoundExclusive)
2576 throw new IllegalArgumentException ("The value of '" +
2577 aName.get () +
2578 "' must be > " +
2579 dLowerBoundExclusive +
2580 " and < " +
2581 dUpperBoundExclusive +
2582 "! The current value is: " +
2583 dValue);
2584 return dValue;
2585 }
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601 public static float isBetweenExclusive (final float fValue,
2602 final String sName,
2603 final float fLowerBoundExclusive,
2604 final float fUpperBoundExclusive)
2605 {
2606 return isBetweenExclusive (fValue, () -> sName, fLowerBoundExclusive, fUpperBoundExclusive);
2607 }
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623 public static float isBetweenExclusive (final float fValue,
2624 @Nonnull final Supplier <? extends String> aName,
2625 final float fLowerBoundExclusive,
2626 final float fUpperBoundExclusive)
2627 {
2628 if (isEnabled ())
2629 if (fValue <= fLowerBoundExclusive || fValue >= fUpperBoundExclusive)
2630 throw new IllegalArgumentException ("The value of '" +
2631 aName.get () +
2632 "' must be > " +
2633 fLowerBoundExclusive +
2634 " and < " +
2635 fUpperBoundExclusive +
2636 "! The current value is: " +
2637 fValue);
2638 return fValue;
2639 }
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655 public static BigDecimal isBetweenExclusive (final BigDecimal aValue,
2656 final String sName,
2657 @Nonnull final BigDecimal aLowerBoundExclusive,
2658 @Nonnull final BigDecimal aUpperBoundExclusive)
2659 {
2660 return isBetweenExclusive (aValue, () -> sName, aLowerBoundExclusive, aUpperBoundExclusive);
2661 }
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677 public static BigDecimal isBetweenExclusive (final BigDecimal aValue,
2678 @Nonnull final Supplier <? extends String> aName,
2679 @Nonnull final BigDecimal aLowerBoundExclusive,
2680 @Nonnull final BigDecimal aUpperBoundExclusive)
2681 {
2682 notNull (aValue, aName);
2683 notNull (aLowerBoundExclusive, "LowerBoundInclusive");
2684 notNull (aUpperBoundExclusive, "UpperBoundInclusive");
2685 if (isEnabled ())
2686 if (aValue.compareTo (aLowerBoundExclusive) <= 0 || aValue.compareTo (aUpperBoundExclusive) >= 0)
2687 throw new IllegalArgumentException ("The value of '" +
2688 aName.get () +
2689 "' must be > " +
2690 aLowerBoundExclusive +
2691 " and < " +
2692 aUpperBoundExclusive +
2693 "! The current value is: " +
2694 aValue);
2695 return aValue;
2696 }
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712 public static BigInteger isBetweenExclusive (final BigInteger aValue,
2713 final String sName,
2714 @Nonnull final BigInteger aLowerBoundExclusive,
2715 @Nonnull final BigInteger aUpperBoundExclusive)
2716 {
2717 return isBetweenExclusive (aValue, () -> sName, aLowerBoundExclusive, aUpperBoundExclusive);
2718 }
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734 public static BigInteger isBetweenExclusive (final BigInteger aValue,
2735 @Nonnull final Supplier <? extends String> aName,
2736 @Nonnull final BigInteger aLowerBoundExclusive,
2737 @Nonnull final BigInteger aUpperBoundExclusive)
2738 {
2739 notNull (aValue, aName);
2740 notNull (aLowerBoundExclusive, "LowerBoundInclusive");
2741 notNull (aUpperBoundExclusive, "UpperBoundInclusive");
2742 if (isEnabled ())
2743 if (aValue.compareTo (aLowerBoundExclusive) <= 0 || aValue.compareTo (aUpperBoundExclusive) >= 0)
2744 throw new IllegalArgumentException ("The value of '" +
2745 aName.get () +
2746 "' must be > " +
2747 aLowerBoundExclusive +
2748 " and < " +
2749 aUpperBoundExclusive +
2750 "! The current value is: " +
2751 aValue);
2752 return aValue;
2753 }
2754
2755 private static void _isArrayOfsLen (@Nonnegative final int nArrayLen,
2756 @Nonnegative final int nOfs,
2757 @Nonnegative final int nLen)
2758 {
2759 isGE0 (nOfs, "Offset");
2760 isGE0 (nLen, "Length");
2761 if (isEnabled ())
2762 if ((nOfs + nLen) > nArrayLen)
2763 throw new IllegalArgumentException ("Offset (" +
2764 nOfs +
2765 ") + length (" +
2766 nLen +
2767 ") exceeds array length (" +
2768 nArrayLen +
2769 ")");
2770
2771 }
2772
2773 public static void isArrayOfsLen (final Object [] aArray, @Nonnegative final int nOfs, @Nonnegative final int nLen)
2774 {
2775 notNull (aArray, "Array");
2776 _isArrayOfsLen (aArray.length, nOfs, nLen);
2777 }
2778
2779 public static void isArrayOfsLen (final boolean [] aArray, @Nonnegative final int nOfs, @Nonnegative final int nLen)
2780 {
2781 notNull (aArray, "Array");
2782 _isArrayOfsLen (aArray.length, nOfs, nLen);
2783 }
2784
2785 public static void isArrayOfsLen (final byte [] aArray, @Nonnegative final int nOfs, @Nonnegative final int nLen)
2786 {
2787 notNull (aArray, "Array");
2788 _isArrayOfsLen (aArray.length, nOfs, nLen);
2789 }
2790
2791 public static void isArrayOfsLen (final char [] aArray, @Nonnegative final int nOfs, @Nonnegative final int nLen)
2792 {
2793 notNull (aArray, "Array");
2794 _isArrayOfsLen (aArray.length, nOfs, nLen);
2795 }
2796
2797 public static void isArrayOfsLen (final double [] aArray, @Nonnegative final int nOfs, @Nonnegative final int nLen)
2798 {
2799 notNull (aArray, "Array");
2800 _isArrayOfsLen (aArray.length, nOfs, nLen);
2801 }
2802
2803 public static void isArrayOfsLen (final float [] aArray, @Nonnegative final int nOfs, @Nonnegative final int nLen)
2804 {
2805 notNull (aArray, "Array");
2806 _isArrayOfsLen (aArray.length, nOfs, nLen);
2807 }
2808
2809 public static void isArrayOfsLen (final int [] aArray, @Nonnegative final int nOfs, @Nonnegative final int nLen)
2810 {
2811 notNull (aArray, "Array");
2812 _isArrayOfsLen (aArray.length, nOfs, nLen);
2813 }
2814
2815 public static void isArrayOfsLen (final long [] aArray, @Nonnegative final int nOfs, @Nonnegative final int nLen)
2816 {
2817 notNull (aArray, "Array");
2818 _isArrayOfsLen (aArray.length, nOfs, nLen);
2819 }
2820
2821 public static void isArrayOfsLen (final short [] aArray, @Nonnegative final int nOfs, @Nonnegative final int nLen)
2822 {
2823 notNull (aArray, "Array");
2824 _isArrayOfsLen (aArray.length, nOfs, nLen);
2825 }
2826 }