edu.emory.mathcs.backport.java.util

Class AbstractMap.SimpleImmutableEntry

public static class AbstractMap.SimpleImmutableEntry extends Object implements 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
SimpleImmutableEntry(Object key, Object value)
Creates an entry representing a mapping from the specified key to the specified value.
SimpleImmutableEntry(Entry entry)
Creates an entry representing the same mapping as the specified entry.
Method Summary
booleanequals(Object o)
ObjectgetKey()
Returns the key corresponding to this entry.
ObjectgetValue()
Returns the value corresponding to this entry.
inthashCode()
ObjectsetValue(Object value)
Replaces the value corresponding to this entry with the specified value (optional operation).
StringtoString()
Returns a String representation of this map entry.

Constructor Detail

SimpleImmutableEntry

public SimpleImmutableEntry(Object key, 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

SimpleImmutableEntry

public SimpleImmutableEntry(Entry entry)
Creates an entry representing the same mapping as the specified entry.

Parameters: entry the entry to copy

Method Detail

equals

public boolean equals(Object o)

getKey

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

Returns: the key corresponding to this entry

getValue

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

Returns: the value corresponding to this entry

hashCode

public int hashCode()

setValue

public Object setValue(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.

Parameters: value new value to be stored in this entry

Returns: (Does not return)

Throws: UnsupportedOperationException always

toString

public 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