public final class Optional<T> extends Object
Modifier and Type | Method and Description |
---|---|
static <T> Optional<T> |
empty() |
boolean |
equals(Object obj) |
Optional<T> |
filter(Predicate<? super T> predicate) |
<U> Optional<U> |
flatMap(Function<? super T,? extends Optional<? extends U>> mapper) |
T |
get() |
int |
hashCode() |
void |
ifPresent(Consumer<? super T> action) |
void |
ifPresentOrElse(Consumer<? super T> action,
Runnable emptyAction) |
boolean |
isPresent() |
<U> Optional<U> |
map(Function<? super T,? extends U> mapper) |
static <T> Optional<T> |
of(T value) |
static <T> Optional<T> |
ofNullable(T value) |
Optional<T> |
or(Supplier<? extends Optional<? extends T>> supplier) |
T |
orElse(T other) |
T |
orElseGet(Supplier<? extends T> supplier) |
<X extends Throwable> |
orElseThrow(Supplier<? extends X> exceptionSupplier) |
String |
toString() |
public static <T> Optional<T> empty()
public static <T> Optional<T> of(T value)
public static <T> Optional<T> ofNullable(T value)
public T get()
public boolean isPresent()
public void ifPresentOrElse(Consumer<? super T> action, Runnable emptyAction) throws Throwable
Throwable
public <U> Optional<U> map(Function<? super T,? extends U> mapper) throws Throwable
Throwable
public <U> Optional<U> flatMap(Function<? super T,? extends Optional<? extends U>> mapper) throws Throwable
Throwable
public <X extends Throwable> T orElseThrow(Supplier<? extends X> exceptionSupplier) throws X extends Throwable
X extends Throwable
Copyright © 2020. All rights reserved.