If a value is present, returns the result of applying the given
Optional
-bearing mapping function to the value, otherwise returns
an empty Optional
.
This method is similar to map(Function)
, but the mapping
function is one whose result is already an Optional
, and if
invoked, flatMap
does not wrap it within an additional
Optional
.
<U> | The type of value of the Optional returned by the
mapping function | |
mapper | the mapping function to apply to a value, if present |
Optional
-bearing mapping
function to the value of this Optional
, if a value is
present, otherwise an empty Optional
NullPointerException | if the mapping function is null or
returns a null result |
Diagram: Optional