CompletionStage.thenCompose

Returns a new CompletionStage that is completed with the same value as the CompletionStage returned by the given function.

<p>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.

<p>To ensure progress, the supplied function must arrange eventual completion of its result.

<p>This method is analogous to {@link java.util.Optional#flatMap Optional.flatMap} and {@link java.util.stream.Stream#flatMap Stream.flatMap}.

<p>See the {@link CompletionStage} documentation for rules covering exceptional completion.

@param fn the function to use to compute another CompletionStage @param (U) the type of the returned CompletionStage's result @return the new CompletionStage

interface CompletionStage(T)
thenCompose
(
U
)
(
Function!(T, CompletionStage!(U)) fn
)

Meta