Package com.linkedin.venice.utils.lazy
Interface LazyResettable<C>
-
- All Superinterfaces:
Lazy<C>
- All Known Implementing Classes:
LazyResettableImpl
,LazyResettableWithTearDown
public interface LazyResettable<C> extends Lazy<C>
This, likeLazy
, implements the same API asOptional
and provides late initialization for its content. Contrarily toLazy
, however, this interface provides areset()
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 theSupplier
used in the initialization of the content, rather than declare a non-finalLazy
and rely on convention to always reset it to a new reference that happens to carry the sameSupplier
.
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description static <C> LazyResettable<C>
of(java.util.function.Supplier<C> supplier)
static <C> LazyResettable<C>
of(java.util.function.Supplier<C> supplier, java.util.function.Consumer<C> tearDown)
void
reset()
Returns to the uninitialized state.
-
-
-
Method Detail
-
reset
void reset()
Returns to the uninitialized state.
-
of
static <C> LazyResettable<C> of(java.util.function.Supplier<C> supplier)
- Parameters:
supplier
- to initialize the wrapped value- Returns:
- an instance of
Lazy
which will execute the {@param supplier} if needed
-
of
static <C> LazyResettable<C> of(java.util.function.Supplier<C> supplier, java.util.function.Consumer<C> tearDown)
- 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
Lazy
which will execute the {@param supplier} if needed
-
-