public abstract static class F.Option<T>
extends java.lang.Object
implements java.lang.Iterable<T>
Option
are either an instance of Some
or the object None
.Constructor and Description |
---|
F.Option() |
Modifier and Type | Method and Description |
---|---|
abstract T |
get()
Returns the value if defined.
|
T |
getOrElse(T defaultValue)
Get the value if defined, otherwise return the supplied
defaultValue . |
abstract boolean |
isDefined()
Is the value of this option defined?
|
<A> F.Option<A> |
map(F.Function<T,A> function)
Map this option to another value.
|
static <T> F.None<T> |
None()
Constructs a
None value. |
static <T> F.Some<T> |
Some(T value)
Construct a
Some value. |
public abstract boolean isDefined()
true
if the value is defined, otherwise false
.public abstract T get()
null
.public static <T> F.None<T> None()
None
value.public static <T> F.Some<T> Some(T value)
Some
value.value
- The value to make optionalT
.public T getOrElse(T defaultValue)
defaultValue
.defaultValue
- The value to return if the value of this option is not defineddefaultValue
.public <A> F.Option<A> map(F.Function<T,A> function)
function
- The function to map the option using.java.lang.RuntimeException
- if function
threw an Exception. If the exception is a
RuntimeException
, it will be rethrown as is, otherwise it will be wrapped in a
RuntimeException
.