Package Summary  Overview Summary

class:CompletionStage [CHANGED]

  • All Known Implementing Classes:
    CompletableFuture


    public interface CompletionStage<T>
    
    A stage of a possibly asynchronous computation, that performs an action or computes a value when another CompletionStage completes. A stage completes upon termination of its computation, but this may in turn trigger other dependent stages. The functionality defined in this interface takes only a few basic forms, which expand out to a larger set of methods to capture a range of usage styles:
    • The computation performed by a stage may be expressed as a Function, Consumer, or Runnable (using methods with names including apply, accept, or run, respectively) depending on whether it requires arguments and/or produces results. For example,:
       
      
      
       stage.thenApply(x -> square(x))
            .thenAccept(x -> System.out.print(x))
            .thenRun(() -> System.out.println());
      
      .An additional form (compose) appliesallows the construction of computation pipelines from functions returning completion stages.

      Any argument to a stage's computation is the outcome of stages themselves, rather than their resultsa triggering stage's computation.

    • One stage's execution may be triggered by completion of a single stage, or both of two stages, or either of two stages. Dependencies on a single stage are arranged using methods with prefix then. Those triggered by completion of both of two stages may combine their results or effects, using correspondingly named methods. Those triggered by either of two stages make no guarantees about which of the results or effects are used for the dependent stage's computation.
    • Dependencies among stages control the triggering of computations, but do not otherwise guarantee any particular ordering. Additionally, execution of a new stage's computations may be arranged in any of three ways: default execution, default asynchronous execution (using methods with suffix async that employ the stage's default asynchronous execution facility), or custom (via a supplied Executor). The execution properties of default and async modes are specified by CompletionStage implementations, not this interface. Methods with explicit Executor arguments may have arbitrary execution properties, and might not even support concurrent execution, but are arranged for processing in a way that accommodates asynchrony.
    • Two method forms (handle and whenComplete) support processingunconditional computation whether the triggering stage completed normally or exceptionally: Method whenComplete allows injection of an action regardless of outcome, otherwise preserving the outcome in its completion. Method handle additionally allowsexceptionally supports computation only when the triggering stage to computecompletes exceptionally, computing a replacement result that may enable further processing by other dependent stages, similarly to the java catch keyword. In all other cases, if a stage's computation terminates abruptly with an (unchecked) exception or error, then all dependent stages requiring its completion complete exceptionally as well, with a CompletionException holding the exception as its cause. If a stage is dependent on both of two stages, and both complete exceptionally, then the CompletionException may correspond to either one of these exceptions. If a stage is dependent on either of two others, and only one of them completes exceptionally, no guarantees are made about whether the dependent stage completes normally or exceptionally. In the case of method whenComplete, when the supplied action itself encounters an exception, then the stage completes exceptionally completeswith this exception if not alreadyunless the source stage also completed exceptionally, in which case the exceptional completion from the source stage is given preference and propagated to the dependent stage.

    All methods adhere to the above triggering, execution, and exceptional completion specifications (which are not repeated in individual method specifications). Additionally, while arguments used to pass a completion result (that is, for parameters of type T) for methods accepting them may be null, passing a null value for any other parameter will result in a NullPointerException being thrown.

    Method form handle is the most general way of creating a continuation stage, unconditionally performing a computation that is given both the result and exception (if any) of the triggering CompletionStage, and computing an arbitrary result. Method whenComplete is similar, but preserves the result of the triggering stage instead of computing a new one. Because a stage's normal result may be null, both methods should have a computation structured thus:

    (result, exception) -> {
       if (exception == null) {
         // triggering stage completed normally
       } else {
         // triggering stage completed exceptionally
       }
     }
    

    This interface does not define methods for initially creating, forcibly completing normally or exceptionally, probing completion status or results, or awaiting completion of a stage. Implementations of CompletionStage may provide means of achieving such effects, as appropriate. Method toCompletableFuture() enables interoperability among different implementations of this interface by providing a common conversion type.

    Since:
    1.8
  • All Known Implementing Classes:
    CompletableFuture


    public interface CompletionStage<T>
    
    A stage of a possibly asynchronous computation, that performs an action or computes a value when another CompletionStage completes. A stage completes upon termination of its computation, but this may in turn trigger other dependent stages. The functionality defined in this interface takes only a few basic forms, which expand out to a larger set of methods to capture a range of usage styles:
    • The computation performed by a stage may be expressed as a Function, Consumer, or Runnable (using methods with names including apply, accept, or run, respectively) depending on whether it requires arguments and/or produces results. For example, stage.thenApply(x -> square(x)).thenAccept(x -> System.out.print(x)).thenRun(() -> System.out.println()) . An additional form (compose) applies functions of stages themselves, rather than their results.
    • One stage's execution may be triggered by completion of a single stage, or both of two stages, or either of two stages. Dependencies on a single stage are arranged using methods with prefix then. Those triggered by completion of both of two stages may combine their results or effects, using correspondingly named methods. Those triggered by either of two stages make no guarantees about which of the results or effects are used for the dependent stage's computation.
    • Dependencies among stages control the triggering of computations, but do not otherwise guarantee any particular ordering. Additionally, execution of a new stage's computations may be arranged in any of three ways: default execution, default asynchronous execution (using methods with suffix async that employ the stage's default asynchronous execution facility), or custom (via a supplied Executor). The execution properties of default and async modes are specified by CompletionStage implementations, not this interface. Methods with explicit Executor arguments may have arbitrary execution properties, and might not even support concurrent execution, but are arranged for processing in a way that accommodates asynchrony.
    • Two method forms support processing whether the triggering stage completed normally or exceptionally: Method whenComplete allows injection of an action regardless of outcome, otherwise preserving the outcome in its completion. Method handle additionally allows the stage to compute a replacement result that may enable further processing by other dependent stages. In all other cases, if a stage's computation terminates abruptly with an (unchecked) exception or error, then all dependent stages requiring its completion complete exceptionally as well, with a CompletionException holding the exception as its cause. If a stage is dependent on both of two stages, and both complete exceptionally, then the CompletionException may correspond to either one of these exceptions. If a stage is dependent on either of two others, and only one of them completes exceptionally, no guarantees are made about whether the dependent stage completes normally or exceptionally. In the case of method whenComplete, when the supplied action itself encounters an exception, then the stage exceptionally completes with this exception if not already completed exceptionally.

    All methods adhere to the above triggering, execution, and exceptional completion specifications (which are not repeated in individual method specifications). Additionally, while arguments used to pass a completion result (that is, for parameters of type T) for methods accepting them may be null, passing a null value for any other parameter will result in a NullPointerException being thrown.

    This interface does not define methods for initially creating, forcibly completing normally or exceptionally, probing completion status or results, or awaiting completion of a stage. Implementations of CompletionStage may provide means of achieving such effects, as appropriate. Method toCompletableFuture() enables interoperability among different implementations of this interface by providing a common conversion type.

    Since:
    1.8
  • All Known Implementing Classes:
    CompletableFuture


    public interface CompletionStage<T>
    
    A stage of a possibly asynchronous computation, that performs an action or computes a value when another CompletionStage completes. A stage completes upon termination of its computation, but this may in turn trigger other dependent stages. The functionality defined in this interface takes only a few basic forms, which expand out to a larger set of methods to capture a range of usage styles:
    • The computation performed by a stage may be expressed as a Function, Consumer, or Runnable (using methods with names including apply, accept, or run, respectively) depending on whether it requires arguments and/or produces results. For example:
       
      
      
       stage.thenApply(x -> square(x))
            .thenAccept(x -> System.out.print(x))
            .thenRun(() -> System.out.println());
      
      An additional form (compose) allows the construction of computation pipelines from functions returning completion stages.

      Any argument to a stage's computation is the outcome of a triggering stage's computation.

    • One stage's execution may be triggered by completion of a single stage, or both of two stages, or either of two stages. Dependencies on a single stage are arranged using methods with prefix then. Those triggered by completion of both of two stages may combine their results or effects, using correspondingly named methods. Those triggered by either of two stages make no guarantees about which of the results or effects are used for the dependent stage's computation.
    • Dependencies among stages control the triggering of computations, but do not otherwise guarantee any particular ordering. Additionally, execution of a new stage's computations may be arranged in any of three ways: default execution, default asynchronous execution (using methods with suffix async that employ the stage's default asynchronous execution facility), or custom (via a supplied Executor). The execution properties of default and async modes are specified by CompletionStage implementations, not this interface. Methods with explicit Executor arguments may have arbitrary execution properties, and might not even support concurrent execution, but are arranged for processing in a way that accommodates asynchrony.
    • Two method forms (handle and whenComplete) support unconditional computation whether the triggering stage completed normally or exceptionally. Method exceptionally supports computation only when the triggering stage completes exceptionally, computing a replacement result, similarly to the java catch keyword. In all other cases, if a stage's computation terminates abruptly with an (unchecked) exception or error, then all dependent stages requiring its completion complete exceptionally as well, with a CompletionException holding the exception as its cause. If a stage is dependent on both of two stages, and both complete exceptionally, then the CompletionException may correspond to either one of these exceptions. If a stage is dependent on either of two others, and only one of them completes exceptionally, no guarantees are made about whether the dependent stage completes normally or exceptionally. In the case of method whenComplete, when the supplied action itself encounters an exception, then the stage completes exceptionally with this exception unless the source stage also completed exceptionally, in which case the exceptional completion from the source stage is given preference and propagated to the dependent stage.

    All methods adhere to the above triggering, execution, and exceptional completion specifications (which are not repeated in individual method specifications). Additionally, while arguments used to pass a completion result (that is, for parameters of type T) for methods accepting them may be null, passing a null value for any other parameter will result in a NullPointerException being thrown.

    Method form handle is the most general way of creating a continuation stage, unconditionally performing a computation that is given both the result and exception (if any) of the triggering CompletionStage, and computing an arbitrary result. Method whenComplete is similar, but preserves the result of the triggering stage instead of computing a new one. Because a stage's normal result may be null, both methods should have a computation structured thus:

    (result, exception) -> {
       if (exception == null) {
         // triggering stage completed normally
       } else {
         // triggering stage completed exceptionally
       }
     }
    

    This interface does not define methods for initially creating, forcibly completing normally or exceptionally, probing completion status or results, or awaiting completion of a stage. Implementations of CompletionStage may provide means of achieving such effects, as appropriate. Method toCompletableFuture() enables interoperability among different implementations of this interface by providing a common conversion type.

    Since:
    1.8

