T - the expected type of the nullable value.public class Optional<T>
extends java.lang.Object
| Constructor and Description |
|---|
Optional(T value)
Constructs a new optional value
|
| Modifier and Type | Method and Description |
|---|---|
static <T> Optional<T> |
empty()
Returns an empty Optional instance.
|
boolean |
equals(java.lang.Object rhs) |
T |
get()
Gets the optional value if present.
|
int |
hashCode() |
boolean |
isPresent()
Checks if a non-null value is present.
|
public Optional(@Nullable
T value)
value - the optional valuepublic boolean isPresent()
@NonNull public T get()
java.util.NoSuchElementException - if the value is null.public int hashCode()
hashCode in class java.lang.Objectpublic boolean equals(java.lang.Object rhs)
equals in class java.lang.Objectpublic static <T> Optional<T> empty()
T - Type of the optional value