Class SoftObject


  • public final class SoftObject
    extends java.lang.ref.SoftReference
    Convenience class to wrap an Object into a SoftReference.

    Modified from java.util.WeakHashMap.WeakKey.

    Version:
    $Revision$
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected int hashCode
      The hash code of the nested object
    • Constructor Summary

      Constructors 
      Constructor Description
      SoftObject​(java.lang.Object obj)
      Construct a SoftObject.
      SoftObject​(java.lang.Object obj, java.lang.ref.ReferenceQueue queue)
      Construct a SoftObject.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static SoftObject create​(java.lang.Object obj)
      Create a SoftObject for the given object.
      static SoftObject create​(java.lang.Object obj, java.lang.ref.ReferenceQueue queue)
      Create a SoftObject for the given object.
      boolean equals​(java.lang.Object obj)
      Check the equality of an object with this.
      int hashCode()
      Return the hash code of the nested object.
      • Methods inherited from class java.lang.ref.SoftReference

        get
      • Methods inherited from class java.lang.ref.Reference

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

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

      • hashCode

        protected final int hashCode
        The hash code of the nested object
    • Constructor Detail

      • SoftObject

        public SoftObject​(java.lang.Object obj)
        Construct a SoftObject.
        Parameters:
        obj - Object to reference.
      • SoftObject

        public SoftObject​(java.lang.Object obj,
                          java.lang.ref.ReferenceQueue queue)
        Construct a SoftObject.
        Parameters:
        obj - Object to reference.
        queue - Reference queue.
    • Method Detail

      • equals

        public boolean equals​(java.lang.Object obj)
        Check the equality of an object with this.
        Overrides:
        equals in class java.lang.Object
        Parameters:
        obj - Object to test equality with.
        Returns:
        True if object is equal.
      • hashCode

        public int hashCode()
        Return the hash code of the nested object.
        Overrides:
        hashCode in class java.lang.Object
        Returns:
        The hash code of the nested object.
      • create

        public static SoftObject create​(java.lang.Object obj)
        Create a SoftObject for the given object.
        Parameters:
        obj - Object to reference.
        Returns:
        SoftObject or null if object is null.
      • create

        public static SoftObject create​(java.lang.Object obj,
                                        java.lang.ref.ReferenceQueue queue)
        Create a SoftObject for the given object.
        Parameters:
        obj - Object to reference.
        queue - Reference queue.
        Returns:
        SoftObject or null if object is null.