edu.emory.mathcs.backport.java.util
Class AbstractMap.SimpleImmutableEntry

java.lang.Object
  extended byedu.emory.mathcs.backport.java.util.AbstractMap.SimpleImmutableEntry
All Implemented Interfaces:
java.util.Map.Entry
Enclosing class:
AbstractMap

public static class AbstractMap.SimpleImmutableEntry
extends java.lang.Object
implements java.util.Map.Entry

An Entry maintaining an immutable key and value, This class does not support method setValue. This class may be convenient in methods that return thread-safe snapshots of key-value mappings.

Since:
1.6

Constructor Summary
AbstractMap.SimpleImmutableEntry(java.util.Map.Entry entry)
          Creates an entry representing the same mapping as the specified entry.
AbstractMap.SimpleImmutableEntry(java.lang.Object key, java.lang.Object value)
          Creates an entry representing a mapping from the specified key to the specified value.
 
Method Summary
 boolean equals(java.lang.Object o)
           
 java.lang.Object getKey()
          Returns the key corresponding to this entry.
 java.lang.Object getValue()
          Returns the value corresponding to this entry.
 int hashCode()
           
 java.lang.Object setValue(java.lang.Object value)
          Replaces the value corresponding to this entry with the specified value (optional operation).
 java.lang.String toString()
          Returns a String representation of this map entry.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AbstractMap.SimpleImmutableEntry

public AbstractMap.SimpleImmutableEntry(java.lang.Object key,
                                        java.lang.Object value)
Creates an entry representing a mapping from the specified key to the specified value.

Parameters:
key - the key represented by this entry
value - the value represented by this entry

AbstractMap.SimpleImmutableEntry

public AbstractMap.SimpleImmutableEntry(java.util.Map.Entry entry)
Creates an entry representing the same mapping as the specified entry.

Parameters:
entry - the entry to copy
Method Detail

getKey

public java.lang.Object getKey()
Returns the key corresponding to this entry.

Specified by:
getKey in interface java.util.Map.Entry
Returns:
the key corresponding to this entry

getValue

public java.lang.Object getValue()
Returns the value corresponding to this entry.

Specified by:
getValue in interface java.util.Map.Entry
Returns:
the value corresponding to this entry

setValue

public java.lang.Object setValue(java.lang.Object value)
Replaces the value corresponding to this entry with the specified value (optional operation). This implementation simply throws UnsupportedOperationException, as this class implements an immutable map entry.

Specified by:
setValue in interface java.util.Map.Entry
Parameters:
value - new value to be stored in this entry
Returns:
(Does not return)
Throws:
java.lang.UnsupportedOperationException - always

equals

public boolean equals(java.lang.Object o)
Specified by:
equals in interface java.util.Map.Entry

hashCode

public int hashCode()
Specified by:
hashCode in interface java.util.Map.Entry

toString

public java.lang.String toString()
Returns a String representation of this map entry. This implementation returns the string representation of this entry's key followed by the equals character ("=") followed by the string representation of this entry's value.

Returns:
a String representation of this map entry