Package com.atlassian.jira.util
Class Optionals
java.lang.Object
com.atlassian.jira.util.Optionals
Utility methods relating to the
Optional type, to make up for its deficiencies.- Since:
- 9.7
-
Method Summary
-
Method Details
-
fallBack
@Nonnull public static <T> Optional<T> fallBack(Optional<T> primary, Supplier<Optional<T>> secondarySupplier) If the first optional given is empty, falls back to the second one (which could also be empty).- Type Parameters:
T- the type of optional value- Parameters:
primary- the first optional to checksecondarySupplier- the supplier of the optional to use as a fallback- Returns:
- an optional, could be empty
-
foldToEffect
Specialised version offoldthat "returns"Void.- Type Parameters:
T- the optional type- Parameters:
optional- the optional to be foldedifPresent- the consumer to invoke if the optional is presentifAbsent- the effect to perform if the optional is empty
-