Example usage for Java com.google.common.base Optional fields, constructors, methods, implement or subclass
The text is from its open source code.
Optional | absent() Returns an Optional instance with no contained reference. |
Set | asSet() Returns an immutable singleton Set whose only element is the contained instance if it is present; an empty immutable Set otherwise. |
boolean | equals(@Nullable Object object) Returns true if object is an Optional instance, and either the contained references are Object#equals equal to each other or both are absent. |
Optional | fromNullable(@Nullable T nullableReference) If nullableReference is non-null, returns an Optional instance containing that reference; otherwise returns Optional#absent . |
T | get() Returns the contained instance, which must be present. |
int | hashCode() Returns a hash code for this instance. |
boolean | isPresent() Returns true if this holder contains a (non-null) instance. |
Optional | of(T reference) Returns an Optional instance containing the given non-null reference. |
T | or(T defaultValue) Returns the contained instance if it is present; defaultValue otherwise. |
Optional | or(Optional extends T> secondChoice) Returns this Optional if it has a value present; secondChoice otherwise. |
T | or(Supplier extends T> supplier) Returns the contained instance if it is present; supplier.get() otherwise. |
T | orNull() Returns the contained instance if it is present; null otherwise. |
Iterable | presentInstances(final Iterable extends Optional extends T>> optionals) Returns the value of each present instance from the supplied optionals , in order, skipping over occurrences of Optional#absent . |
String | toString() Returns a string representation for this instance. |
Optional | transform(Function super T, V> function) If the instance is present, it is transformed with the given Function ; otherwise, Optional#absent is returned. |