Package org.apache.commons.collections4.keyvalue

# Class TiedMapEntry<K,V>

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

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

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

public class TiedMapEntry<K,V> extends Object implements Map.Entry<K,V>, KeyValue<K,V>, Serializable
A `Map.Entry` tied to a map underneath.

This can be used to enable a map entry to make changes on the underlying map, however this will probably mess up any iterators.

Since:
  3.0
See Also:
  - Serialized Form

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `TiedMapEntry(Map<K,V> map, K key)`
  Constructs a new entry with the given Map and key.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `boolean`
  `equals(Object obj)`
  Compares this `Map.Entry` with another `Map.Entry`.
  `K`
  `getKey()`
  Gets the key of this entry
  `V`
  `getValue()`
  Gets the value of this entry direct from the map.
  `int`
  `hashCode()`
  Gets a hashCode compatible with the equals method.
  `V`
  `setValue(V value)`
  Sets the value associated with the key direct onto the map.
  `String`
  `toString()`
  Gets a string version of the entry.

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

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

- ## Constructor Details

  - ### TiedMapEntry

    public TiedMapEntry(Map<K,V> map, K key)
    Constructs a new entry with the given Map and key.
    Parameters:
      `map` - The map
      `key` - The key

- ## 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

  - ### getKey

    public K getKey()
    Gets the key of this entry
    Specified by:
      `getKey` in interface `KeyValue<K,V>`
    Specified by:
      `getKey` in interface `Map.Entry<K,V>`
    Returns:
      The key

  - ### getValue

    public V getValue()
    Gets the value of this entry direct from the map.
    Specified by:
      `getValue` in interface `KeyValue<K,V>`
    Specified by:
      `getValue` in interface `Map.Entry<K,V>`
    Returns:
      The 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 associated with the key direct onto the map.
    Specified by:
      `setValue` in interface `Map.Entry<K,V>`
    Parameters:
      `value` - The new value
    Returns:
      The old value
    Throws:
      `IllegalArgumentException` - if the value is set to this map entry

  - ### toString

    public String toString()
    Gets a string version of the entry.
    Overrides:
      `toString` in class `Object`
    Returns:
      entry as a string