Package org.apache.commons.collections4.keyvalue

# Class AbstractMapEntry<K,V>

java.lang.Object
org.apache.commons.collections4.keyvalue.AbstractKeyValue<K,V>
org.apache.commons.collections4.keyvalue.AbstractMapEntry<K,V>

Type Parameters:
  `K` - The type of keys
  `V` - The type of mapped values

All Implemented Interfaces:
  `Map.Entry<K,V>`, `KeyValue<K,V>`

Direct Known Subclasses:
  `DefaultMapEntry`, `UnmodifiableMapEntry`

public abstract class AbstractMapEntry<K,V> extends AbstractKeyValue<K,V> implements Map.Entry<K,V>
Abstract Pair class to assist with creating correct `Map.Entry` implementations.

Since:
  3.0

- ## Constructor Summary

  Constructors
  Modifier
  Constructor
  Description
  `protected`
  `AbstractMapEntry(K key, V value)`
  Constructs a new entry with the given key and given value.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `boolean`
  `equals(Object obj)`
  Compares this `Map.Entry` with another `Map.Entry`.
  `int`
  `hashCode()`
  Gets a hashCode compatible with the equals method.
  `V`
  `setValue(V value)`
  Sets the value stored in this `Map.Entry`.

  ### Methods inherited from class org.apache.commons.collections4.keyvalue.AbstractKeyValue

  `getKey, getValue, setKey, toString`

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

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

  ### Methods inherited from interface java.util.Map.Entry

  `getKey, getValue`

- ## Constructor Details

  - ### AbstractMapEntry

    protected AbstractMapEntry(K key, V value)
    Constructs a new entry with the given key and given value.
    Parameters:
      `key` - The key for the entry, may be null
      `value` - The value for the entry, may be null

- ## Method Details

  - ### equals

    public boolean equals(Object obj)
    Compares this `Map.Entry` with another `Map.Entry`.

    Implemented per API documentation of `Map.Entry.equals(Object)`

    Specified by:
      `equals` in interface `Map.Entry<K,V>`
    Overrides:
      `equals` in class `Object`
    Parameters:
      `obj` - The object to compare to
    Returns:
      true if equal key and value

  - ### hashCode

    public int hashCode()
    Gets a hashCode compatible with the equals method.

    Implemented per API documentation of `Map.Entry.hashCode()`

    Specified by:
      `hashCode` in interface `Map.Entry<K,V>`
    Overrides:
      `hashCode` in class `Object`
    Returns:
      A suitable hash code

  - ### setValue

    public V setValue(V value)
    Sets the value stored in this `Map.Entry`.

    This `Map.Entry` is not connected to a Map, so only the local data is changed.

    Specified by:
      `setValue` in interface `Map.Entry<K,V>`
    Overrides:
      `setValue` in class `AbstractKeyValue<K,V>`
    Parameters:
      `value` - The new value
    Returns:
      The previous value