17
17
import static com .coditory .quark .config .Preconditions .expectNonNull ;
18
18
19
19
interface ConfigGetters {
20
+ @ NotNull
21
+ String getPath ();
22
+
20
23
@ NotNull
21
24
<T > Optional <T > getAsOptional (@ NotNull Class <T > type , @ NotNull String path );
22
25
@@ -28,7 +31,7 @@ default <T> T get(@NotNull Class<T> type, @NotNull String path) {
28
31
expectNonNull (type , "type" );
29
32
expectNonNull (path , "path" );
30
33
return getAsOptional (type , path )
31
- .orElseThrow (() -> missingConfigValueForPath (path ));
34
+ .orElseThrow (() -> missingConfigValueForPath (getPath (), path ));
32
35
}
33
36
34
37
@ Nullable
@@ -51,7 +54,7 @@ default <T> List<T> getList(Class<T> type, String path) {
51
54
expectNonNull (type , "type" );
52
55
expectNonNull (path , "path" );
53
56
return getListAsOptional (type , path )
54
- .orElseThrow (() -> missingConfigValueForPath (path ));
57
+ .orElseThrow (() -> missingConfigValueForPath (getPath (), path ));
55
58
}
56
59
57
60
@ Nullable
@@ -83,7 +86,7 @@ default Optional<String> getStringAsOptional(@NotNull String path) {
83
86
default String getString (@ NotNull String path ) {
84
87
expectNonNull (path , "path" );
85
88
return getStringAsOptional (path )
86
- .orElseThrow (() -> missingConfigValueForPath (path ));
89
+ .orElseThrow (() -> missingConfigValueForPath (getPath (), path ));
87
90
}
88
91
89
92
@ Nullable
@@ -111,7 +114,7 @@ default Optional<Object> getObjectAsOptional(@NotNull String path) {
111
114
default Object getObject (@ NotNull String path ) {
112
115
expectNonNull (path , "path" );
113
116
return getObjectAsOptional (path )
114
- .orElseThrow (() -> missingConfigValueForPath (path ));
117
+ .orElseThrow (() -> missingConfigValueForPath (getPath (), path ));
115
118
}
116
119
117
120
@ Nullable
@@ -139,7 +142,7 @@ default Optional<Boolean> getBooleanAsOptional(@NotNull String path) {
139
142
default Boolean getBoolean (@ NotNull String path ) {
140
143
expectNonNull (path , "path" );
141
144
return getBooleanAsOptional (path )
142
- .orElseThrow (() -> missingConfigValueForPath (path ));
145
+ .orElseThrow (() -> missingConfigValueForPath (getPath (), path ));
143
146
}
144
147
145
148
@ Nullable
@@ -167,7 +170,7 @@ default Optional<Short> getShortAsOptional(@NotNull String path) {
167
170
default Short getShort (@ NotNull String path ) {
168
171
expectNonNull (path , "path" );
169
172
return getShortAsOptional (path )
170
- .orElseThrow (() -> missingConfigValueForPath (path ));
173
+ .orElseThrow (() -> missingConfigValueForPath (getPath (), path ));
171
174
}
172
175
173
176
@ Nullable
@@ -195,7 +198,7 @@ default Optional<Byte> getByteAsOptional(@NotNull String path) {
195
198
default Byte getByte (@ NotNull String path ) {
196
199
expectNonNull (path , "path" );
197
200
return getByteAsOptional (path )
198
- .orElseThrow (() -> missingConfigValueForPath (path ));
201
+ .orElseThrow (() -> missingConfigValueForPath (getPath (), path ));
199
202
}
200
203
201
204
@ Nullable
@@ -223,7 +226,7 @@ default Optional<Integer> getIntegerAsOptional(@NotNull String path) {
223
226
default Integer getInteger (@ NotNull String path ) {
224
227
expectNonNull (path , "path" );
225
228
return getIntegerAsOptional (path )
226
- .orElseThrow (() -> missingConfigValueForPath (path ));
229
+ .orElseThrow (() -> missingConfigValueForPath (getPath (), path ));
227
230
}
228
231
229
232
@ Nullable
@@ -251,7 +254,7 @@ default Optional<Long> getLongAsOptional(@NotNull String path) {
251
254
default Long getLong (@ NotNull String path ) {
252
255
expectNonNull (path , "path" );
253
256
return getLongAsOptional (path )
254
- .orElseThrow (() -> missingConfigValueForPath (path ));
257
+ .orElseThrow (() -> missingConfigValueForPath (getPath (), path ));
255
258
}
256
259
257
260
@ Nullable
@@ -279,7 +282,7 @@ default Optional<Float> getFloatAsOptional(@NotNull String path) {
279
282
default Float getFloat (@ NotNull String path ) {
280
283
expectNonNull (path , "path" );
281
284
return getFloatAsOptional (path )
282
- .orElseThrow (() -> missingConfigValueForPath (path ));
285
+ .orElseThrow (() -> missingConfigValueForPath (getPath (), path ));
283
286
}
284
287
285
288
@ Nullable
@@ -307,7 +310,7 @@ default Optional<Double> getDoubleAsOptional(@NotNull String path) {
307
310
default Double getDouble (@ NotNull String path ) {
308
311
expectNonNull (path , "path" );
309
312
return getDoubleAsOptional (path )
310
- .orElseThrow (() -> missingConfigValueForPath (path ));
313
+ .orElseThrow (() -> missingConfigValueForPath (getPath (), path ));
311
314
}
312
315
313
316
@ Nullable
@@ -335,7 +338,7 @@ default Optional<BigDecimal> getBigDecimalAsOptional(@NotNull String path) {
335
338
default BigDecimal getBigDecimal (@ NotNull String path ) {
336
339
expectNonNull (path , "path" );
337
340
return getBigDecimalAsOptional (path )
338
- .orElseThrow (() -> missingConfigValueForPath (path ));
341
+ .orElseThrow (() -> missingConfigValueForPath (getPath (), path ));
339
342
}
340
343
341
344
@ Nullable
@@ -363,7 +366,7 @@ default Optional<Instant> getInstantAsOptional(@NotNull String path) {
363
366
default Instant getInstant (@ NotNull String path ) {
364
367
expectNonNull (path , "path" );
365
368
return getInstantAsOptional (path )
366
- .orElseThrow (() -> missingConfigValueForPath (path ));
369
+ .orElseThrow (() -> missingConfigValueForPath (getPath (), path ));
367
370
}
368
371
369
372
@ Nullable
@@ -391,7 +394,7 @@ default Optional<ZonedDateTime> getZonedDateTimeAsOptional(@NotNull String path)
391
394
default ZonedDateTime getZonedDateTime (@ NotNull String path ) {
392
395
expectNonNull (path , "path" );
393
396
return getZonedDateTimeAsOptional (path )
394
- .orElseThrow (() -> missingConfigValueForPath (path ));
397
+ .orElseThrow (() -> missingConfigValueForPath (getPath (), path ));
395
398
}
396
399
397
400
@ Nullable
@@ -419,7 +422,7 @@ default Optional<Duration> getDurationAsOptional(@NotNull String path) {
419
422
default Duration getDuration (@ NotNull String path ) {
420
423
expectNonNull (path , "path" );
421
424
return getDurationAsOptional (path )
422
- .orElseThrow (() -> missingConfigValueForPath (path ));
425
+ .orElseThrow (() -> missingConfigValueForPath (getPath (), path ));
423
426
}
424
427
425
428
@ Nullable
@@ -447,7 +450,7 @@ default Optional<Locale> getLocaleAsOptional(@NotNull String path) {
447
450
default Locale getLocale (@ NotNull String path ) {
448
451
expectNonNull (path , "path" );
449
452
return getLocaleAsOptional (path )
450
- .orElseThrow (() -> missingConfigValueForPath (path ));
453
+ .orElseThrow (() -> missingConfigValueForPath (getPath (), path ));
451
454
}
452
455
453
456
@ Nullable
@@ -475,7 +478,7 @@ default Optional<Currency> getCurrencyAsOptional(@NotNull String path) {
475
478
default Currency getCurrency (@ NotNull String path ) {
476
479
expectNonNull (path , "path" );
477
480
return getCurrencyAsOptional (path )
478
- .orElseThrow (() -> missingConfigValueForPath (path ));
481
+ .orElseThrow (() -> missingConfigValueForPath (getPath (), path ));
479
482
}
480
483
481
484
@ Nullable
@@ -505,7 +508,7 @@ default Optional<List<String>> getStringListAsOptional(@NotNull String path) {
505
508
default List <String > getStringList (@ NotNull String path ) {
506
509
expectNonNull (path , "path" );
507
510
return getStringListAsOptional (path )
508
- .orElseThrow (() -> missingConfigValueForPath (path ));
511
+ .orElseThrow (() -> missingConfigValueForPath (getPath (), path ));
509
512
}
510
513
511
514
@ Nullable
@@ -539,7 +542,7 @@ default Optional<List<Object>> getObjectListAsOptional(@NotNull String path) {
539
542
default List <Object > getObjectList (@ NotNull String path ) {
540
543
expectNonNull (path , "path" );
541
544
return getObjectListAsOptional (path )
542
- .orElseThrow (() -> missingConfigValueForPath (path ));
545
+ .orElseThrow (() -> missingConfigValueForPath (getPath (), path ));
543
546
}
544
547
545
548
@ Nullable
@@ -567,7 +570,7 @@ default Optional<List<Boolean>> getBooleanListAsOptional(@NotNull String path) {
567
570
default List <Boolean > getBooleanList (@ NotNull String path ) {
568
571
expectNonNull (path , "path" );
569
572
return getBooleanListAsOptional (path )
570
- .orElseThrow (() -> missingConfigValueForPath (path ));
573
+ .orElseThrow (() -> missingConfigValueForPath (getPath (), path ));
571
574
}
572
575
573
576
@ Nullable
@@ -595,7 +598,7 @@ default Optional<List<Short>> getShortListAsOptional(@NotNull String path) {
595
598
default List <Short > getShortList (@ NotNull String path ) {
596
599
expectNonNull (path , "path" );
597
600
return getShortListAsOptional (path )
598
- .orElseThrow (() -> missingConfigValueForPath (path ));
601
+ .orElseThrow (() -> missingConfigValueForPath (getPath (), path ));
599
602
}
600
603
601
604
@ Nullable
@@ -623,7 +626,7 @@ default Optional<List<Byte>> getByteListAsOptional(@NotNull String path) {
623
626
default List <Byte > getByteList (@ NotNull String path ) {
624
627
expectNonNull (path , "path" );
625
628
return getByteListAsOptional (path )
626
- .orElseThrow (() -> missingConfigValueForPath (path ));
629
+ .orElseThrow (() -> missingConfigValueForPath (getPath (), path ));
627
630
}
628
631
629
632
@ Nullable
@@ -651,7 +654,7 @@ default Optional<List<Integer>> getIntegerListAsOptional(@NotNull String path) {
651
654
default List <Integer > getIntegerList (@ NotNull String path ) {
652
655
expectNonNull (path , "path" );
653
656
return getIntegerListAsOptional (path )
654
- .orElseThrow (() -> missingConfigValueForPath (path ));
657
+ .orElseThrow (() -> missingConfigValueForPath (getPath (), path ));
655
658
}
656
659
657
660
@ Nullable
@@ -679,7 +682,7 @@ default Optional<List<Long>> getLongListAsOptional(@NotNull String path) {
679
682
default List <Long > getLongList (@ NotNull String path ) {
680
683
expectNonNull (path , "path" );
681
684
return getLongListAsOptional (path )
682
- .orElseThrow (() -> missingConfigValueForPath (path ));
685
+ .orElseThrow (() -> missingConfigValueForPath (getPath (), path ));
683
686
}
684
687
685
688
@ Nullable
@@ -707,7 +710,7 @@ default Optional<List<Float>> getFloatListAsOptional(@NotNull String path) {
707
710
default List <Float > getFloatList (@ NotNull String path ) {
708
711
expectNonNull (path , "path" );
709
712
return getFloatListAsOptional (path )
710
- .orElseThrow (() -> missingConfigValueForPath (path ));
713
+ .orElseThrow (() -> missingConfigValueForPath (getPath (), path ));
711
714
}
712
715
713
716
@ Nullable
@@ -735,7 +738,7 @@ default Optional<List<Double>> getDoubleListAsOptional(@NotNull String path) {
735
738
default List <Double > getDoubleList (@ NotNull String path ) {
736
739
expectNonNull (path , "path" );
737
740
return getDoubleListAsOptional (path )
738
- .orElseThrow (() -> missingConfigValueForPath (path ));
741
+ .orElseThrow (() -> missingConfigValueForPath (getPath (), path ));
739
742
}
740
743
741
744
@ Nullable
@@ -763,7 +766,7 @@ default Optional<List<BigDecimal>> getBigDecimalListAsOptional(@NotNull String p
763
766
default List <BigDecimal > getBigDecimalList (@ NotNull String path ) {
764
767
expectNonNull (path , "path" );
765
768
return getBigDecimalListAsOptional (path )
766
- .orElseThrow (() -> missingConfigValueForPath (path ));
769
+ .orElseThrow (() -> missingConfigValueForPath (getPath (), path ));
767
770
}
768
771
769
772
@ Nullable
@@ -791,7 +794,7 @@ default Optional<List<Instant>> getInstantListAsOptional(@NotNull String path) {
791
794
default List <Instant > getInstantList (@ NotNull String path ) {
792
795
expectNonNull (path , "path" );
793
796
return getInstantListAsOptional (path )
794
- .orElseThrow (() -> missingConfigValueForPath (path ));
797
+ .orElseThrow (() -> missingConfigValueForPath (getPath (), path ));
795
798
}
796
799
797
800
@ Nullable
@@ -819,7 +822,7 @@ default Optional<List<ZonedDateTime>> getZonedDateTimeListAsOptional(@NotNull St
819
822
default List <ZonedDateTime > getZonedDateTimeList (@ NotNull String path ) {
820
823
expectNonNull (path , "path" );
821
824
return getZonedDateTimeListAsOptional (path )
822
- .orElseThrow (() -> missingConfigValueForPath (path ));
825
+ .orElseThrow (() -> missingConfigValueForPath (getPath (), path ));
823
826
}
824
827
825
828
@ Nullable
@@ -847,7 +850,7 @@ default Optional<List<Duration>> getDurationListAsOptional(@NotNull String path)
847
850
default List <Duration > getDurationList (@ NotNull String path ) {
848
851
expectNonNull (path , "path" );
849
852
return getDurationListAsOptional (path )
850
- .orElseThrow (() -> missingConfigValueForPath (path ));
853
+ .orElseThrow (() -> missingConfigValueForPath (getPath (), path ));
851
854
}
852
855
853
856
@ Nullable
@@ -875,7 +878,7 @@ default Optional<List<Locale>> getLocaleListAsOptional(@NotNull String path) {
875
878
default List <Locale > getLocaleList (@ NotNull String path ) {
876
879
expectNonNull (path , "path" );
877
880
return getLocaleListAsOptional (path )
878
- .orElseThrow (() -> missingConfigValueForPath (path ));
881
+ .orElseThrow (() -> missingConfigValueForPath (getPath (), path ));
879
882
}
880
883
881
884
@ Nullable
@@ -903,7 +906,7 @@ default Optional<List<Currency>> getCurrencyListAsOptional(@NotNull String path)
903
906
default List <Currency > getCurrencyList (@ NotNull String path ) {
904
907
expectNonNull (path , "path" );
905
908
return getCurrencyListAsOptional (path )
906
- .orElseThrow (() -> missingConfigValueForPath (path ));
909
+ .orElseThrow (() -> missingConfigValueForPath (getPath (), path ));
907
910
}
908
911
909
912
@ Nullable
@@ -931,7 +934,7 @@ default Optional<List<Config>> getSubConfigListAsOptional(@NotNull String path)
931
934
default List <Config > getSubConfigList (@ NotNull String path ) {
932
935
expectNonNull (path , "path" );
933
936
return getSubConfigListAsOptional (path )
934
- .orElseThrow (() -> missingConfigValueForPath (path ));
937
+ .orElseThrow (() -> missingConfigValueForPath (getPath (), path ));
935
938
}
936
939
937
940
@ NotNull
0 commit comments