public class UnmodifiableMap<K,V> extends java.lang.Object implements java.util.Map<K,V>, java.io.Serializable
Map
prohibiting all calls which would modify
its contents. As the construction of this class is performed in constant time
it is prefered over copying the map (which takes linear time). Using this
class is also preferred to using the unmodifiableX()
in class
Collections
as they return the collection base type that does not
signal, that the object ist unmodifiable. Using the classes in this package
makes unmodifiability more explicit.
All prohibited methods throw an UnsupportedOperationException
. The
class is nearly the same as the one returned by
Collections.unmodifiableMap(Map)
, but by making it a public class we
can make the return value of some methods more explicit.
This map is serializable if the wrapped map is serializable.
Constructor and Description |
---|
UnmodifiableMap(java.util.Map<K,V> m)
Creates a new unmodifiable map from another map.
|
Modifier and Type | Method and Description |
---|---|
void |
clear()
Operation is not supported.
|
boolean |
containsKey(java.lang.Object key) |
boolean |
containsValue(java.lang.Object value) |
UnmodifiableSet<java.util.Map.Entry<K,V>> |
entrySet() |
boolean |
equals(java.lang.Object obj) |
V |
get(java.lang.Object key) |
int |
hashCode() |
boolean |
isEmpty() |
UnmodifiableSet<K> |
keySet() |
V |
put(K arg0,
V arg1)
Operation is not supported.
|
void |
putAll(java.util.Map<? extends K,? extends V> arg0)
Operation is not supported.
|
V |
remove(java.lang.Object arg0)
Operation is not supported.
|
int |
size() |
java.lang.String |
toString()
Returns a string representation of this map.
|
UnmodifiableCollection<V> |
values() |
public UnmodifiableMap(java.util.Map<K,V> m)
public boolean containsKey(java.lang.Object key)
public boolean containsValue(java.lang.Object value)
public UnmodifiableSet<K> keySet()
public UnmodifiableCollection<V> values()
public UnmodifiableSet<java.util.Map.Entry<K,V>> entrySet()
public void clear()
public java.lang.String toString()
toString
in class java.lang.Object
public boolean equals(java.lang.Object obj)