Class Reference<T>

  • Type Parameters:
    T -
    Direct Known Subclasses:
    Var

    public class Reference<T>
    extends java.lang.Object
    A simple container holding a reference to another object.
    • Constructor Summary

      Constructors 
      Constructor Description
      Reference()
      Create a new Reference with a null value.
      Reference​(T value)
      Create a new Reference to the given value object.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean clear()
      Sets this references value field to null.
      T get()
      Retrieves this references value object.
      T getAndClear()
      Retrieves this references value field and clears it.
      T getAndSet​(T value)
      Replaces this references value with the given one.
      boolean isNotSet()  
      boolean isSet()  
      boolean set​(T value)
      Sets this references value object to the given instance.
      T setAndGet​(T value)
      Replaces this references value with the given one.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • Reference

        public Reference()
        Create a new Reference with a null value.
      • Reference

        public Reference​(T value)
        Create a new Reference to the given value object.
        Parameters:
        value - the value object
    • Method Detail

      • clear

        public boolean clear()
        Sets this references value field to null.
        Returns:
        true
      • set

        public boolean set​(T value)
        Sets this references value object to the given instance.
        Parameters:
        value - the value
        Returns:
        true
      • get

        public T get()
        Retrieves this references value object.
        Returns:
        the target
      • getAndClear

        public T getAndClear()
        Retrieves this references value field and clears it. Equivalent to getAndSet(null).
        Returns:
        the target
      • getAndSet

        public T getAndSet​(T value)
        Replaces this references value with the given one.
        Parameters:
        value - the new value
        Returns:
        the previous value
      • setAndGet

        public T setAndGet​(T value)
        Replaces this references value with the given one.
        Parameters:
        value - the new value
        Returns:
        the new value
      • isSet

        public boolean isSet()
        Returns:
        true if this Reference holds a non-null value
      • isNotSet

        public boolean isNotSet()
        Returns:
        true if this Reference holds a null value