Returns a new CompletionStage that is completed with the same value as the CompletionStage returned by the given function.
When this stage completes normally, the given function is invoked with this stage's result as the argument, returning another CompletionStage. When that stage completes normally, the CompletionStage returned by this method is completed with the same value.
To ensure progress, the supplied function must arrange eventual completion of its result.
This method is analogous to
Optional.flatMap and
Stream.flatMap.
See the CompletionStage documentation for rules
covering exceptional completion.
fn | the function to use to compute another CompletionStage | |
<U> | the type of the returned CompletionStage's result |
Diagram: Future