Class DataMap

java.lang.Object
com.complexible.common.base.DataMap

public class DataMap extends Object
An object that maps keys to values in a type-safe manner. A key cannot be mapped to multiple values. Each key specifies the Java Object allowed for the values of the key. Neither null keys nor null values are allowed.
Since:
2.0
Version:
2.0
Author:
Evren Sirin
  • Method Details

    • of

      public static DataMap of()
      Create a new empty data map.
    • of

      public static <V> DataMap of(DataKey<V> key, V value)
      Create a new data map with the given single mapping.
    • of

      public static <V1, V2> DataMap of(DataKey<V1> key1, V1 value1, DataKey<V2> key2, V2 value2)
      Create a new data map with the given two mapping.
    • of

      public static <V1, V2, V3> DataMap of(DataKey<V1> key1, V1 value1, DataKey<V2> key2, V2 value2, DataKey<V3> key3, V3 value3)
      Create a new data map with the given three mappings.
    • get

      public <V> V get(DataKey<V> key)
      Returns the value to which the specified key is mapped, or null if this map contains no mapping for the key.
      Type Parameters:
      V - Allowed types for the specified key
      Parameters:
      key - the key whose associated value is to be returned
      Returns:
      the value to which the specified key is mapped, or null if this map contains no mapping for the key
    • set

      public <V> DataMap set(DataKey<V> key, V value)
      Associates the specified value with the specified key in this map. If the map previously contained a mapping for the key, the old value is replaced by the specified value.
      Type Parameters:
      V - allowed types for this key
      Parameters:
      key - the key to identify the data value
      value - the new data value to associate with the key
      Returns:
      this data map for method chaining
    • contains

      public <V> boolean contains(DataKey<V> key)
    • remove

      public <V> V remove(DataKey<V> key)