Package com.gengoai.hermes
Class AttributeMap
- java.lang.Object
-
- java.util.AbstractMap<K,V>
-
- java.util.HashMap<AttributeType<?>,Object>
-
- com.gengoai.hermes.AttributeMap
-
- All Implemented Interfaces:
Serializable
,Cloneable
,Map<AttributeType<?>,Object>
public class AttributeMap extends HashMap<AttributeType<?>,Object>
Specialized HashMap for storingAttributeType
s and their values that correctly handles json serialization / deserialization and allows for checked type gets.- Author:
- David B. Bracewell
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class java.util.AbstractMap
AbstractMap.SimpleEntry<K extends Object,V extends Object>, AbstractMap.SimpleImmutableEntry<K extends Object,V extends Object>
-
-
Constructor Summary
Constructors Constructor Description AttributeMap()
Instantiates a new Attribute map.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <T> T
get(@NonNull AttributeType<T> attributeType)
Gets the value of the given attribute<T> T
getOrDefault(@NonNull AttributeType<T> attributeType, T defaultValue)
Gets the value of the given attribute or returns the default value if it is not in the mapObject
put(@NonNull AttributeType attributeType, Object value)
void
putAll(@NonNull Map<? extends AttributeType<?>,?> map)
-
Methods inherited from class java.util.HashMap
clear, clone, compute, computeIfAbsent, computeIfPresent, containsKey, containsValue, entrySet, forEach, get, getOrDefault, isEmpty, keySet, merge, putIfAbsent, remove, remove, replace, replace, replaceAll, size, values
-
Methods inherited from class java.util.AbstractMap
equals, hashCode, toString
-
-
-
-
Method Detail
-
get
public <T> T get(@NonNull @NonNull AttributeType<T> attributeType)
Gets the value of the given attribute- Type Parameters:
T
- the type of the attribute- Parameters:
attributeType
- the attribute type- Returns:
- the value of the attribute
-
getOrDefault
public <T> T getOrDefault(@NonNull @NonNull AttributeType<T> attributeType, T defaultValue)
Gets the value of the given attribute or returns the default value if it is not in the map- Type Parameters:
T
- the type of the attribute- Parameters:
attributeType
- the attribute typedefaultValue
- the default value- Returns:
- the value of the attribute or the default value if the attribute is not in the map
-
put
public Object put(@NonNull @NonNull AttributeType attributeType, Object value)
- Specified by:
put
in interfaceMap<AttributeType<?>,Object>
- Overrides:
put
in classHashMap<AttributeType<?>,Object>
-
putAll
public void putAll(@NonNull @NonNull Map<? extends AttributeType<?>,?> map)
- Specified by:
putAll
in interfaceMap<AttributeType<?>,Object>
- Overrides:
putAll
in classHashMap<AttributeType<?>,Object>
-
-