public final class Option<T> extends Object implements Serializable
| Modifier and Type | Method and Description |
|---|---|
static <T> Option<T> |
empty() |
boolean |
equals(Object o) |
<U> Option<U> |
flatMap(Function<? super T,Option<U>> mapper) |
static <T> Option<T> |
fromJavaOptional(Optional<T> v)
Convert from java.util.Optional.
|
T |
get() |
int |
hashCode() |
void |
ifPresent(Consumer<? super T> consumer) |
boolean |
isPresent() |
<U> Option<U> |
map(Function<? super T,? extends U> mapper) |
static <T> Option<T> |
of(T value) |
static <T> Option<T> |
ofNullable(T value) |
Option<T> |
or(Supplier<? extends Option<T>> other)
Returns this
Option if not empty, otherwise evaluates the provided supplier
and returns the alternative |
T |
orElse(T other)
Identical to
Optional.orElse |
T |
orElseGet(Supplier<? extends T> other)
Identical to
Optional.orElseGet |
<X extends Throwable> |
orElseThrow(Supplier<? extends X> exceptionSupplier)
Identical to
Optional.orElseThrow |
Optional<T> |
toJavaOptional()
Convert to java Optional.
|
String |
toString() |
public static <T> Option<T> fromJavaOptional(Optional<T> v)
T - type of the value stored in java.util.Optional objectv - java.util.Optional objectpublic static <T> Option<T> empty()
public static <T> Option<T> of(T value)
public static <T> Option<T> ofNullable(T value)
public boolean isPresent()
public T get()
public Option<T> or(Supplier<? extends Option<T>> other)
Option if not empty, otherwise evaluates the provided supplier
and returns the alternativepublic <X extends Throwable> T orElseThrow(Supplier<? extends X> exceptionSupplier) throws X extends Throwable
Optional.orElseThrowX extends ThrowableCopyright © 2022 The Apache Software Foundation. All rights reserved.