| |||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public static class AbstractMap.SimpleImmutableEntry extends Object implements Map.Entry, Serializable
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.
Constructor Summary | |
---|---|
AbstractMap.SimpleImmutableEntry(Object key, Object value) Creates an entry representing a mapping from the specified key to the specified value. |
|
Creates an entry representing the same mapping as the specified entry. |
Method Summary | |
---|---|
boolean |
Compares the specified object with this entry for equality. |
Object |
getKey() Returns the key corresponding to this entry. |
Object |
getValue() Returns the value corresponding to this entry. |
int |
hashCode() Returns the hash code value for this map entry. |
Object |
Replaces the value corresponding to this entry with the specified value (optional operation). |
String |
toString() Returns a String representation of this map entry. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public AbstractMap.SimpleImmutableEntry(Object key, Object value)
key
- the key represented by this entryvalue
- the value represented by this entrypublic AbstractMap.SimpleImmutableEntry(Map.Entry entry)
entry
- the entry to copyMethod Detail |
---|
public boolean equals(Object o)
(e1.getKey()==null ? e2.getKey()==null : e1.getKey().equals(e2.getKey())) && (e1.getValue()==null ? e2.getValue()==null : e1.getValue().equals(e2.getValue()))This ensures that the {@code equals} method works properly across different implementations of the {@code Map.Entry} interface.
equals
in class Object
o
- object to be compared for equality with this map entrypublic Object getKey()
public Object getValue()
public int hashCode()
(e.getKey()==null ? 0 : e.getKey().hashCode()) ^ (e.getValue()==null ? 0 : e.getValue().hashCode())This ensures that {@code e1.equals(e2)} implies that {@code e1.hashCode()==e2.hashCode()} for any two Entries {@code e1} and {@code e2}, as required by the general contract of {@link Object#hashCode}.
hashCode
in class Object
public Object setValue(Object value)
value
- new value to be stored in this entrypublic String toString()
toString
in class Object
| |||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |