public abstract static class F.Option<T>
extends java.lang.Object
implements java.util.Collection<T>
Option are either an instance of Some or the object None.| Constructor and Description |
|---|
F.Option() |
| Modifier and Type | Method and Description |
|---|---|
boolean |
add(java.lang.Object o) |
boolean |
addAll(java.util.Collection<? extends T> c) |
void |
clear() |
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?
|
boolean |
isEmpty() |
<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. |
boolean |
remove(java.lang.Object o) |
boolean |
removeAll(java.util.Collection<?> c) |
boolean |
retainAll(java.util.Collection<?> c) |
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 boolean isEmpty()
isEmpty in interface java.util.Collection<T>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.public void clear()
clear in interface java.util.Collection<T>public boolean retainAll(java.util.Collection<?> c)
retainAll in interface java.util.Collection<T>public boolean add(java.lang.Object o)
add in interface java.util.Collection<T>public boolean remove(java.lang.Object o)
remove in interface java.util.Collection<T>public boolean removeAll(java.util.Collection<?> c)
removeAll in interface java.util.Collection<T>