Interface LazyValue<T>

Type Parameters:
T - the type to supply
All Superinterfaces:
Supplier<T>
All Known Implementing Classes:
SimpleLazyValue, ThreadSafeLazyValue

public interface LazyValue<T> extends Supplier<T>
Represents a Lazy-loaded value which is loaded only on the first call to get. Though it is not a functional interface, it does extend Supplier so it can easily drop-in directly to various standard APIs. The interface makes no gaurantees as to thead safety, however specific implementations may.
  • Method Details

    • get

      T get()
      Gets the value of this SimpleLazyValue, computing it if it was not already computed.
      Specified by:
      get in interface Supplier<T>
      Returns:
      the optional value
    • getOptional

      Optional<T> getOptional()
      Gets an Optional representing this SimpleLazyValue. If the value was not previously loaded, then this simply returns an empty.
      Returns:
      the Optional representing the value