Java java.util Optional fields, constructors, methods, implement or subclass

Example usage for Java java.util Optional fields, constructors, methods, implement or subclass

Introduction

In this page you can find the methods, fields and constructors for java.util Optional.

The text is from its open source code.

Constructor

Method

booleanequals(Object obj)
Indicates whether some other object is "equal to" this Optional .
Optionalfilter(Predicate predicate)
If a value is present, and the value matches the given predicate, returns an Optional describing the value, otherwise returns an empty Optional .
OptionalflatMap(Function> 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 .
Tget()
If a value is present, returns the value, otherwise throws NoSuchElementException .
voidifPresent(Consumer action)
If a value is present, performs the given action with the value, otherwise does nothing.
booleanisPresent()
If a value is present, returns true , otherwise false .
Optionalmap(Function 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 .
Optionalof(T value)
Returns an Optional describing the given non- null value.
OptionalofNullable(T value)
Returns an Optional describing the given value, if non- null , otherwise returns an empty Optional .
Optionalor(Supplier> supplier)
If a value is present, returns an Optional describing the value, otherwise returns an Optional produced by the supplying function.
TorElse(T other)
If a value is present, returns the value, otherwise returns other .
TorElseGet(Supplier supplier)
If a value is present, returns the value, otherwise returns the result produced by the supplying function.
TorElseThrow(Supplier exceptionSupplier)
If a value is present, returns the value, otherwise throws an exception produced by the exception supplying function.
StringtoString()
Returns a non-empty string representation of this Optional suitable for debugging.