Package eu.bandm.tools.util.nonnull
Class MapProxy<K,V>
java.lang.Object
eu.bandm.tools.util.nonnull.MapProxy<K,V>
- All Implemented Interfaces:
Serializable,Map<K,V>
- Direct Known Subclasses:
NonNullKeyMap.MyProxy,NonNullMap.MyProxy,NonNullValueMap.MyProxy
Implements a map by delegation to a peer object from the
Java collection library.
Is used for nonNull maps, therefore the "put" methods (etc.) are implemented in the subclasses and left here abstract. This class implements more explicit delegations to the peer than minimally required by AbstractMap, for higher efficiency.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static class(package private) static class(package private) static classPutting null as a value (not as a key) must also be prevented on this way: NonNullMap -> entrySet() -> NonNullMapEntrySet -> iterator() -> NonNullMapEntryIterator -> next() -> NonNullMapEntry -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionasSorted()Returns a sorted, unmodifiable view IFF the backing peer is a sorted map.voidclear()booleancontainsKey(Object key) booleancontainsValue(Object value) entrySet()Will be overridden for value checked maps.booleaninthashCode()booleanisEmpty()keySet()intsize()toString()values()Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Map
compute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, put, putAll, putIfAbsent, remove, replace, replace, replaceAll
-
Field Details
-
peer
cf https://stackoverflow.com/questions/6433478/is-there-a-standard-java-list-implementation-that-doesnt-allow-adding-null-to-i
-
-
Constructor Details
-
MapProxy
-
-
Method Details
-
toString
-
asSorted
Returns a sorted, unmodifiable view IFF the backing peer is a sorted map.- Throws:
UnsupportedOperationException- if the backing peer does not offer a sorted view.
-
clear
public void clear() -
containsKey
- Specified by:
containsKeyin interfaceMap<K,V>
-
containsValue
- Specified by:
containsValuein interfaceMap<K,V>
-
entrySet
Will be overridden for value checked maps. Java API doc says "[Map.entrySet()] does not support the add or addAll operations", so no checks are required on this level. -
equals
-
get
-
hashCode
public int hashCode() -
isEmpty
public boolean isEmpty() -
keySet
-
remove
-
size
public int size() -
values
-