method:thenApply-java.util.function.Function- [CHANGED]

  • thenApply

    <U> CompletionStage<U> thenApply(Function<? super T,? extends U> fn)
    Returns a new CompletionStage that, when this stage completes normally, is executed with this stage's result as the argument to the supplied function.

    This method is analogous to Optional.map and Stream.map.

    See the CompletionStage documentation for rules covering exceptional completion.

    Type Parameters:
    U - the function's return type
    Parameters:
    fn - the function to use to compute the value of the returned CompletionStage
    Returns:
    the new CompletionStage
  • thenApply

    <U> CompletionStage<U> thenApply(Function<? super T,? extends U> fn)
    Returns a new CompletionStage that, when this stage completes normally, is executed with this stage's result as the argument to the supplied function. See the CompletionStage documentation for rules covering exceptional completion.
    Type Parameters:
    U - the function's return type
    Parameters:
    fn - the function to use to compute the value of the returned CompletionStage
    Returns:
    the new CompletionStage
  • thenApply

    <U> CompletionStage<U> thenApply(Function<? super T,? extends U> fn)
    Returns a new CompletionStage that, when this stage completes normally, is executed with this stage's result as the argument to the supplied function.

    This method is analogous to Optional.map and Stream.map.

    See the CompletionStage documentation for rules covering exceptional completion.

    Type Parameters:
    U - the function's return type
    Parameters:
    fn - the function to use to compute the value of the returned CompletionStage
    Returns:
    the new CompletionStage

