Package com.complexible.common.base
Class DataMap
- java.lang.Object
-
- com.complexible.common.base.DataMap
-
public class DataMap extends java.lang.ObjectAn 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 Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description <V> booleancontains(DataKey<V> key)<V> Vget(DataKey<V> key)Returns the value to which the specified key is mapped, ornullif this map contains no mapping for the key.static DataMapof()Create a new empty data map.static <V> DataMapof(DataKey<V> key, V value)Create a new data map with the given single mapping.static <V1,V2>
DataMapof(DataKey<V1> key1, V1 value1, DataKey<V2> key2, V2 value2)Create a new data map with the given two mapping.static <V1,V2,V3>
DataMapof(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.<V> Vremove(DataKey<V> key)<V> DataMapset(DataKey<V> key, V value)Associates the specified value with the specified key in this map.
-
-
-
Method Detail
-
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, ornullif 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
nullif 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 valuevalue- 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)
-
-