- java.lang.Object
-
- eu.ess.xaos.core.util.Lazy<T>
-
- Type Parameters:
T
- The type of the returned lazy evaluation.
- All Implemented Interfaces:
Supplier<T>
public class Lazy<T> extends Object implements Supplier<T>
Lazy evaluation value container.set(Object)
can be used to force a new value to theLazy
container. If called beforeget()
, it will inhibit the lazy evaluation.This class is thread-safe.
Usage: instead of creating a (instance) variable of type T, create if of type Lazy<T> passing the supplier for the lazy evaluation. Use the get() method on your (instance) variable the get the actual value.
Note: don't rely in possible collateral effects from the provided
Supplier
. Ifset(Object)
is called beforeget()
, then the lazy evaluation will never occur.- Author:
- claudio.rosati@esss.se
- See Also:
- Lazy Assignment in Java
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description T
get()
Returns the current value of this lazy container.static <T> Lazy<T>
of(Supplier<T> supplier)
void
set(T newValue)
Sets a new value for this value container.
-