Class StrongReference<T,​A>

  • Type Parameters:
    T - the reference value type
    A - the attachment type
    All Implemented Interfaces:
    Reference<T,​A>

    public class StrongReference<T,​A>
    extends java.lang.Object
    implements Reference<T,​A>
    A strong reference with an attachment. Since strong references are always reachable, a reaper may not be used.
    Author:
    David M. Lloyd
    • Constructor Detail

      • StrongReference

        public StrongReference​(T value,
                               A attachment)
      • StrongReference

        public StrongReference​(T value)
    • Method Detail

      • get

        public T get()
        Description copied from interface: Reference
        Get the value, or null if the reference has been cleared.
        Specified by:
        get in interface Reference<T,​A>
        Returns:
        the value
      • clear

        public void clear()
        Description copied from interface: Reference
        Clear the reference.
        Specified by:
        clear in interface Reference<T,​A>
      • getAttachment

        public A getAttachment()
        Description copied from interface: Reference
        Get the attachment, if any.
        Specified by:
        getAttachment in interface Reference<T,​A>
        Returns:
        the attachment
      • toString

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