Class MapEntry<K,​V>

  • Type Parameters:
    K - the type of the key of this entry.
    V - the type of the value of this entry.
    All Implemented Interfaces:
    java.util.Map.Entry<K,​V>

    public class MapEntry<K,​V>
    extends java.lang.Object
    implements java.util.Map.Entry<K,​V>
    Understands an entry in a Map.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      K key  
      V value  
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private MapEntry​(K key, V value)  
    • Field Detail

      • key

        public final K key
      • value

        public final V value
    • Constructor Detail

      • MapEntry

        private MapEntry​(K key,
                         V value)
    • Method Detail

      • entry

        public static <K,​V> MapEntry<K,​V> entry​(K key,
                                                            V value)
        Creates a new MapEntry.
        Type Parameters:
        K - the type of the key of this entry.
        V - the type of the value of this entry.
        Parameters:
        key - the key of the entry to create.
        value - the value of the entry to create.
        Returns:
        the created MapEntry.
      • equals

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

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

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • getKey

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

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

        public V setValue​(V value)
        Always throws UnsupportedOperationException, as this class represents an immutable map entry.
        Specified by:
        setValue in interface java.util.Map.Entry<K,​V>
        Parameters:
        value - ignored
        Returns:
        (Does not return)
        Throws:
        java.lang.UnsupportedOperationException - always