Class ForwardingMapEntry<K,V>

All Implemented Interfaces:

public abstract class ForwardingMapEntry<K,V> extends Object implements 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 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.

2.0 (imported from Google Collections Library)
Mike Bostock, Louis Wasserman
  • Method Details

    • delegate

      protected abstract Map.Entry<K,V> delegate()
      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.
    • getKey

      public K getKey()
      Specified by:
      getKey in interface Map.Entry<K,V>
    • getValue

      public V getValue()
      Specified by:
      getValue in interface Map.Entry<K,V>
    • setValue

      public V setValue(V value)
      Specified by:
      setValue in interface Map.Entry<K,V>
    • equals

      public boolean equals(Object object)
      Specified by:
      equals in interface Map.Entry<K,V>
      equals in class Object
    • hashCode

      public int hashCode()
      Specified by:
      hashCode in interface Map.Entry<K,V>
      hashCode in class Object
    • toString

      public String toString()
      Returns the string representation generated by the delegate's toString method.
      toString in class Object