Class KeyValuePair<K,​V>

  • Type Parameters:
    K - the Object type used as key
    V - the Object type used as value
    All Implemented Interfaces:
    Map.Entry<K,​V>

    public class KeyValuePair<K,​V>
    extends Object
    implements Map.Entry<K,​V>
    A generic Map.Entry class, useful for returning key-value-like results.
    • Constructor Detail

      • KeyValuePair

        public KeyValuePair​(K k,
                            V v)
        Constructs a Key-Value pair using the given key and value.
        Parameters:
        k - The key object
        v - The value object
    • Method Detail

      • getKey

        public K getKey()
        Returns the key corresponding to this entry.
        Specified by:
        getKey in interface Map.Entry<K,​V>
        Returns:
        the key corresponding to this entry.
      • getValue

        public V getValue()
        Returns the value corresponding to this entry.
        Specified by:
        getValue in interface Map.Entry<K,​V>
        Returns:
        the value corresponding to this entry.
      • setValue

        public V setValue​(V newValue)
                   throws UnsupportedOperationException
        Replaces the value corresponding to this entry with the specified value (optional operation).
        Specified by:
        setValue in interface Map.Entry<K,​V>
        Parameters:
        newValue - new value to be stored in this entry.
        Returns:
        old value corresponding to the entry.
        Throws:
        UnsupportedOperationException - if the put operation is not supported by the backing map.