| Constructor and Description |
|---|
Option() |
| Modifier and Type | Method and Description |
|---|---|
abstract T |
getOrElse(T defaultValue)
If the option is nonempty returns its value, otherwise returns
defaultValue. |
abstract T |
getOrNull()
If the option is nonempty returns its value, otherwise returns
null. |
abstract T |
getOrThrow()
Gets the value of this option.
|
abstract <E extends Throwable> |
getOrThrow(E e)
Returns its value if not empty, otherwise throws
e. |
abstract T |
getOrThrow(String message)
Gets the value of this option.
|
boolean |
isDefined()
Returns
true if the option is a Some(...). |
abstract boolean |
isEmpty()
Returns
true if the option is the None value. |
static <T> Option<T> |
none()
Gets the none object for the given type.
|
static <T> Option<T> |
of(T t)
Wraps anything.
|
static <T> Option<T> |
some(T t)
Gets the some object wrapping the given value.
|
abstract String |
toStringOr(String defaultValue) |
public abstract T getOrNull()
null.public abstract T getOrElse(T defaultValue)
defaultValue. Note that
defaultValue is eagerly evaluated.public abstract T getOrThrow()
IllegalArgumentException is thrown.public abstract T getOrThrow(String message)
IllegalArgumentException is thrown with the specifed message.public abstract <E extends Throwable> T getOrThrow(E e) throws E extends Throwable
e.E extends Throwablepublic abstract boolean isEmpty()
true if the option is the None value.public boolean isDefined()
true if the option is a Some(...).public static <T> Option<T> none()
T with an unchecked
warning allows to simulate a bottom type in Java.public static <T> Option<T> some(T t)
public static <T> Option<T> of(T t)
T - t - Copyright © 2015. All Rights Reserved.