flatMap
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, but the mapping function is one whose result is already an Optional, and if invoked, flatMap does not wrap it within an additional Optional.
Return
the result of applying an Optional-bearing mapping function to the value of this Optional, if a value is present, otherwise an empty Optional
Parameters
mapper
the mapping function to apply to a value, if present
the type of value of the Optional returned by the mapping function
Throws
if the mapping function returns a null result