method:thenCombineAsync-java.util.concurrent.CompletionStage-java.util.function.BiFunction- [CHANGED]

  • thenCombineAsync

    <U,V> CompletionStage<V> thenCombineAsync(CompletionStage<? extends U> other,
                                              BiFunction<? super T,? super U,? extends V> fn)
    Returns a new CompletionStage that, when this and the other given stage both complete normally, is executed using this stage's default asynchronous execution facility, with the two results as arguments to the supplied function. See the CompletionStage documentation for rules covering exceptional completion.
    Type Parameters:
    U - the type of the other CompletionStage's result
    V - the function's return type
    Parameters:
    other - the other CompletionStage
    fn - the function to use to compute the value of the returned CompletionStage
    Returns:
    the new CompletionStage
  • thenCombineAsync

    <U,V> CompletionStage<V> thenCombineAsync(CompletionStage<? extends U> other,
                                              BiFunction<? super T,? super U,? extends V> fn)
    Returns a new CompletionStage that, when this and the other given stage complete normally, is executed using this stage's default asynchronous execution facility, with the two results as arguments to the supplied function. See the CompletionStage documentation for rules covering exceptional completion.
    Type Parameters:
    U - the type of the other CompletionStage's result
    V - the function's return type
    Parameters:
    other - the other CompletionStage
    fn - the function to use to compute the value of the returned CompletionStage
    Returns:
    the new CompletionStage
  • thenCombineAsync

    <U,V> CompletionStage<V> thenCombineAsync(CompletionStage<? extends U> other,
                                              BiFunction<? super T,? super U,? extends V> fn)
    Returns a new CompletionStage that, when this and the other given stage both complete normally, is executed using this stage's default asynchronous execution facility, with the two results as arguments to the supplied function. See the CompletionStage documentation for rules covering exceptional completion.
    Type Parameters:
    U - the type of the other CompletionStage's result
    V - the function's return type
    Parameters:
    other - the other CompletionStage
    fn - the function to use to compute the value of the returned CompletionStage
    Returns:
    the new CompletionStage

