| Modifier and Type | Method and Description |
|---|---|
static <T> Optional<T> |
fallBack(Optional<T> primary,
java.util.function.Supplier<Optional<T>> secondarySupplier)
If the first optional given is empty, falls back to the second one (which could also be empty).
|
static <T> void |
foldToEffect(Optional<T> optional,
java.util.function.Consumer<T> ifPresent,
Runnable ifAbsent)
Specialised version of
fold that "returns" Void. |
@Nonnull public static <T> Optional<T> fallBack(Optional<T> primary, java.util.function.Supplier<Optional<T>> secondarySupplier)
T - the type of optional valueprimary - the first optional to checksecondarySupplier - the supplier of the optional to use as a fallbackpublic static <T> void foldToEffect(Optional<T> optional, java.util.function.Consumer<T> ifPresent, Runnable ifAbsent)
fold that "returns" Void.T - the optional typeoptional - the optional to be foldedifPresent - the consumer to invoke if the optional is presentifAbsent - the effect to perform if the optional is emptyCopyright © 2002-2024 Atlassian. All Rights Reserved.