Package io.javago.sync
Class OnceValue<T>
java.lang.Object
io.javago.sync.OnceValue<T>
- Type Parameters:
T- the type of results supplied by this supplier
- All Implemented Interfaces:
Supplier<T>
The
OnceValue class implements Go's sync.OnceValue.
A Supplier wrapper that ensures the wrapped Supplier is executed only once.-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
OnceValue
Constructs a newOnceValuethat will wrap the givenSupplier.- Parameters:
func- theSupplierto be wrapped and executed only once
-
-
Method Details
-
get
Executes the wrappedSupplieronly once. If this method is called multiple times, the wrappedSupplierwill only be executed the first time and its result will be returned. Subsequent calls will returnnull.
-