Class OptionalUtils
- java.lang.Object
- 
- com.atlassian.confluence.impl.util.OptionalUtils
 
- 
 public final class OptionalUtils extends Object Utility methods relating to Optionals.- Since:
- 6.7.0
 
- 
- 
Method SummaryAll Methods Static Methods Concrete Methods Modifier and Type Method Description static <T,U>
 Optional<U>first(Optional<T> maybeT, Function<? super T,Optional<U>>... mappers)Returns the first non-empty value obtained by separately applying the given mappers to the given Optional.static <T> Optional<T>firstNonEmpty(Supplier<Optional<T>>... lazyOptionals)Returns the first of the given Optionals that is non-empty.static <A,B>
 Optional<io.atlassian.fugue.Pair<A,B>>zip(Optional<A> o1, Optional<B> o2)Zips the two given optionals into an optional of a pair.
 
- 
- 
- 
Method Detail- 
zippublic static <A,B> Optional<io.atlassian.fugue.Pair<A,B>> zip(Optional<A> o1, Optional<B> o2) Zips the two given optionals into an optional of a pair. This method can be deleted once we're on Fugue 4.6.0 or later, when itsPairtype will contain this method.- Type Parameters:
- A- the first type
- B- the second type
- Parameters:
- o1- the first optional
- o2- the second optional
- Returns:
- empty if either or both optionals are empty
 
 - 
first@SafeVarargs public static <T,U> Optional<U> first(Optional<T> maybeT, Function<? super T,Optional<U>>... mappers) Returns the first non-empty value obtained by separately applying the given mappers to the given Optional.- Type Parameters:
- T- the input type
- U- the output type
- Parameters:
- maybeT- the optional to which to apply the mappers
- mappers- the mappers to apply one by one
- Returns:
- empty if the given Optional is empty or all the given mappers return an empty
 
 - 
firstNonEmpty@SafeVarargs public static <T> Optional<T> firstNonEmpty(Supplier<Optional<T>>... lazyOptionals) Returns the first of the given Optionals that is non-empty.- Type Parameters:
- T- the type of value
- Parameters:
- lazyOptionals- the optionals to inspect
- Returns:
- empty if all of the given optionals are empty
 
 
- 
 
-