-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default T
get()
boolean
isInitialized()
static <T> Lazy<T>
lazy(Supplier<T> supplier)
Creates a strict lazy value using the provided Supplier.default <R> Lazy<R>
map(Function<? super T,? extends R> function)
static <T> Lazy<T>
pure(Supplier<T> supplier)
Creates a pure lazy value using the provided Supplier to initialize the value.static <T> Lazy<T>
relaxed(Supplier<T> supplier)
Creates a relaxed lazy value using the provided Supplier.void
set(T newValue)
T
value()
static <T> Lazy<T>
value(T value)
Creates a lazy value using the provided constant value.
-
-
-
Method Detail
-
value
T value()
-
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.
-
-