Class DottedResolver
java.lang.Object
com.mrivanplays.annotationconfig.core.resolver.key.DottedResolver
- All Implemented Interfaces:
KeyResolver
Represents a resolver of dotted keys.
A dotted key is a key which is of type "a.b.c". This key resolver boxes it in a Map
as
such:
Map<String, Object> values = // ...
String key = "foo.bar.baz"; // say this is your key
Object val = // ...
Map<String, Object> bazMap = new HashMap<>();
bazMap.put("baz", val);
Map<String, Object> barMap = new HashMap<>();
barMap.put("bar", bazMap);
values.put("foo", barMap);
of course by using clever tricks.
This key resolver also handles non-dotted keys (e.g. keys with no ".") with the same handling
as that KeyResolver.DEFAULT
applies.
This is a singleton class ; obtain instance using getInstance()
.
- Since:
- 2.0.1
- Author:
- MrIvanPlays
-
Field Summary
Fields inherited from interface com.mrivanplays.annotationconfig.core.resolver.key.KeyResolver
DEFAULT
-
Method Summary
Modifier and TypeMethodDescriptionvoid
AnnotationConfig calls this method whenever it needs to populate the specifiedMap
values
with the specifiedvalue
and specifiedkey
.static DottedResolver
Returns the instance of theDottedResolver
AnnotationConfig calls this method whenever it needs the value of the specifiedkey
.
-
Method Details
-
getInstance
Returns the instance of theDottedResolver
- Returns:
- instance
-
unbox
AnnotationConfig calls this method whenever it needs the value of the specifiedkey
.Keep in mind just because modification of the inputted
Map
values
won't bug you it does not mean it goes without consequences. It is strongly not recommended as it may alter the set values.- Specified by:
unbox
in interfaceKeyResolver
- Parameters:
key
- the key of the valuevalues
- the values to unbox it from- Returns:
- value or null
-
boxTo
AnnotationConfig calls this method whenever it needs to populate the specifiedMap
values
with the specifiedvalue
and specifiedkey
.- Specified by:
boxTo
in interfaceKeyResolver
- Parameters:
key
- the key of the valuevalue
- the value to boxvalues
- the place where the value shall be put
-