Package com.twelvemonkeys.util
Class NullMap<K,V>
- java.lang.Object
-
- com.twelvemonkeys.util.NullMap<K,V>
-
- All Implemented Interfaces:
java.io.Serializable,java.util.Map<K,V>
public final class NullMap<K,V> extends java.lang.Object implements java.util.Map<K,V>, java.io.SerializableAn (immutable) emptyMap, that supports allMapoperations without throwing exceptions (in contrast toCollections.EMPTY_MAPthat will throw exceptions onput/remove).NOTE: This is not a general purpose
Mapimplementation, as theputandputAllmethods will not modify the map. Instances of this class will always be an empty map.- Version:
- $Id: com/twelvemonkeys/util/NullMap.java#2 $
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description NullMap()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclear()booleancontainsKey(java.lang.Object pKey)booleancontainsValue(java.lang.Object pValue)java.util.Set<java.util.Map.Entry<K,V>>entrySet()booleanequals(java.lang.Object pOther)Tests the given object for equality (wether it is also an emptyMap).Vget(java.lang.Object pKey)inthashCode()Returns thehashCodeof the empty map,0.booleanisEmpty()java.util.Set<K>keySet()Vput(java.lang.Object pKey, java.lang.Object pValue)voidputAll(java.util.Map pMap)Vremove(java.lang.Object pKey)intsize()java.util.Collection<V>values()
-
-
-
Method Detail
-
containsKey
public final boolean containsKey(java.lang.Object pKey)
-
containsValue
public final boolean containsValue(java.lang.Object pValue)
-
values
public final java.util.Collection<V> values()
-
putAll
public final void putAll(java.util.Map pMap)
-
remove
public final V remove(java.lang.Object pKey)
-
put
public final V put(java.lang.Object pKey, java.lang.Object pValue)
-
equals
public boolean equals(java.lang.Object pOther)
Tests the given object for equality (wether it is also an emptyMap). This is consistent with the standardMapimplementations of the Java Collections Framework.
-
-