Class TypeResolvingMap

java.lang.Object
java.util.AbstractMap<String,Object>
de.eldoria.eldoutilities.serialization.TypeResolvingMap
All Implemented Interfaces:
Map<String,Object>

public final class TypeResolvingMap extends AbstractMap<String,Object>
Map for type resolving.
Since:
1.0.0
  • Method Details

    • entrySet

      @NotNull public @NotNull Set<Map.Entry<String,Object>> entrySet()
      Specified by:
      entrySet in interface Map<String,Object>
      Specified by:
      entrySet in class AbstractMap<String,Object>
    • get

      public Object get(Object key)
      Get a value from map.
      Specified by:
      get in interface Map<String,Object>
      Overrides:
      get in class AbstractMap<String,Object>
      Parameters:
      key - key
      Returns:
      object or null if key is not present
    • getValue

      public <T> T getValue(String key)
      Get a value from map.
      Type Parameters:
      T - type of return value
      Parameters:
      key - key
      Returns:
      object or null if key is not present
    • listToMap

      public <T, V> void listToMap(Map<T,V> map, String key, Function<V,T> valueToKey)
    • getValueOrDefault

      public <T> T getValueOrDefault(String key, T defaultValue)
      Get a value from map.
      Type Parameters:
      T - type of return value
      Parameters:
      key - key
      defaultValue - default value if key does not exist
      Returns:
      value of key or default value
    • getValueOrDefault

      public UUID getValueOrDefault(String key, UUID defaultValue)
    • getValueOrDefault

      public <T extends Enum<T>> T getValueOrDefault(String key, @Nullable T defaultValue, Class<T> clazz)
      Get a value from map.
      Type Parameters:
      T - type of return value
      Parameters:
      key - key
      defaultValue - default value if key does not exist
      clazz - enum clazz to resolve
      Returns:
      value of key or default value
    • getValueOrDefault

      public <T extends Enum<T>> List<T> getValueOrDefault(String key, List<T> defaultValue, Class<T> clazz)
      Get a value from map.
      Type Parameters:
      T - type of return value
      Parameters:
      key - key
      defaultValue - default value if key does not exist
      clazz - enum clazz to resolve
      Returns:
      value of key or default value
    • getValueOrDefault

      public <T> T getValueOrDefault(String key, T defaultValue, Function<String,T> valueConverter)
      Get a value from map.
      Type Parameters:
      T - type of return value
      Parameters:
      key - key
      defaultValue - default value if key does not exist
      valueConverter - Function to parse the string to value
      Returns:
      value of key or default value
    • getMap

      @NotNull public <K, V> @NotNull Map<K,V> getMap(String key, BiFunction<String,V,K> keyOrValueToKey)
      Converts a map which was saved with SerializationUtil.Builder.addMap(String, Map, BiFunction) )} to a map. These objects will be wrapped into an MapEntry object.
      Type Parameters:
      K - type of key
      V - type of value
      Parameters:
      key - key of map
      keyOrValueToKey - function to map the key or the value to a key
      Returns:
      map
      Since:
      1.3.2
    • getValue

      public <T> T getValue(String key, Function<String,T> valueConverter)
      Get a value from map.
      Type Parameters:
      T - type of return value
      Parameters:
      key - key
      valueConverter - Function to parse the string to value.
      Returns:
      converted string or null if key is not present.
    • size

      public int size()
      Specified by:
      size in interface Map<String,Object>
      Overrides:
      size in class AbstractMap<String,Object>
    • isEmpty

      public boolean isEmpty()
      Specified by:
      isEmpty in interface Map<String,Object>
      Overrides:
      isEmpty in class AbstractMap<String,Object>
    • containsKey

      public boolean containsKey(Object key)
      Specified by:
      containsKey in interface Map<String,Object>
      Overrides:
      containsKey in class AbstractMap<String,Object>
    • containsValue

      public boolean containsValue(Object value)
      Specified by:
      containsValue in interface Map<String,Object>
      Overrides:
      containsValue in class AbstractMap<String,Object>
    • keySet

      @NotNull public @NotNull Set<String> keySet()
      Specified by:
      keySet in interface Map<String,Object>
      Overrides:
      keySet in class AbstractMap<String,Object>