Class 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 Detail

      • LazyReference

        public LazyReference​(Supplier<T> supplier)
    • Method Detail

      • 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.