method:thenCombineAsync-java.util.concurrent.CompletionStage-java.util.function.BiFunction-java.util.concurrent.Executor- [CHANGED]

  • thenCombineAsync

    <U,V> CompletionStage<V> thenCombineAsync(CompletionStage<? extends U> other,
                                              BiFunction<? super T,? super U,? extends V> fn,
                                              Executor executor)
    Returns a new CompletionStage that, when this and the other given stage both complete normally, is executed using the supplied executor, with the two results as arguments to the supplied function. See the CompletionStage documentation for rules covering exceptional completion.
    Type Parameters:
    U - the type of the other CompletionStage's result
    V - the function's return type
    Parameters:
    other - the other CompletionStage
    fn - the function to use to compute the value of the returned CompletionStage
    executor - the executor to use for asynchronous execution
    Returns:
    the new CompletionStage
  • thenCombineAsync

    <U,V> CompletionStage<V> thenCombineAsync(CompletionStage<? extends U> other,
                                              BiFunction<? super T,? super U,? extends V> fn,
                                              Executor executor)
    Returns a new CompletionStage that, when this and the other given stage complete normally, is executed using the supplied executor, with the two results as arguments to the supplied function. See the CompletionStage documentation for rules covering exceptional completion.
    Type Parameters:
    U - the type of the other CompletionStage's result
    V - the function's return type
    Parameters:
    other - the other CompletionStage
    fn - the function to use to compute the value of the returned CompletionStage
    executor - the executor to use for asynchronous execution
    Returns:
    the new CompletionStage
  • thenCombineAsync

    <U,V> CompletionStage<V> thenCombineAsync(CompletionStage<? extends U> other,
                                              BiFunction<? super T,? super U,? extends V> fn,
                                              Executor executor)
    Returns a new CompletionStage that, when this and the other given stage both complete normally, is executed using the supplied executor, with the two results as arguments to the supplied function. See the CompletionStage documentation for rules covering exceptional completion.
    Type Parameters:
    U - the type of the other CompletionStage's result
    V - the function's return type
    Parameters:
    other - the other CompletionStage
    fn - the function to use to compute the value of the returned CompletionStage
    executor - the executor to use for asynchronous execution
    Returns:
    the new CompletionStage

method:thenAcceptBothAsync-java.util.concurrent.CompletionStage-java.util.function.BiConsumer- [CHANGED]

  • thenAcceptBothAsync

    <U> CompletionStage<Void> thenAcceptBothAsync(CompletionStage<? extends U> other,
                                                  BiConsumer<? super T,? super U> action)
    Returns a new CompletionStage that, when this and the other given stage both complete normally, is executed using this stage's default asynchronous execution facility, with the two results as arguments to the supplied action. See the CompletionStage documentation for rules covering exceptional completion.
    Type Parameters:
    U - the type of the other CompletionStage's result
    Parameters:
    other - the other CompletionStage
    action - the action to perform before completing the returned CompletionStage
    Returns:
    the new CompletionStage
  • thenAcceptBothAsync

    <U> CompletionStage<Void> thenAcceptBothAsync(CompletionStage<? extends U> other,
                                                  BiConsumer<? super T,? super U> action)
    Returns a new CompletionStage that, when this and the other given stage complete normally, is executed using this stage's default asynchronous execution facility, with the two results as arguments to the supplied action.
    Type Parameters:
    U - the type of the other CompletionStage's result
    Parameters:
    other - the other CompletionStage
    action - the action to perform before completing the returned CompletionStage
    Returns:
    the new CompletionStage
  • thenAcceptBothAsync

    <U> CompletionStage<Void> thenAcceptBothAsync(CompletionStage<? extends U> other,
                                                  BiConsumer<? super T,? super U> action)
    Returns a new CompletionStage that, when this and the other given stage both complete normally, is executed using this stage's default asynchronous execution facility, with the two results as arguments to the supplied action. See the CompletionStage documentation for rules covering exceptional completion.
    Type Parameters:
    U - the type of the other CompletionStage's result
    Parameters:
    other - the other CompletionStage
    action - the action to perform before completing the returned CompletionStage
    Returns:
    the new CompletionStage

