Package eu.bandm.tools.util.java
Class HeteroMap
- All Implemented Interfaces:
Map<HeteroMap.Key,Object>
Immutable map with heterogeneously typed entries.
Keys are restricted to instances of a generic interface that is parameterized with the type of the corresponding value. Consequently, null keys are not supported.
This implementation is not suitable for high-performance applications.
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from class java.util.AbstractMap
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K, V> -
Method Summary
Modifier and TypeMethodDescriptionstatic HeteroMapempty()Returns an empty map.entrySet()<V> @Opt Vget(HeteroMap.Key<V> key) Returns the value to which the specified key is mapped, ornullif this map contains no mapping for the key.<V> HeteroMapwith(HeteroMap.Key<V> key, @Opt V value) Returns a map that has the same mappings as this map, with one exception.Methods inherited from class java.util.AbstractMap
clear, clone, containsKey, containsValue, equals, get, hashCode, isEmpty, keySet, put, putAll, remove, size, toString, valuesMethods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Map
compute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, putIfAbsent, remove, replace, replace, replaceAll
-
Method Details
-
get
Returns the value to which the specified key is mapped, ornullif this map contains no mapping for the key.- Type Parameters:
V- the type of the value- 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 - Throws:
NullPointerException- ifkeyis null
-
entrySet
- Specified by:
entrySetin interfaceMap<HeteroMap.Key,Object> - Specified by:
entrySetin classAbstractMap<HeteroMap.Key,Object>
-
empty
Returns an empty map.- Returns:
- a map that contains no key–value pairs
-
with
Returns a map that has the same mappings as this map, with one exception.The new map may either add a value (for a key that has previously not been mapped), or replace/remove a value (for a key that has previously been mapped).
The original map is not modified. The returned map may be identical to the original, if the operation has no effect. Namely, removing a
nullvalue and replacing a value by one that is equal according toObjects.equals(Object,Object)is considered to have no effect.- Type Parameters:
V- the type of the new value- Parameters:
key- the key to map to a new valuevalue- the new value, ornullfor unmappingkey- Returns:
- a map that maps all keys of
thisto the same values, except thatkeyis mapped tovalue
-