| Modifier and Type | Method and Description |
|---|---|
static boolean |
any(Iterable<Optional<?>> optionals)
Checks if any of the optionals is present.
|
static boolean |
any(Optional<?>... optionals)
Checks if any of the optionals is present.
|
static boolean |
any(Stream<Optional<?>> optionals)
Checks if any of the optionals is present.
|
static <U> Optional<U> |
ifPresentOrElse(Optional<U> optional,
Consumer<U> consumer,
Runnable ifNotPresent)
Feeds {code optional}'s value to
consumer if it is present or else runs ifNotPresent. |
static <U,T> Optional<U> |
mapOrElse(Optional<T> optional,
Function<? super T,? extends U> mapper,
Runnable ifNotPresent)
Maps the
optional using mapper if it is present or runs ifNotPresent. |
static <U extends Comparable<? super U>> |
nullsFirst()
Creates a comparator to sort by the optional's value,
nulls first. |
static <U> Comparator<Optional<U>> |
nullsFirst(Comparator<? super U> comparator)
Creates a comparator wrapping
comparator to sort by the optional's value, nulls first. |
static <U extends Comparable<? super U>> |
nullsLast()
Creates a comparator to sort by the optional's value,
nulls last. |
static <U> Comparator<Optional<U>> |
nullsLast(Comparator<? super U> comparator)
Creates a comparator wrapping
comparator to sort by the optional's value, nulls last. |
static <U> Optional<U> |
or(Optional<U>... optionals)
Gets the first value of the first optional that is present.
|
static <U> Optional<U> |
or(Optional<U> a,
Optional<U> b)
Gets the value of
a if it is present or else the value of b. |
static <U> Optional<U> |
or(Optional<U> a,
Supplier<Optional<U>> b)
Gets the value of
a if it is present or else the value of b. |
static <U> Optional<U> |
or(Stream<Supplier<Optional<U>>> optionals)
Gets the first value of the first optional that is present.
|
static <U> Optional<U> |
or(Supplier<Optional<U>>... optionals)
Gets the first value of the first optional that is present.
|
static <U> U |
orElseNull(Optional<U> optional)
Gets the value of
optional if it is present, null otherwise. |
public static boolean any(Optional<?>... optionals)
optionals - the optionalspublic static boolean any(Iterable<Optional<?>> optionals)
optionals - the optionalspublic static boolean any(Stream<Optional<?>> optionals)
optionals - the optionalspublic static <U> Comparator<Optional<U>> nullsLast(Comparator<? super U> comparator)
comparator to sort by the optional's value, nulls last.U - the optional's typecomparator - the comparatorpublic static <U extends Comparable<? super U>> Comparator<Optional<U>> nullsLast()
nulls last.U - the optional's typepublic static <U> Comparator<Optional<U>> nullsFirst(Comparator<? super U> comparator)
comparator to sort by the optional's value, nulls first.U - the optional's typecomparator - the comparatorpublic static <U extends Comparable<? super U>> Comparator<Optional<U>> nullsFirst()
nulls first.U - the optional's typepublic static <U> U orElseNull(Optional<U> optional)
optional if it is present, null otherwise.U - the optional's typeoptional - the optionalnullpublic static <U> Optional<U> ifPresentOrElse(Optional<U> optional, Consumer<U> consumer, Runnable ifNotPresent)
consumer if it is present or else runs ifNotPresent.U - the optional's typeoptional - the optionalconsumer - the consumerifNotPresent - the runnablepublic static <U,T> Optional<U> mapOrElse(Optional<T> optional, Function<? super T,? extends U> mapper, Runnable ifNotPresent)
optional using mapper if it is present or runs ifNotPresent.T - the resulting optional's typeU - the optional's typeoptional - the optinalmapper - the mapperifNotPresent - the runnablepublic static <U> Optional<U> or(Optional<U> a, Supplier<Optional<U>> b)
a if it is present or else the value of b.U - the optional's typea - the first optionalb - a supplier for the second optionalpublic static <U> Optional<U> or(Optional<U> a, Optional<U> b)
a if it is present or else the value of b.U - the optional's typea - the first optionalb - a the second optional@SafeVarargs public static <U> Optional<U> or(Optional<U>... optionals)
U - the optional's typeoptionals - the optionals@SafeVarargs public static <U> Optional<U> or(Supplier<Optional<U>>... optionals)
U - the optional's typeoptionals - the optionalsCopyright © 2015–2020 52°North Initiative for Geospatial Open Source Software GmbH. All rights reserved.