method:thenAcceptBothAsync-java.util.concurrent.CompletionStage-java.util.function.BiConsumer-java.util.concurrent.Executor- [CHANGED]

  • thenAcceptBothAsync

    <U> CompletionStage<Void> thenAcceptBothAsync(CompletionStage<? extends U> other,
                                                  BiConsumer<? super T,? super U> action,
                                                  Executor executor)
    Returns a new CompletionStage that, when this and the other given stage both complete normally, is executed using the supplied executor, with the two results as arguments to the supplied functionaction. See the CompletionStage documentation for rules covering exceptional completion.
    Type Parameters:
    U - the type of the other CompletionStage's result
    Parameters:
    other - the other CompletionStage
    action - the action to perform before completing the returned CompletionStage
    executor - the executor to use for asynchronous execution
    Returns:
    the new CompletionStage
  • thenAcceptBothAsync

    <U> CompletionStage<Void> thenAcceptBothAsync(CompletionStage<? extends U> other,
                                                  BiConsumer<? super T,? super U> action,
                                                  Executor executor)
    Returns a new CompletionStage that, when this and the other given stage complete normally, is executed using the supplied executor, with the two results as arguments to the supplied function.
    Type Parameters:
    U - the type of the other CompletionStage's result
    Parameters:
    other - the other CompletionStage
    action - the action to perform before completing the returned CompletionStage
    executor - the executor to use for asynchronous execution
    Returns:
    the new CompletionStage
  • thenAcceptBothAsync

    <U> CompletionStage<Void> thenAcceptBothAsync(CompletionStage<? extends U> other,
                                                  BiConsumer<? super T,? super U> action,
                                                  Executor executor)
    Returns a new CompletionStage that, when this and the other given stage both complete normally, is executed using the supplied executor, with the two results as arguments to the supplied action. See the CompletionStage documentation for rules covering exceptional completion.
    Type Parameters:
    U - the type of the other CompletionStage's result
    Parameters:
    other - the other CompletionStage
    action - the action to perform before completing the returned CompletionStage
    executor - the executor to use for asynchronous execution
    Returns:
    the new CompletionStage

method:runAfterBothAsync-java.util.concurrent.CompletionStage-java.lang.Runnable- [CHANGED]

  • runAfterBothAsync

    CompletionStage<Void> runAfterBothAsync(CompletionStage<?> other,
                                            Runnable action)
    Returns a new CompletionStage that, when this and the other given stage both complete normally, executes the given action using this stage's default asynchronous execution facility. See the CompletionStage documentation for rules covering exceptional completion.
    Parameters:
    other - the other CompletionStage
    action - the action to perform before completing the returned CompletionStage
    Returns:
    the new CompletionStage
  • runAfterBothAsync

    CompletionStage<Void> runAfterBothAsync(CompletionStage<?> other,
                                            Runnable action)
    Returns a new CompletionStage that, when this and the other given stage complete normally, executes the given action using this stage's default asynchronous execution facility. See the CompletionStage documentation for rules covering exceptional completion.
    Parameters:
    other - the other CompletionStage
    action - the action to perform before completing the returned CompletionStage
    Returns:
    the new CompletionStage
  • runAfterBothAsync

    CompletionStage<Void> runAfterBothAsync(CompletionStage<?> other,
                                            Runnable action)
    Returns a new CompletionStage that, when this and the other given stage both complete normally, executes the given action using this stage's default asynchronous execution facility. See the CompletionStage documentation for rules covering exceptional completion.
    Parameters:
    other - the other CompletionStage
    action - the action to perform before completing the returned CompletionStage
    Returns:
    the new CompletionStage

method:runAfterBothAsync-java.util.concurrent.CompletionStage-java.lang.Runnable-java.util.concurrent.Executor- [CHANGED]

  • runAfterBothAsync

    CompletionStage<Void> runAfterBothAsync(CompletionStage<?> other,
                                            Runnable action,
                                            Executor executor)
    Returns a new CompletionStage that, when this and the other given stage both complete normally, executes the given action using the supplied executor. See the CompletionStage documentation for rules covering exceptional completion.
    Parameters:
    other - the other CompletionStage
    action - the action to perform before completing the returned CompletionStage
    executor - the executor to use for asynchronous execution
    Returns:
    the new CompletionStage
  • runAfterBothAsync

    CompletionStage<Void> runAfterBothAsync(CompletionStage<?> other,
                                            Runnable action,
                                            Executor executor)
    Returns a new CompletionStage that, when this and the other given stage complete normally, executes the given action using the supplied executor. See the CompletionStage documentation for rules covering exceptional completion.
    Parameters:
    other - the other CompletionStage
    action - the action to perform before completing the returned CompletionStage
    executor - the executor to use for asynchronous execution
    Returns:
    the new CompletionStage
  • runAfterBothAsync

    CompletionStage<Void> runAfterBothAsync(CompletionStage<?> other,
                                            Runnable action,
                                            Executor executor)
    Returns a new CompletionStage that, when this and the other given stage both complete normally, executes the given action using the supplied executor. See the CompletionStage documentation for rules covering exceptional completion.
    Parameters:
    other - the other CompletionStage
    action - the action to perform before completing the returned CompletionStage
    executor - the executor to use for asynchronous execution
    Returns:
    the new CompletionStage

