Warning
The methods of ForwardingMapEntry forward indiscriminately to
the methods of the delegate. For example, overriding getValue alone will not
change the behavior of equals, which can lead to unexpected behavior. In this case, you
should override equals as well, either providing your own implementation, or delegating
to the provided standardEquals method.
Each of the standard methods, where appropriate, use Objects#equal to test
equality for both keys and values. This may not be the desired behavior for map implementations
that use non-standard notions of key equality, such as the entry of a SortedMap whose
comparator is not consistent with equals.
The standard methods are not guaranteed to be thread-safe, even when all of the
methods that they depend on are thread-safe.
| Access | Constructor and Description |
|---|---|
| protected |
| Modifier and Type | Method and Description |
|---|---|
| protected abstract Map. | delegate()
Implements abstract com. |
| public boolean | equals(Object
object to be compared for equality with this map entry object)Overrides java. Implements java. |
| public K | |
| public V | |
| public int | hashCode()
Overrides java. Implements java. |
| public V | setValue(V
new value to be stored in this entry value)Implements java. |
| protected boolean | standardEquals(Object object)
A sensible definition of |
| protected int | |
| protected String |
| ForwardingMapEntry | back to summary |
|---|---|
| protected ForwardingMapEntry() Constructor for use by subclasses. | |
| delegate | back to summary |
|---|---|
| protected abstract Map. Implements abstract com. Doc from com. Returns the backing delegate instance that methods are forwarded to. Abstract subclasses
generally override this method with an abstract method that has a more specific return type,
such as
| |
| equals | back to summary |
|---|---|
| public boolean equals(Object object) Overrides java. Implements java. Doc from java. Compares the specified object with this entry for equality.
Returns
(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 equals method works properly across
different implementations of the Map.Entry interface.
| |
| getKey | back to summary |
|---|---|
| public K getKey() Implements java. Doc from java. Returns the key corresponding to this entry.
| |
| getValue | back to summary |
|---|---|
| public V getValue() Implements java. Doc from java. Returns the value corresponding to this entry. If the mapping
has been removed from the backing map (by the iterator's
| |
| hashCode | back to summary |
|---|---|
| public int hashCode() Overrides java. Implements java. Doc from java. Returns the hash code value for this map entry. The hash code
of a map entry
(e.getKey()==null ? 0 : e.getKey().hashCode()) ^
(e.getValue()==null ? 0 : e.getValue().hashCode())
This ensures that e1.equals(e2) implies that
e1.hashCode()==e2.hashCode() for any two Entries
e1 and e2, as required by the general
contract of Object.hashCode.
| |
| setValue | back to summary |
|---|---|
| public V setValue(V value) Implements java. Doc from java. Replaces the value corresponding to this entry with the specified
value (optional operation). (Writes through to the map.) The
behavior of this call is undefined if the mapping has already been
removed from the map (by the iterator's
| |
| standardEquals | back to summary |
|---|---|
| protected boolean standardEquals(Object object) A sensible definition of
| |
| standardHashCode | back to summary |
|---|---|
| protected int standardHashCode() A sensible definition of
| |
| standardToString | back to summary |
|---|---|
| protected String standardToString() A sensible definition of
| |