Package com.gengoai
Class Lazy<T>
- java.lang.Object
-
- com.gengoai.Lazy<T>
-
- Type Parameters:
T
- the type parameter
- All Implemented Interfaces:
SerializableSupplier<T>
,Serializable
,Supplier<T>
public final class Lazy<T> extends Object implements SerializableSupplier<T>
Lazily create a value in a thread safe manner. Common usage is as follows:
//Declare a lazy initialized object. Lazy<ExpensiveObject> lazy = new Lazy(() -> createExpensiveObject()); //Now we will actually create the object. lazy.get().operation(); //Successive calls will use the already created object. lazy.get().operation_2();
- Author:
- David B. Bracewell
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description Lazy(SerializableSupplier<? extends T> supplier)
Instantiates a new Lazy created object.
-