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.Serializable
An (immutable) emptyMap
, that supports allMap
operations without throwing exceptions (in contrast toCollections.EMPTY_MAP
that will throw exceptions onput
/remove
).NOTE: This is not a general purpose
Map
implementation, as theput
andputAll
methods 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 void
clear()
boolean
containsKey(java.lang.Object pKey)
boolean
containsValue(java.lang.Object pValue)
java.util.Set<java.util.Map.Entry<K,V>>
entrySet()
boolean
equals(java.lang.Object pOther)
Tests the given object for equality (wether it is also an emptyMap
).V
get(java.lang.Object pKey)
int
hashCode()
Returns thehashCode
of the empty map,0
.boolean
isEmpty()
java.util.Set<K>
keySet()
V
put(java.lang.Object pKey, java.lang.Object pValue)
void
putAll(java.util.Map pMap)
V
remove(java.lang.Object pKey)
int
size()
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 standardMap
implementations of the Java Collections Framework.
-
-