Package org.apache.commons.collections4.keyvalue

# Class AbstractKeyValue<K,V>

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

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

All Implemented Interfaces:
  `KeyValue<K,V>`

Direct Known Subclasses:
  `AbstractMapEntry`, `DefaultKeyValue`

public abstract class AbstractKeyValue<K,V> extends Object implements KeyValue<K,V>
Abstract pair class to assist with creating `KeyValue` and `Map.Entry` implementations.

Since:
  3.0

- ## Constructor Summary

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

- ## Method Summary

  Modifier and Type
  Method
  Description
  `K`
  `getKey()`
  Gets the key from the pair.
  `V`
  `getValue()`
  Gets the value from the pair.
  `protected K`
  `setKey(K key)`
  Sets the key.
  `protected V`
  `setValue(V value)`
  Sets the value.
  `String`
  `toString()`
  Gets a debugging String view of the pair.

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

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

- ## Constructor Details

  - ### AbstractKeyValue

    protected AbstractKeyValue(K key, V value)
    Constructs a new pair with the specified 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

  - ### getKey

    public K getKey()
    Gets the key from the pair.
    Specified by:
      `getKey` in interface `KeyValue<K,V>`
    Returns:
      The key

  - ### getValue

    public V getValue()
    Gets the value from the pair.
    Specified by:
      `getValue` in interface `KeyValue<K,V>`
    Returns:
      The value

  - ### setKey

    protected K setKey(K key)
    Sets the key.
    Parameters:
      `key` - The key.
    Returns:
      The previous key.

  - ### setValue

    protected V setValue(V value)
    Sets the value.
    Parameters:
      `value` - The value.
    Returns:
      The previous value.

  - ### toString

    public String toString()
    Gets a debugging String view of the pair.
    Overrides:
      `toString` in class `Object`
    Returns:
      A String view of the entry