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 record
A record that holds a pair of values. -
Constructor Summary
ConstructorsConstructorDescriptionOnceValues
(Supplier<OnceValues.Values<S, T>> supplier) Constructs a newOnceValues
that will wrap the givenSupplier
. -
Method Summary
-
Constructor Details
-
OnceValues
Constructs a newOnceValues
that will wrap the givenSupplier
.- Parameters:
supplier
- theSupplier
to be wrapped and executed only once
-
-
Method Details
-
get
Executes the wrappedSupplier
only once. If this method is called multiple times, the wrappedSupplier
will only be executed the first time and its result will be returned. Subsequent calls will returnnull
.
-