T
- The type of the optional value.public class Optional<T> extends Object implements Iterable<T>, Serializable
Value class representing an optional value.
This class is immutable and thus thread-safe.
Modifier and Type | Method and Description |
---|---|
Optional<?> |
adapt() |
boolean |
equals(Object obj) |
<R> Optional<R> |
flatMap(F1<? super T,Optional<? extends R>> f) |
T |
get() |
T |
getOrElse(T t) |
T |
getOrElseF(F0<T> f) |
int |
hashCode() |
boolean |
isDefined() |
boolean |
isEmpty() |
Iterator<T> |
iterator() |
static <S> Optional<S> |
lift(S someOrNull)
|
<R> Optional<R> |
map(F1<? super T,? extends R> f) |
static <N> Optional<N> |
none() |
T |
orNull() |
static <S> Optional<S> |
some(S some)
Create a defined
Optional with the given value some . |
List<T> |
toList() |
String |
toString() |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
forEach, spliterator
public static <S> Optional<S> some(S some)
Create a defined Optional
with the given value some
.
public static <S> Optional<S> lift(S someOrNull)
Create an Optional
from the given object or a none
in case the
object was null
.
public static <N> Optional<N> none()
public T get()
public T orNull()
public boolean isDefined()
public boolean isEmpty()
public Optional<?> adapt()
Copyright © 2019. All rights reserved.