edu.emory.mathcs.backport.java.util

Class AbstractMap.SimpleEntry

Enclosing Class:
AbstractMap
Implemented Interfaces:
Entry

public static class AbstractMap.SimpleEntry
extends java.lang.Object
implements Entry

An Entry maintaining a key and a value. The value may be changed using the setValue method. This class facilitates the process of building custom map implementations. For example, it may be convenient to return arrays of SimpleEntry instances in method Map.entrySet().toArray
Since:
1.6

Constructor Summary

SimpleEntry(Entry entry)
Creates an entry representing the same mapping as the specified entry.
SimpleEntry(Object key, Object value)
Creates an entry representing a mapping from the specified key to the specified value.

Method Summary

boolean
equals(Object o)
Object
getKey()
Returns the key corresponding to this entry.
Object
getValue()
Returns the value corresponding to this entry.
int
hashCode()
Object
setValue(Object value)
Replaces the value corresponding to this entry with the specified value.
String
toString()
Returns a String representation of this map entry.

Constructor Details

SimpleEntry

public SimpleEntry(Entry entry)
Creates an entry representing the same mapping as the specified entry.
Parameters:
entry - the entry to copy

SimpleEntry

public SimpleEntry(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

Method Details

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.
Parameters:
value - new value to be stored in this entry
Returns:
the old value corresponding to the entry

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