T - the type of the contained objectpublic abstract class Option<T>
extends java.lang.Object
materialize and dematerialize
operators.| Modifier and Type | Class and Description |
|---|---|
static class |
Option.Error<T>
Class representing an error option.
|
static class |
Option.None<T>
The helper class representing an option holding nothing.
|
static class |
Option.Some<T>
A helper class representing an option holding something of T.
|
| Constructor and Description |
|---|
Option() |
| Modifier and Type | Method and Description |
|---|---|
static <T> Option.Error<T> |
error(java.lang.Throwable t)
Create an error instance with the given Throwable.
|
static java.lang.Throwable |
getError(Option<?> o)
Extracts the error value from the option.
|
boolean |
hasError() |
boolean |
hasValue() |
static boolean |
isError(Option<?> o)
Returns true if the option is of type Error.
|
boolean |
isNone() |
static boolean |
isNone(Option<?> o)
Returns true if the option is of type None.
|
static boolean |
isSome(Option<?> o)
Returns true if the option is of type Some.
|
static <T> Option.None<T> |
none()
Returns a none of T.
|
static <T> Option.Some<T> |
some(T value)
Create a new Some instance with the supplied value.
|
abstract T |
value() |
public abstract T value()
public boolean hasValue()
public boolean hasError()
public boolean isNone()
@Nonnull public static <T> Option.None<T> none()
T - the type of the T@Nonnull public static <T> Option.Some<T> some(T value)
T - the value typevalue - the initial value@Nonnull public static <T> Option.Error<T> error(@Nonnull java.lang.Throwable t)
T - the element type, irrelevantt - the throwablepublic static boolean isError(@Nullable
Option<?> o)
o - the optionpublic static boolean isNone(@Nullable
Option<?> o)
o - the optionpublic static boolean isSome(@Nullable
Option<?> o)
o - the option@Nonnull public static java.lang.Throwable getError(Option<?> o)
Error instance.o - the option to get the error from