Package io.javago.sync
Class OnceValues<S,T>
java.lang.Object
io.javago.sync.OnceValues<S,T>
- Type Parameters:
S- the type of the first valueT- the type of the second value
- All Implemented Interfaces:
Supplier<OnceValues.Values<S,T>>
The
OnceValues class implements Go's sync.OnceValues.
A Supplier wrapper that ensures the wrapped Supplier is executed only once and returns a pair of
values.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordA record that holds a pair of values. -
Constructor Summary
ConstructorsConstructorDescriptionOnceValues(Supplier<OnceValues.Values<S, T>> supplier) Constructs a newOnceValuesthat will wrap the givenSupplier. -
Method Summary
-
Constructor Details
-
OnceValues
Constructs a newOnceValuesthat will wrap the givenSupplier.- Parameters:
supplier- 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.
-