public final class OptionalDO<T>
extends java.lang.Object
Modifier and Type | Method and Description |
---|---|
static <T> OptionalDO<T> |
empty()
Returns an empty
OptionalDO instance. |
T |
get()
Returns the value if present, otherwise throws
NoSuchElementException . |
boolean |
isPresent()
Returns
true if present, otherwise false . |
static <T> OptionalDO<T> |
of(T value)
Returns an
OptionalDO describing the given non-null
value. |
static <T> OptionalDO<T> |
ofNullable(T value)
Returns an
OptionalDO describing the given value, if
non-null , otherwise returns an empty OptionalDO . |
T |
orElse(T other)
Returns the value if present, otherwise returns
other . |
public static <T> OptionalDO<T> empty()
OptionalDO
instance. No value is present for this
OptionalDO
.T
- The type of the non-existent valueOptionalDO
public static <T> OptionalDO<T> of(T value)
OptionalDO
describing the given non-null
value.T
- the type of the valuevalue
- the value to describe, which must be non-null
OptionalDO
with the value presentjava.lang.NullPointerException
- if value is null
public static <T> OptionalDO<T> ofNullable(T value)
OptionalDO
describing the given value, if
non-null
, otherwise returns an empty OptionalDO
.T
- the type of the valuevalue
- the possibly-null
value to describeOptionalDO
with a present value if the specified value is non-null
, otherwise an empty OptionalDO
public T get()
NoSuchElementException
.null
value described by this OptionalDO
java.util.NoSuchElementException
- if no value is presentisPresent()
public boolean isPresent()
true
if present, otherwise false
.true
if a value is present, otherwise false