Class ReferenceIdentityMap.ReferenceEntry

  • Enclosing class:
    ReferenceIdentityMap

    private static class ReferenceIdentityMap.ReferenceEntry
    extends java.lang.ref.WeakReference
    Each entry in the Map is represented with a ReferenceEntry.

    If getKey() or getValue() returns null, it means the mapping is stale and should be removed.

    Since:
    Commons Collections 3.1
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      private java.lang.Object getKey()
      Gets the key from the entry.
      private java.lang.Object getValue()
      Gets the value from the entry.
      private void purged()
      Purges this entry.
      private java.lang.Object setValue​(java.lang.Object obj)
      Sets the value of the entry.
      • Methods inherited from class java.lang.ref.Reference

        clear, clone, enqueue, get, isEnqueued, reachabilityFence
      • Methods inherited from class java.lang.Object

        equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • hashCode

        private int hashCode
        The hash code of the key
      • value

        private java.lang.Object value
        The value
    • Constructor Detail

      • ReferenceEntry

        private ReferenceEntry​(ReferenceIdentityMap parent,
                               ReferenceIdentityMap.ReferenceEntry next,
                               int hashCode,
                               java.lang.Object key,
                               java.lang.Object value)
        Creates a new entry object for the ReferenceMap.
        Parameters:
        parent - the parent map
        next - the next entry in the hash bucket
        hashCode - the hash code of the key
        key - the key
        value - the value
    • Method Detail

      • getKey

        private java.lang.Object getKey()
        Gets the key from the entry. This method dereferences weak and soft keys and thus may return null.
        Returns:
        the key, which may be null if it was garbage collected
      • getValue

        private java.lang.Object getValue()
        Gets the value from the entry. This method dereferences weak and soft value and thus may return null.
        Returns:
        the value, which may be null if it was garbage collected
      • setValue

        private java.lang.Object setValue​(java.lang.Object obj)
        Sets the value of the entry.
        Parameters:
        obj - the object to store
        Returns:
        the previous value
      • purged

        private void purged()
        Purges this entry.