public final class TuneOptional<T> extends Object
isPresent()
will return true
and
get()
will return the value.Modifier and Type | Method and Description |
---|---|
static <T> TuneOptional<T> |
empty()
Returns an empty
Optional instance. |
boolean |
equals(Object obj)
Indicates whether some other object is "equal to" this Optional.
|
T |
get()
If a value is present in this
Optional , returns the value,
otherwise throws NoSuchElementException . |
int |
hashCode()
Returns the hash code value of the present value, if any, or 0 (zero) if
no value is present.
|
boolean |
isPresent()
Return
true if there is a value present, otherwise false . |
static <T> TuneOptional<T> |
of(T value)
Returns an
Optional with the specified present non-null value. |
static <T> TuneOptional<T> |
ofNullable(T value)
Returns an
Optional describing the specified value, if non-null,
otherwise returns an empty Optional . |
T |
orElse(T other)
Return the value if present, otherwise return
other . |
String |
toString()
Returns a non-empty string representation of this Optional suitable for
debugging.
|
public static <T> TuneOptional<T> empty()
Optional
instance. No value is present for this
Optional.T
- Type of the non-existent valueOptional
public static <T> TuneOptional<T> of(T value)
Optional
with the specified present non-null value.T
- the class of the valuevalue
- the value to be present, which must be non-nullOptional
with the value presentNullPointerException
- if value is nullpublic static <T> TuneOptional<T> ofNullable(T value)
Optional
describing the specified value, if non-null,
otherwise returns an empty Optional
.T
- the class of the valuevalue
- the possibly-null value to describeOptional
with a present value if the specified value
is non-null, otherwise an empty Optional
public T get()
Optional
, returns the value,
otherwise throws NoSuchElementException
.Optional
NoSuchElementException
- if there is no value presentisPresent()
public boolean isPresent()
true
if there is a value present, otherwise false
.true
if there is a value present, otherwise false
public T orElse(T other)
other
.other
- the value to be returned if there is no value present, may
be nullother
public boolean equals(Object obj)
Optional
and;
equals()
.
public int hashCode()