T - The value type.public final class Option<T>
extends java.lang.Object
| Modifier and Type | Method and Description |
|---|---|
static <T> Option<T> |
empty()
Returns an
Option with null-value. |
boolean |
equals(java.lang.Object obj)
Indicates whether some other object is "equal to" this Option.
|
T |
getValue()
Gets the value in the
Option. |
int |
hashCode()
Returns hash code of the value this Option is initialized with or -1 if in uninitialized state.
|
boolean |
isInitialized()
Return
true if this instance is initialized with a null-value or non-null-value, otherwise false. |
static <T> Option<T> |
of(T value)
Returns an
Option with the specified null-value or non-null-value. |
static <T> Option<T> |
uninitialized()
Returns an
Option instance with no-value. |
public static <T> Option<T> of(T value)
Option with the specified null-value or non-null-value.T - The value type.value - the value.Option with the value present.public static <T> Option<T> empty()
Option with null-value.
Option.empty() is a syntactic sugar for Option.of(null).
T - The value type.Option with a null-value.public static <T> Option<T> uninitialized()
Option instance with no-value.T - Type of the non-existent value.public boolean isInitialized()
true if this instance is initialized with a null-value or non-null-value, otherwise false.true if a value has been initialized, otherwise falsepublic boolean equals(java.lang.Object obj)
Option and;
equals().
equals in class java.lang.Objectobj - an object to be tested for equalityfalsepublic int hashCode()
The value 0 will be returned when initialized with null.
hashCode in class java.lang.Object