Package io.helidon.common
Interface LazyValue<T>
-
- Type Parameters:
T
- type of the provided object
- All Superinterfaces:
Supplier<T>
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
@FunctionalInterface public interface LazyValue<T> extends Supplier<T>
A typed supplier that wraps another supplier and only retrieves the value on the first request toSupplier.get()
, caching the value for all subsequent invocations.Helidon implementations obtained through
create(java.util.function.Supplier)
andcreate(Object)
are guaranteed to be thread safe.
-
-
Method Detail
-
create
static <T> LazyValue<T> create(Supplier<T> supplier)
Create a lazy value from a supplier.- Type Parameters:
T
- type of the value- Parameters:
supplier
- supplier to get the value from- Returns:
- a lazy value that will obtain the value from supplier on first call to
Supplier.get()
-
create
static <T> LazyValue<T> create(T value)
Create a lazy value from a value.- Type Parameters:
T
- type of the value- Parameters:
value
- actual value to return- Returns:
- a lazy value that will always return the value provided
-
-