Example usage for Java java.util Optional fields, constructors, methods, implement or subclass
The text is from its open source code.
boolean | equals(Object obj) Indicates whether some other object is "equal to" this Optional . |
Optional | filter(Predicate super T> predicate) If a value is present, and the value matches the given predicate, returns an Optional describing the value, otherwise returns an empty Optional . |
Optional | flatMap(Function super T, ? extends Optional extends U>> mapper) If a value is present, returns the result of applying the given Optional -bearing mapping function to the value, otherwise returns an empty Optional . |
T | get() If a value is present, returns the value, otherwise throws NoSuchElementException . |
void | ifPresent(Consumer super T> action) If a value is present, performs the given action with the value, otherwise does nothing. |
boolean | isPresent() If a value is present, returns true , otherwise false . |
Optional | map(Function super T, ? extends U> mapper) If a value is present, returns an Optional describing (as if by #ofNullable ) the result of applying the given mapping function to the value, otherwise returns an empty Optional . |
Optional | of(T value) Returns an Optional describing the given non- null value. |
Optional | ofNullable(T value) Returns an Optional describing the given value, if non- null , otherwise returns an empty Optional . |
Optional | or(Supplier extends Optional extends T>> supplier) If a value is present, returns an Optional describing the value, otherwise returns an Optional produced by the supplying function. |
T | orElse(T other) If a value is present, returns the value, otherwise returns other . |
T | orElseGet(Supplier extends T> supplier) If a value is present, returns the value, otherwise returns the result produced by the supplying function. |
T | orElseThrow(Supplier extends X> exceptionSupplier) If a value is present, returns the value, otherwise throws an exception produced by the exception supplying function. |
String | toString() Returns a non-empty string representation of this Optional suitable for debugging. |