method:acceptEitherAsync-java.util.concurrent.CompletionStage-java.util.function.Consumer-java.util.concurrent.Executor- [CHANGED]

  • acceptEitherAsync

    CompletionStage<Void> acceptEitherAsync(CompletionStage<? extends T> other,
                                            Consumer<? super T> action,
                                            Executor executor)
    Returns a new CompletionStage that, when either this or the other given stage complete normally, is executed using the supplied executor, with the corresponding result as argument to the supplied functionaction. See the CompletionStage documentation for rules covering exceptional completion.
    Parameters:
    other - the other CompletionStage
    action - the action to perform before completing the returned CompletionStage
    executor - the executor to use for asynchronous execution
    Returns:
    the new CompletionStage
  • acceptEitherAsync

    CompletionStage<Void> acceptEitherAsync(CompletionStage<? extends T> other,
                                            Consumer<? super T> action,
                                            Executor executor)
    Returns a new CompletionStage that, when either this or the other given stage complete normally, is executed using the supplied executor, with the corresponding result as argument to the supplied function. See the CompletionStage documentation for rules covering exceptional completion.
    Parameters:
    other - the other CompletionStage
    action - the action to perform before completing the returned CompletionStage
    executor - the executor to use for asynchronous execution
    Returns:
    the new CompletionStage
  • acceptEitherAsync

    CompletionStage<Void> acceptEitherAsync(CompletionStage<? extends T> other,
                                            Consumer<? super T> action,
                                            Executor executor)
    Returns a new CompletionStage that, when either this or the other given stage complete normally, is executed using the supplied executor, with the corresponding result as argument to the supplied action. See the CompletionStage documentation for rules covering exceptional completion.
    Parameters:
    other - the other CompletionStage
    action - the action to perform before completing the returned CompletionStage
    executor - the executor to use for asynchronous execution
    Returns:
    the new CompletionStage

method:thenCompose-java.util.function.Function- [CHANGED]

  • thenCompose

    <U> CompletionStage<U> thenCompose(Function<? super T,? extends CompletionStage<U>> fn)
    Returns a new CompletionStage that , whenis completed with the same value as the CompletionStage returned by the given function.

    When this stage completes normally, the given function is executedinvoked with this stage's result as the argument to, 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.

    Type Parameters:
    U - the type of the returned CompletionStage's result
    Parameters:
    fn - the function returning a newto use to compute another CompletionStage
    Returns:
    the new CompletionStage
  • thenCompose

    <U> CompletionStage<U> thenCompose(Function<? super T,? extends CompletionStage<U>> fn)
    Returns a new CompletionStage that, when this stage completes normally, is executed with this stage's result as the argument to the supplied function. See the CompletionStage documentation for rules covering exceptional completion.
    Type Parameters:
    U - the type of the returned CompletionStage's result
    Parameters:
    fn - the function returning a new CompletionStage
    Returns:
    the CompletionStage
  • thenCompose

    <U> CompletionStage<U> thenCompose(Function<? super T,? extends CompletionStage<U>> fn)
    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.

    Type Parameters:
    U - the type of the returned CompletionStage's result
    Parameters:
    fn - the function to use to compute another CompletionStage
    Returns:
    the new CompletionStage

method:thenComposeAsync-java.util.function.Function- [CHANGED]

  • thenComposeAsync

    <U> CompletionStage<U> thenComposeAsync(Function<? super T,? extends CompletionStage<U>> fn)
    Returns a new CompletionStage that , when this stage completes normally,is completed with the same value as the CompletionStage returned by the given function, executed using this stage's default asynchronous execution facility,.

    When this stage completes normally, the given function is invoked with this stage's result as the argument to, 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.

    See the CompletionStage documentation for rules covering exceptional completion.

    Type Parameters:
    U - the type of the returned CompletionStage's result
    Parameters:
    fn - the function returning a newto use to compute another CompletionStage
    Returns:
    the new CompletionStage
  • thenComposeAsync

    <U> CompletionStage<U> thenComposeAsync(Function<? super T,? extends CompletionStage<U>> fn)
    Returns a new CompletionStage that, when this stage completes normally, is executed using this stage's default asynchronous execution facility, with this stage's result as the argument to the supplied function. See the CompletionStage documentation for rules covering exceptional completion.
    Type Parameters:
    U - the type of the returned CompletionStage's result
    Parameters:
    fn - the function returning a new CompletionStage
    Returns:
    the CompletionStage
  • thenComposeAsync

    <U> CompletionStage<U> thenComposeAsync(Function<? super T,? extends CompletionStage<U>> fn)
    Returns a new CompletionStage that is completed with the same value as the CompletionStage returned by the given function, executed using this stage's default asynchronous execution facility.

    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.

    See the CompletionStage documentation for rules covering exceptional completion.

    Type Parameters:
    U - the type of the returned CompletionStage's result
    Parameters:
    fn - the function to use to compute another CompletionStage
    Returns:
    the new CompletionStage

