Class ConstantReference<T>

java.lang.Object
io.github.cowwoc.pouch10.core.ConstantReference<T>
Type Parameters:
T - the type of value returned by the reference
All Implemented Interfaces:
Reference<T>

public final class ConstantReference<T> extends Object implements Reference<T>
A Reference that returns a pre-existing value.

The implementation is thread-safe.

  • Constructor Details

    • ConstantReference

      public ConstantReference(T value)
      Creates a new ConstantReference.
      Parameters:
      value - the value
  • Method Details

    • getValue

      public T getValue()
      Description copied from interface: Reference
      Returns the value. Subsequent invocations of this method return the same value.
      Specified by:
      getValue in interface Reference<T>
      Returns:
      an object of type <T>
    • isInitialized

      public boolean isInitialized()
      Description copied from interface: Reference
      Indicates if the value was initialized.

      A value may get initialized immediately after this method returns false but once it returns true it will continue to do so indefinitely.

      Specified by:
      isInitialized in interface Reference<T>
      Returns:
      true if the value was initialized