java.util
Class AbstractMap.SimpleImmutableEntry<K,V>

java.lang.Object
  extended by java.util.AbstractMap.SimpleImmutableEntry<K,V>
All Implemented Interfaces:
Serializable, Map.Entry<K,V>
Enclosing class:
AbstractMap<K,V>

public static class AbstractMap.SimpleImmutableEntry<K,V>
extends Object
implements Map.Entry<K,V>, Serializable

A class containing an immutable key and value. The implementation of Entry#setValue(V) for this class simply throws an UnsupportedOperationException, thus preventing changes being made. This is useful when a static thread-safe view of a map is required.

Since:
1.6
See Also:
Serialized Form

Constructor Summary
AbstractMap.SimpleImmutableEntry(K key, V value)
           
AbstractMap.SimpleImmutableEntry(Map.Entry<? extends K,? extends V> entry)
           
 
Method Summary
 K getKey()
          Get the key corresponding to this entry.
 V getValue()
          Get the value corresponding to this entry.
 V setValue(V value)
          Replaces the value with the specified object (optional operation).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.util.Map.Entry
equals, hashCode
 

Constructor Detail

AbstractMap.SimpleImmutableEntry

public AbstractMap.SimpleImmutableEntry(K key,
                                        V value)

AbstractMap.SimpleImmutableEntry

public AbstractMap.SimpleImmutableEntry(Map.Entry<? extends K,? extends V> entry)
Method Detail

getKey

public K getKey()
Description copied from interface: Map.Entry
Get the key corresponding to this entry.

Specified by:
getKey in interface Map.Entry<K,V>
Returns:
the key

getValue

public V getValue()
Description copied from interface: Map.Entry
Get the value corresponding to this entry. If you already called Iterator.remove(), this is undefined.

Specified by:
getValue in interface Map.Entry<K,V>
Returns:
the value

setValue

public V setValue(V value)
Description copied from interface: Map.Entry
Replaces the value with the specified object (optional operation). This writes through to the map, and is undefined if you already called Iterator.remove().

Specified by:
setValue in interface Map.Entry<K,V>
Parameters:
value - the new value to store
Returns:
the old value