Package com.linkedin.venice.utils.lazy
Class LazyResettableImpl<C>
java.lang.Object
com.linkedin.venice.utils.lazy.LazyResettableImpl<C>
- All Implemented Interfaces:
Lazy<C>,LazyResettable<C>
- Direct Known Subclasses:
LazyResettableWithTearDown
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionIf a value is initialized, and the value matches the given predicate, return anOptionaldescribing the value, otherwise return an emptyOptional.<U> Optional<U>If a value is initialized, apply the providedOptional-bearing mapping function to it, return that result, otherwise return an emptyOptional.get()voidboolean<U> Optional<U>If a value is initialized, apply the provided mapping function to it, and if the result is non-null, return anOptionaldescribing the result.Return the value if initialized, otherwise returnother.Return the value if initialized, otherwise invokeotherand return the result of that invocation.orElseThrow(Supplier<? extends X> exceptionSupplier) Return the contained value, if initialized, otherwise throw an exception to be created by the provided supplier.voidreset()Returns to the uninitialized state.
-
Field Details
-
lazy
-
-
Constructor Details
-
LazyResettableImpl
-
-
Method Details
-
reset
public void reset()Description copied from interface:LazyResettableReturns to the uninitialized state.- Specified by:
resetin interfaceLazyResettable<C>
-
get
-
ifPresent
-
isPresent
public boolean isPresent() -
filter
Description copied from interface:LazyIf a value is initialized, and the value matches the given predicate, return anOptionaldescribing the value, otherwise return an emptyOptional. -
map
Description copied from interface:LazyIf a value is initialized, apply the provided mapping function to it, and if the result is non-null, return anOptionaldescribing the result. Otherwise return an emptyOptional.- Specified by:
mapin interfaceLazy<C>- Type Parameters:
U- The type of the result of the mapping function- Parameters:
mapper- a mapping function to apply to the value, if initialized- Returns:
- an
Optionaldescribing the result of applying a mapping function to the value of thisOptional, if a value is initialized, otherwise an emptyOptional
-
flatMap
Description copied from interface:LazyIf a value is initialized, apply the providedOptional-bearing mapping function to it, return that result, otherwise return an emptyOptional. This method is similar toLazy.map(Function), but the provided mapper is one whose result is already anOptional, and if invoked,flatMapdoes not wrap it with an additionalOptional.- Specified by:
flatMapin interfaceLazy<C>- Type Parameters:
U- The type parameter to theOptionalreturned by the mapping function- Parameters:
mapper- a mapping function to apply to the value, if initialized- Returns:
- the result of applying an
Optional-bearing mapping function to the value of thisOptional, if a value is initialized, otherwise an emptyOptional
-
orElse
Description copied from interface:LazyReturn the value if initialized, otherwise returnother. -
orElseGet
Description copied from interface:LazyReturn the value if initialized, otherwise invokeotherand return the result of that invocation. -
orElseThrow
Description copied from interface:LazyReturn the contained value, if initialized, otherwise throw an exception to be created by the provided supplier.- Specified by:
orElseThrowin interfaceLazy<C>- Type Parameters:
X- Type of the exception to be thrown- Parameters:
exceptionSupplier- The supplier which will return the exception to be thrown- Returns:
- the initialized value
- Throws:
X- if there is no value initialized
-