Optional not containing a reference.
| Modifier and Type | Field and Description |
|---|---|
| pack-priv static final Absent | |
| private static final long |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public Set | asSet()
Implements abstract com. Set whose only element is the contained instance if it
is present; an empty immutable Set otherwise.
|
| public boolean | equals(Object
the reference object with which to compare. object)Implements abstract com. true if object is an Optional instance, and either the
contained references are equal to each other or both are absent.
|
| public T | get()
Implements abstract com. |
| public int | hashCode()
Implements abstract com. |
| public boolean | isPresent()
Implements abstract com. true if this holder contains a (non-null) instance.
|
| public T | or(T defaultValue)
Implements abstract com. defaultValue otherwise.
|
| public Optional | or(Optional<? extends T> secondChoice)
Implements abstract com. Optional if it has a value present; secondChoice otherwise.
|
| public T | or(Supplier<? extends T> supplier)
Implements abstract com. supplier.get() otherwise.
|
| public T | orNull()
Implements abstract com. null otherwise.
|
| private Object | |
| public String | toString()
Implements abstract com. |
| public <V> Optional | transform(Function<? super T, V> function)
Implements abstract com. Function; otherwise,
Optional#absent is returned.
|
| pack-priv static <T> Optional |
| INSTANCE | back to summary |
|---|---|
| pack-priv static final Absent<Object> INSTANCE | |
| serialVersionUID | back to summary |
|---|---|
| private static final long serialVersionUID | |
| Absent | back to summary |
|---|---|
| private Absent() | |
| asSet | back to summary |
|---|---|
| public Set Implements abstract com. Doc from com. Returns an immutable singleton Comparison to
... can be replaced with:
Java 9 users: some use cases can be written with calls to
| |
| equals | back to summary |
|---|---|
| public boolean equals(Object object) Implements abstract com. Doc from com. Returns Comparison to
| |
| get | back to summary |
|---|---|
| public T get() Implements abstract com. Doc from com. Returns the contained instance, which must be present. If the instance might be absent, use
Comparison to
| |
| hashCode | back to summary |
|---|---|
| public int hashCode() Implements abstract com. Doc from com. Returns a hash code for this instance. Comparison to
| |
| isPresent | back to summary |
|---|---|
| public boolean isPresent() Implements abstract com. Doc from com. Returns Comparison to
| |
| or | back to summary |
|---|---|
| public T or(T defaultValue) Implements abstract com. Doc from com. Returns the contained instance if it is present; Note about generics: The signature
As a workaround, it is always safe to cast an
Comparison to
| |
| or | back to summary |
|---|---|
| public Optional Implements abstract com. Doc from com. Returns this Comparison to
| |
| or | back to summary |
|---|---|
| public T or(Supplier<? extends T> supplier) Implements abstract com. Doc from com. Returns the contained instance if it is present; Comparison to
| |
| orNull | back to summary |
|---|---|
| public T orNull() Implements abstract com. Doc from com. Returns the contained instance if it is present; Comparison to
| |
| readResolve | back to summary |
|---|---|
| private Object readResolve() | |
| toString | back to summary |
|---|---|
| public String toString() Implements abstract com. Doc from com. Returns a string representation for this instance. Comparison to
| |
| transform | back to summary |
|---|---|
| public <V> Optional Implements abstract com. Doc from com. If the instance is present, it is transformed with the given Comparison to
| |
| withType | back to summary |
|---|---|
pack-priv static <T> Optional
| |