@GwtCompatible public abstract class ForwardingMapEntry<K,V> extends ForwardingObjectimplements Map .Entry <K ,V>
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(java.lang.Object)
, 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
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.
Modifier | Constructor and Description |
---|---|
protected |
ForwardingMapEntry()
Constructor for use by subclasses.
|
Modifier and Type | Method and Description |
---|---|
protected abstract Map |
delegate()
Returns the backing delegate instance that methods are forwarded to.
|
boolean |
equals(Object
|
K |
getKey()
|
V |
getValue()
|
int |
hashCode()
|
V |
setValue(V value)
|
protected boolean |
standardEquals(Object
|
protected int |
standardHashCode()
|
protected String |
standardToString()
|
toString
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
comparingByKey, comparingByKey, comparingByValue, comparingByValue
protected ForwardingMapEntry()
protected abstract Map.Entry <K ,V> delegate()
ForwardingObject
ForwardingSet.delegate()
. Concrete subclasses override this method to supply the instance being decorated.
public K getKey()
public V getValue()
public boolean equals(Objectobject)
public int hashCode()
protected boolean standardEquals(Objectobject)
equals(Object)
in terms of
getKey()
and
getValue()
. If you override either of these methods, you may wish to override
equals(Object)
to forward to this implementation.
protected int standardHashCode()
hashCode()
in terms of
getKey()
and
getValue()
. If you override either of these methods, you may wish to override
hashCode()
to forward to this implementation.
@Beta protected StringstandardToString()
ForwardingObject.toString()
in terms of
getKey()
and
getValue()
. If you override either of these methods, you may wish to override
equals(java.lang.Object)
to forward to this implementation.