T
- element typepublic class Option<T>
extends java.lang.Object
Option
stores a single value which may also be null.
This is different from Optional
which does not support null values.Constructor and Description |
---|
Option(T value)
Construct option with specified value.
|
Modifier and Type | Method and Description |
---|---|
static <EE> Option<EE> |
empty() |
boolean |
equals(java.lang.Object obj) |
T |
getValue()
Returns stored value.
|
T |
getValueOrNull()
Returns stored value of null if no value is stored.
|
int |
hashCode() |
boolean |
hasValue()
Returns true if a value is stored, false otherwise
|
static <T> Option<T> |
of(T value) |
java.lang.String |
toString() |
public Option(T value)
value
- valuepublic static <EE> Option<EE> empty()
public static <T> Option<T> of(T value)
public boolean hasValue()
public T getValueOrNull()
public T getValue()
java.lang.IllegalArgumentException
- if no value is storedpublic boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object