Package com.linkedin.venice.utils.lazy
Interface LazyResettable<C>
- All Superinterfaces:
Lazy<C>
- All Known Implementing Classes:
LazyResettableImpl,LazyResettableWithTearDown
This, like
Lazy, implements the same API as Optional and provides
late initialization for its content. Contrarily to Lazy, however, this interface
provides a reset() function to return to the original, uninitialized, state, after
which the late initialization can occur again, on-demand. This allows the user to define a
member variable as final, and thus guarantee that there is only one statement which can
define the Supplier used in the initialization of the content, rather than declare
a non-final Lazy and rely on convention to always reset it to a new reference that
happens to carry the same Supplier.-
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic <C> LazyResettable<C>static <C> LazyResettable<C>voidreset()Returns to the uninitialized state.
-
Method Details
-
reset
void reset()Returns to the uninitialized state. -
of
- Parameters:
supplier- to initialize the wrapped value- Returns:
- an instance of
Lazywhich will execute the if needed
-
of
- Parameters:
supplier- to initialize the wrapped valuetearDown- to run on thw wrapped value during reset, if it has already been initialized- Returns:
- an instance of
Lazywhich will execute the if needed
-