Interface Lazy<T>

  • Type Parameters:
    T - type of value
    All Superinterfaces:
    Supplier<T>

    public interface Lazy<T>
    extends Supplier<T>
    Provides a lazily-initialized value from a Supplier<T>.
    • Method Detail

      • value

        T value()
      • get

        default T get()
        Specified by:
        get in interface Supplier<T>
      • map

        default <R> Lazy<R> map​(Function<? super T,​? extends R> function)
      • isInitialized

        boolean isInitialized()
      • set

        void set​(T newValue)
      • lazy

        static <T> Lazy<T> lazy​(Supplier<T> supplier)
        Creates a strict lazy value using the provided Supplier. The supplier is guaranteed to only be invoked by at most one thread, and all threads will see the same published value when this returns.
      • value

        static <T> Lazy<T> value​(T value)
        Creates a lazy value using the provided constant value.
      • relaxed

        static <T> Lazy<T> relaxed​(Supplier<T> supplier)
        Creates a relaxed lazy value using the provided Supplier. The supplier may be invoked by more than one thread, but all threads will seem the same published value when this returns.
      • pure

        static <T> Lazy<T> pure​(Supplier<T> supplier)
        Creates a pure lazy value using the provided Supplier to initialize the value. The supplier may be invoked more than once, and the return value should be a purely computed value as the result may be a different instance each time. This is useful for building cache tables and other pure computations.