method:thenComposeAsync-java.util.function.Function-java.util.concurrent.Executor- [CHANGED]

  • thenComposeAsync

    <U> CompletionStage<U> thenComposeAsync(Function<? super T,? extends CompletionStage<U>> fn,
                                            Executor executor)
    Returns a new CompletionStage that , whenis completed with the same value as the CompletionStage returned by the given function, executed using the supplied Executor.

    When this stage completes normally, the given function is executed using the supplied Executor,invoked with this stage's result as the argument to, 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.

    See the CompletionStage documentation for rules covering exceptional completion.

    Type Parameters:
    U - the type of the returned CompletionStage's result
    Parameters:
    fn - the function returning a newto use to compute another CompletionStage
    executor - the executor to use for asynchronous execution
    Returns:
    the new CompletionStage
  • thenComposeAsync

    <U> CompletionStage<U> thenComposeAsync(Function<? super T,? extends CompletionStage<U>> fn,
                                            Executor executor)
    Returns a new CompletionStage that, when this stage completes normally, is executed using the supplied Executor, with this stage's result as the argument to the supplied function. See the CompletionStage documentation for rules covering exceptional completion.
    Type Parameters:
    U - the type of the returned CompletionStage's result
    Parameters:
    fn - the function returning a new CompletionStage
    executor - the executor to use for asynchronous execution
    Returns:
    the CompletionStage
  • thenComposeAsync

    <U> CompletionStage<U> thenComposeAsync(Function<? super T,? extends CompletionStage<U>> fn,
                                            Executor executor)
    Returns a new CompletionStage that is completed with the same value as the CompletionStage returned by the given function, executed using the supplied Executor.

    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.

    See the CompletionStage documentation for rules covering exceptional completion.

    Type Parameters:
    U - the type of the returned CompletionStage's result
    Parameters:
    fn - the function to use to compute another CompletionStage
    executor - the executor to use for asynchronous execution
    Returns:
    the new CompletionStage

method:whenComplete-java.util.function.BiConsumer- [CHANGED]

  • whenComplete

    CompletionStage<T> whenComplete(BiConsumer<? super T,? super Throwable> action)
    Returns a new CompletionStage with the same result or exception as this stage, that executes the given action when this stage completes.

    When this stage is complete, the given action is invoked with the result (or null if none) and the exception (or null if none) of this stage as arguments. The returned stage is completed when the action returns.

    IfUnlike method handle, this method is not designed to translate completion outcomes, so the supplied action should not throw an exception. However, if it does, the following rules apply: if this stage completed normally but the supplied action itself encountersthrows an exception, then the returned stage completes exceptionally completeswith thisthe supplied action's exception unless. Or, if this stage alsocompleted exceptionally (in which case,and the supplied action throws an exception, then the returned stage completes exceptionally completeswith the originalthis stage's exception).

    Parameters:
    action - the action to perform
    Returns:
    the new CompletionStage
  • whenComplete

    CompletionStage<T> whenComplete(BiConsumer<? super T,? super Throwable> action)
    Returns a new CompletionStage with the same result or exception as this stage, that executes the given action when this stage completes.

    When this stage is complete, the given action is invoked with the result (or null if none) and the exception (or null if none) of this stage as arguments. The returned stage is completed when the action returns. If the supplied action itself encounters an exception, then the returned stage exceptionally completes with this exception unless this stage also completed exceptionally (in which case, the returned stage exceptionally completes with the original exception).

    Parameters:
    action - the action to perform
    Returns:
    the new CompletionStage
  • whenComplete

    CompletionStage<T> whenComplete(BiConsumer<? super T,? super Throwable> action)
    Returns a new CompletionStage with the same result or exception as this stage, that executes the given action when this stage completes.

    When this stage is complete, the given action is invoked with the result (or null if none) and the exception (or null if none) of this stage as arguments. The returned stage is completed when the action returns.

    Unlike method handle, this method is not designed to translate completion outcomes, so the supplied action should not throw an exception. However, if it does, the following rules apply: if this stage completed normally but the supplied action throws an exception, then the returned stage completes exceptionally with the supplied action's exception. Or, if this stage completed exceptionally and the supplied action throws an exception, then the returned stage completes exceptionally with this stage's exception.

    Parameters:
    action - the action to perform
    Returns:
    the new CompletionStage

