java.lang.Object
com.mrivanplays.annotationconfig.core.resolver.key.DottedResolver
All Implemented Interfaces:
KeyResolver

public final class DottedResolver extends Object implements 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
  • Method Details

    • getInstance

      public static DottedResolver getInstance()
      Returns the instance of the DottedResolver
      Returns:
      instance
    • unbox

      public Object unbox(String key, Map<String,Object> values)
      AnnotationConfig calls this method whenever it needs the value of the specified key.

      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 interface KeyResolver
      Parameters:
      key - the key of the value
      values - the values to unbox it from
      Returns:
      value or null
    • boxTo

      public void boxTo(String key, Object value, Map<String,Object> values)
      AnnotationConfig calls this method whenever it needs to populate the specified Map values with the specified value and specified key.
      Specified by:
      boxTo in interface KeyResolver
      Parameters:
      key - the key of the value
      value - the value to box
      values - the place where the value shall be put