Package com.complexible.common.base
Class DataMap
- java.lang.Object
-
- com.complexible.common.base.DataMap
-
public class DataMap extends java.lang.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 Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description <V> boolean
contains(DataKey<V> key)
<V> V
get(DataKey<V> key)
Returns the value to which the specified key is mapped, ornull
if this map contains no mapping for the key.static DataMap
of()
Create a new empty data map.static <V> DataMap
of(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> V
remove(DataKey<V> key)
<V> DataMap
set(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, ornull
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 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)
-
-