Class Lazy<T>

java.lang.Object
io.jenetics.internal.util.Lazy<T>
All Implemented Interfaces:
Serializable, Supplier<T>

public final class Lazy<T> extends Object implements Supplier<T>, Serializable
Class for lazy value initialization.
Since:
3.0
Version:
5.0
See Also:
  • Method Details

    • get

      public T get()
      Specified by:
      get in interface Supplier<T>
    • isEvaluated

      public boolean isEvaluated()
      Return the evaluation state of the Lazy variable.
      Returns:
      true is the Lazy variable has been evaluated, false otherwise
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • of

      public static <T> Lazy<T> of(Supplier<T> supplier)
      Create a new lazy value initialization.
      Type Parameters:
      T - the value type
      Parameters:
      supplier - the lazy value supplier
      Returns:
      a new lazy value initialization
      Throws:
      NullPointerException - if the given supplier is null
    • ofValue

      public static <T> Lazy<T> ofValue(T value)
      Create a new Lazy object with the given value. This method allows to create a lazy object with the given value.
      Type Parameters:
      T - the value type
      Parameters:
      value - the value this Lazy object is initialized with
      Returns:
      return a new lazy value with the given value
      Since:
      3.7