public interface Option<T> extends Serializable
someOrNullNoneOf(Object)
static factory method). You can think of this class as OneOf1OrNone.Modifier and Type | Interface and Description |
---|---|
static class |
Option.None<T>
Represents the absence of a value
|
static class |
Option.Some<T>
Represents the presence of a value, even if that value is null.
|
Modifier and Type | Field and Description |
---|---|
static Option |
NONE
None is a singleton and this is its only instance.
|
Modifier and Type | Method and Description |
---|---|
T |
get()
Return the value wrapped in this Option.
|
T |
getOrElse(T t)
If this is Some, return the value wrapped in this Option.
|
boolean |
isSome()
Is this Some?
|
<U> U |
match(Function1<T,U> has,
Function0<U> hasNot)
Pass in a function to execute if its Some and another to execute if its None.
|
static <T> Option<T> |
none()
Calling this instead of referring to NONE directly can make the type infrencer happy.
|
static <T> Option<T> |
of(T t)
Public static factory method for contructing Options.
|
static <T> Option<T> |
someOrNullNoneOf(T t)
Construct an option, but if t is null, make it None instead of Some.
|
<U> Option<U> |
then(Function1<T,Option<U>> f)
If this is Some, Apply the given function, else return None.
|
static final Option NONE
T get()
T getOrElse(T t)
<U> Option<U> then(Function1<T,Option<U>> f)
boolean isSome()
<U> U match(Function1<T,U> has, Function0<U> hasNot)
static <T> Option<T> none()
static <T> Option<T> of(T t)
static <T> Option<T> someOrNullNoneOf(T t)
Copyright © 2017. All rights reserved.