Class BasicMapEntry<K,​V>

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

    public class BasicMapEntry<K,​V>
    extends java.lang.Object
    implements java.util.Map.Entry<K,​V>
    An simple minimal implementation of Map.Entry.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      (package private) K key  
      (package private) V value  
    • Constructor Summary

      Constructors 
      Constructor Description
      BasicMapEntry​(K k, V v)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean equals​(java.lang.Object o)  
      K getKey()  
      V getValue()  
      int hashCode()  
      (package private) void recordAccess​(java.util.HashMap<K,​V> m)
      This method is invoked whenever the value in an entry is overwritten by an invocation of put(k,v) for a key k that's already in the HashMap.
      (package private) void recordRemoval​(java.util.HashMap<K,​V> m)
      This method is invoked whenever the entry is removed from the table.
      V setValue​(V newValue)  
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Field Detail

      • key

        final K key
      • value

        V value
    • Constructor Detail

      • BasicMapEntry

        public BasicMapEntry​(K k,
                             V v)
        Parameters:
        k - the key
        v - the value
    • Method Detail

      • 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 newValue)
        Specified by:
        setValue in interface java.util.Map.Entry<K,​V>
      • equals

        public boolean equals​(java.lang.Object o)
        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
      • recordAccess

        void recordAccess​(java.util.HashMap<K,​V> m)
        This method is invoked whenever the value in an entry is overwritten by an invocation of put(k,v) for a key k that's already in the HashMap.
      • recordRemoval

        void recordRemoval​(java.util.HashMap<K,​V> m)
        This method is invoked whenever the entry is removed from the table.