ForwardingMapEntry
Date: 2016-05-24

com.google.common.collect

## Class ForwardingMapEntry<K,V>

- java.lang.Object
- - com.google.common.collect.ForwardingObject
  - - com.google.common.collect.ForwardingMapEntry<K,V>

- All Implemented Interfaces:
    java.util.Map.Entry<K,V>

      @GwtCompatible
      public abstract class ForwardingMapEntry<K,V>
      extends ForwardingObject
      implements java.util.Map.Entry<K,V>

  A map entry which forwards all its method calls to another map entry. Subclasses should override one or more methods to modify the behavior of the backing map entry as desired per the decorator pattern.

  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.equal(java.lang.Object, java.lang.Object)` 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.

  Since:
    2.0

- - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `protected` | `ForwardingMapEntry()` Constructor for use by subclasses.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected abstract java.util.Map.Entry<K,V>` | `delegate()` Returns the backing delegate instance that methods are forwarded to.
    `boolean` | `equals(java.lang.Object object)`
    `K` | `getKey()`
    `V` | `getValue()`
    `int` | `hashCode()`
    `V` | `setValue(V value)`
    `protected boolean` | `standardEquals(java.lang.Object object)` A sensible definition of `equals(Object)` in terms of `getKey()` and `getValue()`.
    `protected int` | `standardHashCode()` A sensible definition of `hashCode()` in terms of `getKey()` and `getValue()`.
    `protected java.lang.String` | `standardToString()` A sensible definition of `ForwardingObject.toString()` in terms of `getKey()` and `getValue()`.

    - ### Methods inherited from class com.google.common.collect.ForwardingObject

      `toString`

    - ### Methods inherited from class java.lang.Object

      `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### ForwardingMapEntry

          protected ForwardingMapEntry()

      Constructor for use by subclasses.

  - ### Method Detail

    - #### delegate

          protected abstract java.util.Map.Entry<K,V> delegate()

      Description copied from class: `ForwardingObject`
      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 `ForwardingSet.delegate()`. Concrete subclasses override this method to supply the instance being decorated.
      Specified by:
        `delegate` in class `ForwardingObject`

    - #### getKey

          public K getKey()

      Specified by:
        `getKey` in interface `java.util.Map.Entry<K,V>`

    - #### getValue

          public V getValue()

      Specified by:
        `getValue` in interface `java.util.Map.Entry<K,V>`

    - #### setValue

          public V setValue(V value)

      Specified by:
        `setValue` in interface `java.util.Map.Entry<K,V>`

    - #### equals

          public boolean equals(@Nullable
                       java.lang.Object object)

      Specified by:
        `equals` in interface `java.util.Map.Entry<K,V>`
      Overrides:
        `equals` in class `java.lang.Object`

    - #### hashCode

          public int hashCode()

      Specified by:
        `hashCode` in interface `java.util.Map.Entry<K,V>`
      Overrides:
        `hashCode` in class `java.lang.Object`

    - #### standardEquals

          protected boolean standardEquals(@Nullable
                               java.lang.Object object)

      A sensible definition of `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.
      Since:
        7.0

    - #### standardHashCode

          protected int standardHashCode()

      A sensible definition of `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.
      Since:
        7.0

    - #### standardToString

          @Beta
          protected java.lang.String standardToString()

      A sensible definition of `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.
      Since:
        7.0