Class LazyReference<T>

java.lang.Object
org.linkki.util.LazyReference<T>
All Implemented Interfaces:
Supplier<T>

public class LazyReference<T> extends Object implements Supplier<T>
A Supplier that wraps another Supplier which gets called only once upon the first call to get(); afterwards the value is cached.
  • Constructor Details

    • LazyReference

      public LazyReference(Supplier<T> supplier)
  • Method Details

    • getReference

      @Deprecated(since="2.2.0") public T getReference()
      Deprecated.
      Use get() instead.
    • get

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

      public boolean isValuePresent()
      Returns whether a cached value is present. A value of true indicates that the wrapped supplier has already been called and will not be called by get() anymore.
    • lazy

      public static <T> LazyReference<T> lazy(Supplier<T> supplier)