method:whenCompleteAsync-java.util.function.BiConsumer- [CHANGED]

  • whenCompleteAsync

    CompletionStage<T> whenCompleteAsync(BiConsumer<? super T,? super Throwable> action)
    Returns a new CompletionStage with the same result or exception as this stage, that executes the given action using this stage's default asynchronous execution facility when this stage completes.

    When this stage is complete, the given action is invoked with the result (or null if none) and the exception (or null if none) of this stage as arguments. The returned stage is completed when the action returns.

    Unlike method handleAsync, this method is not designed to translate completion outcomes, so the supplied action should not throw an exception. However, if it does, the following rules apply: If this stage completed normally but the supplied action itself encountersthrows an exception, then the returned stage completes exceptionally completeswith thisthe supplied action's exception unless. Or, if this stage alsocompleted exceptionally and the supplied action throws an exception, then the returned stage completes exceptionally with this stage's exception.

    Parameters:
    action - the action to perform
    Returns:
    the new CompletionStage
  • whenCompleteAsync

    CompletionStage<T> whenCompleteAsync(BiConsumer<? super T,? super Throwable> action)
    Returns a new CompletionStage with the same result or exception as this stage, that executes the given action using this stage's default asynchronous execution facility when this stage completes.

    When this stage is complete, the given action is invoked with the result (or null if none) and the exception (or null if none) of this stage as arguments. The returned stage is completed when the action returns. If the supplied action itself encounters an exception, then the returned stage exceptionally completes with this exception unless this stage also completed exceptionally.

    Parameters:
    action - the action to perform
    Returns:
    the new CompletionStage
  • whenCompleteAsync

    CompletionStage<T> whenCompleteAsync(BiConsumer<? super T,? super Throwable> action)
    Returns a new CompletionStage with the same result or exception as this stage, that executes the given action using this stage's default asynchronous execution facility when this stage completes.

    When this stage is complete, the given action is invoked with the result (or null if none) and the exception (or null if none) of this stage as arguments. The returned stage is completed when the action returns.

    Unlike method handleAsync, this method is not designed to translate completion outcomes, so the supplied action should not throw an exception. However, if it does, the following rules apply: If this stage completed normally but the supplied action throws an exception, then the returned stage completes exceptionally with the supplied action's exception. Or, if this stage completed exceptionally and the supplied action throws an exception, then the returned stage completes exceptionally with this stage's exception.

    Parameters:
    action - the action to perform
    Returns:
    the new CompletionStage

method:whenCompleteAsync-java.util.function.BiConsumer-java.util.concurrent.Executor- [CHANGED]

  • whenCompleteAsync

    CompletionStage<T> whenCompleteAsync(BiConsumer<? super T,? super Throwable> action,
                                         Executor executor)
    Returns a new CompletionStage with the same result or exception as this stage, that executes the given action using the supplied Executor when this stage completes.

    When this stage is complete, the given action is invoked with the result (or null if none) and the exception (or null if none) of this stage as arguments. The returned stage is completed when the action returns.

    Unlike method handleAsync, this method is not designed to translate completion outcomes, so the supplied action should not throw an exception. However, if it does, the following rules apply: If this stage completed normally but the supplied action itself encountersthrows an exception, then the returned stage completes exceptionally completeswith thisthe supplied action's exception unless. Or, if this stage alsocompleted exceptionally and the supplied action throws an exception, then the returned stage completes exceptionally with this stage's exception.

    Parameters:
    action - the action to perform
    executor - the executor to use for asynchronous execution
    Returns:
    the new CompletionStage
  • whenCompleteAsync

    CompletionStage<T> whenCompleteAsync(BiConsumer<? super T,? super Throwable> action,
                                         Executor executor)
    Returns a new CompletionStage with the same result or exception as this stage, that executes the given action using the supplied Executor when this stage completes.

    When this stage is complete, the given action is invoked with the result (or null if none) and the exception (or null if none) of this stage as arguments. The returned stage is completed when the action returns. If the supplied action itself encounters an exception, then the returned stage exceptionally completes with this exception unless this stage also completed exceptionally.

    Parameters:
    action - the action to perform
    executor - the executor to use for asynchronous execution
    Returns:
    the new CompletionStage
  • whenCompleteAsync

    CompletionStage<T> whenCompleteAsync(BiConsumer<? super T,? super Throwable> action,
                                         Executor executor)
    Returns a new CompletionStage with the same result or exception as this stage, that executes the given action using the supplied Executor when this stage completes.

    When this stage is complete, the given action is invoked with the result (or null if none) and the exception (or null if none) of this stage as arguments. The returned stage is completed when the action returns.

    Unlike method handleAsync, this method is not designed to translate completion outcomes, so the supplied action should not throw an exception. However, if it does, the following rules apply: If this stage completed normally but the supplied action throws an exception, then the returned stage completes exceptionally with the supplied action's exception. Or, if this stage completed exceptionally and the supplied action throws an exception, then the returned stage completes exceptionally with this stage's exception.

    Parameters:
    action - the action to perform
    executor - the executor to use for asynchronous execution
    Returns:
    the new CompletionStage