Class WeakValueHashMap.Entry

All Implemented Interfaces:
Map.Entry<K,V>, Disposable
Enclosing class:
WeakValueHashMap<K,V>

private final class WeakValueHashMap.Entry extends WeakEntry<V> implements Map.Entry<K,V>
An entry in the WeakValueHashMap. This is a weak reference to a value together with a strong reference to a key.
  • Field Details

    • key

      final K key
      The key.
  • Constructor Details

  • Method Details

    • getKey

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

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

      public V setValue(V value)
      Replaces the value corresponding in this entry with the specified value. This method can be used only for setting the value to null.
      Specified by:
      setValue in interface Map.Entry<K,V>
    • dispose

      public void dispose()
      Invoked by ReferenceQueueConsumer for removing the reference from the enclosing collection.
      Specified by:
      dispose in interface Disposable
    • equals

      public boolean equals(Object other)
      Compares the specified object with this entry for equality.
      Specified by:
      equals in interface Map.Entry<K,V>
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Returns the hash code value for this map entry. This hash code is not stable, since it will change after GC collect the value.
      Specified by:
      hashCode in interface Map.Entry<K,V>
      Overrides:
      hashCode in class Object