Class LazyValue<T>

  • All Implemented Interfaces:

    public abstract class LazyValue<T>
    extends java.lang.Object
    implements java.util.function.Supplier<T>
    An instances of this class represents a lazy value of type T. LazyValue implements an evaluate by need semantics: createValue() is called exactly once when get() is called for the first time.

    LazyValue instances are thread safe.

    • Constructor Summary

      Constructor Description
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      T get()
      Get value.
      boolean hasValue()  
      • Methods inherited from class java.lang.Object

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

      • LazyValue

        public LazyValue()
    • Method Detail

      • hasValue

        public boolean hasValue()
        true iff get() has been called at least once.
      • get

        public T get()
        Get value. Calls createValue() if called for the first time.
        Specified by:
        get in interface java.util.function.Supplier<T>
        the value