Class CompletableFutureUtils
CompletableFuture
.- Author:
- Jerry Lee (oldratlee at gmail dot com), HuHao (995483610 at qq dot com)
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T> CompletableFuture
<Void> acceptEitherSuccess
(CompletableFuture<? extends T> cfThis, CompletionStage<? extends T> other, Consumer<? super T> action) Returns a new CompletableFuture that, when either given stage success, is executed with the corresponding result as argument to the supplied action.static <T> CompletableFuture
<Void> acceptEitherSuccessAsync
(CompletableFuture<? extends T> cfThis, CompletionStage<? extends T> other, Consumer<? super T> action) Returns a new CompletableFuture that, when either given stage success, is executed using this CompletableFuture's default asynchronous execution facility, with the corresponding result as argument to the supplied action.static <T> CompletableFuture
<Void> acceptEitherSuccessAsync
(CompletableFuture<? extends T> cfThis, CompletionStage<? extends T> other, Consumer<? super T> action, Executor executor) Returns a new CompletableFuture that, when either given stage success, is executed using the supplied executor, with the corresponding result as argument to the supplied action.static CompletableFuture
<Void> allFastFailOf
(CompletionStage<?>... cfs) Returns a new CompletableFuture that is successful when all the given stages success; If any of the given stages complete exceptionally, then the returned CompletableFuture also does so *without* waiting other incomplete given stages, with a CompletionException holding this exception as its cause.static CompletableFuture
<Void> allOf
(CompletionStage<?>... cfs) Returns a new CompletableFuture that is completed when all the given stages complete; If any of the given stages complete exceptionally, then the returned CompletableFuture also does so, with a CompletionException holding this exception as its cause.static <T> CompletableFuture
<List<T>> allResultsFastFailOf
(CompletionStage<? extends T>... cfs) Returns a new CompletableFuture that is successful with the results in the same order of the given stages arguments when all the given stages success; If any of the given stages complete exceptionally, then the returned CompletableFuture also does so *without* waiting other incomplete given stages, with a CompletionException holding this exception as its cause.static <T> CompletableFuture
<List<T>> allResultsOf
(CompletionStage<? extends T>... cfs) Returns a new CompletableFuture with the results in the same order of the given stages arguments, the new CompletableFuture is completed when all the given stages complete; If any of the given stages complete exceptionally, then the returned CompletableFuture also does so, with a CompletionException holding this exception as its cause.static <T> CompletableFuture
<List<T>> allSuccessResultsOf
(T valueIfFailed, CompletionStage<? extends T>... cfs) Returns a new CompletableFuture that is successful with the results in the same order of the given stages arguments when all the given stages completed; If the given stage complete exceptionally, treat it successful with value valueIfFailed.static <T1,
T2> CompletableFuture <Tuple2<T1, T2>> allSuccessTupleOf
(CompletionStage<? extends T1> cf1, CompletionStage<? extends T2> cf2) Returns a new CompletableFuture that is successful with the results of the given stages arguments when all the given stages completed; If the given stage complete exceptionally, treat it successful with value valueIfFailed.static <T1,
T2, T3>
CompletableFuture<Tuple3<T1, T2, T3>> allSuccessTupleOf
(CompletionStage<? extends T1> cf1, CompletionStage<? extends T2> cf2, CompletionStage<? extends T3> cf3) Returns a new CompletableFuture that is successful with the results of the given stages arguments when all the given stages completed; If the given stage complete exceptionally, treat it successful with value valueIfFailed.static <T1,
T2, T3, T4>
CompletableFuture<Tuple4<T1, T2, T3, T4>> allSuccessTupleOf
(CompletionStage<? extends T1> cf1, CompletionStage<? extends T2> cf2, CompletionStage<? extends T3> cf3, CompletionStage<? extends T4> cf4) Returns a new CompletableFuture that is successful with the results of the given stages arguments when all the given stages completed; If the given stage complete exceptionally, treat it successful with value valueIfFailed.static <T1,
T2, T3, T4, T5>
CompletableFuture<Tuple5<T1, T2, T3, T4, T5>> allSuccessTupleOf
(CompletionStage<? extends T1> cf1, CompletionStage<? extends T2> cf2, CompletionStage<? extends T3> cf3, CompletionStage<? extends T4> cf4, CompletionStage<? extends T5> cf5) Returns a new CompletableFuture that is successful with the results of the given stages arguments when all the given stages completed; If the given stage complete exceptionally, treat it successful with value valueIfFailed.static <T1,
T2> CompletableFuture <Tuple2<T1, T2>> allTupleFastFailOf
(CompletionStage<? extends T1> cf1, CompletionStage<? extends T2> cf2) Returns a new CompletableFuture that is successful when the given stages success.static <T1,
T2, T3>
CompletableFuture<Tuple3<T1, T2, T3>> allTupleFastFailOf
(CompletionStage<? extends T1> cf1, CompletionStage<? extends T2> cf2, CompletionStage<? extends T3> cf3) Returns a new CompletableFuture that is successful when the given stages success.static <T1,
T2, T3, T4>
CompletableFuture<Tuple4<T1, T2, T3, T4>> allTupleFastFailOf
(CompletionStage<? extends T1> cf1, CompletionStage<? extends T2> cf2, CompletionStage<? extends T3> cf3, CompletionStage<? extends T4> cf4) Returns a new CompletableFuture that is successful when the given stages success.static <T1,
T2, T3, T4, T5>
CompletableFuture<Tuple5<T1, T2, T3, T4, T5>> allTupleFastFailOf
(CompletionStage<? extends T1> cf1, CompletionStage<? extends T2> cf2, CompletionStage<? extends T3> cf3, CompletionStage<? extends T4> cf4, CompletionStage<? extends T5> cf5) Returns a new CompletableFuture that is successful when the given stages success.static <T1,
T2> CompletableFuture <Tuple2<T1, T2>> allTupleOf
(CompletionStage<? extends T1> cf1, CompletionStage<? extends T2> cf2) Returns a new CompletableFuture that is completed when the given stages complete.static <T1,
T2, T3>
CompletableFuture<Tuple3<T1, T2, T3>> allTupleOf
(CompletionStage<? extends T1> cf1, CompletionStage<? extends T2> cf2, CompletionStage<? extends T3> cf3) Returns a new CompletableFuture that is completed when the given stages complete.static <T1,
T2, T3, T4>
CompletableFuture<Tuple4<T1, T2, T3, T4>> allTupleOf
(CompletionStage<? extends T1> cf1, CompletionStage<? extends T2> cf2, CompletionStage<? extends T3> cf3, CompletionStage<? extends T4> cf4) Returns a new CompletableFuture that is completed when the given stages complete.static <T1,
T2, T3, T4, T5>
CompletableFuture<Tuple5<T1, T2, T3, T4, T5>> allTupleOf
(CompletionStage<? extends T1> cf1, CompletionStage<? extends T2> cf2, CompletionStage<? extends T3> cf3, CompletionStage<? extends T4> cf4, CompletionStage<? extends T5> cf5) Returns a new CompletableFuture that is completed when the given stages complete.static <T> CompletableFuture
<T> anyOf
(CompletionStage<? extends T>... cfs) Returns a new CompletableFuture that is completed when any of the given stages complete, with the same result.static <T> CompletableFuture
<T> anySuccessOf
(CompletionStage<? extends T>... cfs) Returns a new CompletableFuture that is successful when any of the given stages success, with the same result.static <T,
U> CompletableFuture <U> applyToEitherSuccess
(CompletableFuture<? extends T> cfThis, CompletionStage<? extends T> other, Function<? super T, ? extends U> fn) Returns a new CompletableFuture that, when either given stage success, is executed with the corresponding result as argument to the supplied function.static <T,
U> CompletableFuture <U> applyToEitherSuccessAsync
(CompletableFuture<? extends T> cfThis, CompletionStage<? extends T> other, Function<? super T, ? extends U> fn) Returns a new CompletableFuture that, when either given stage success, is executed using this CompletableFuture's default asynchronous execution facility, with the corresponding result as argument to the supplied function.static <T,
U> CompletableFuture <U> applyToEitherSuccessAsync
(CompletableFuture<? extends T> cfThis, CompletionStage<? extends T> other, Function<? super T, ? extends U> fn, Executor executor) Returns a new CompletableFuture that, when either given stage success, is executed using the supplied executor, with the corresponding result as argument to the supplied function.static <T,
X extends Throwable, C extends CompletionStage<? super T>>
CReturns a new CompletionStage that, when given stage completes exceptionally with the given exceptionType, is executed with given stage's exception as the argument to the supplied function.static <T,
X extends Throwable, C extends CompletionStage<? super T>>
CcatchingAsync
(C cfThis, Class<X> exceptionType, Function<? super X, ? extends T> fallback) Returns a new CompletionStage that, when given stage completes exceptionally with the given exceptionType, is executed with given stage's exception as the argument to the supplied function, using the given stage's default asynchronous execution facility.static <T,
X extends Throwable, C extends CompletionStage<? super T>>
CcatchingAsync
(C cfThis, Class<X> exceptionType, Function<? super X, ? extends T> fallback, Executor executor) Returns a new CompletionStage that, when given stage completes exceptionally with the given exceptionType, is executed with given stage's exception as the argument to the supplied function, using the supplied Executor.static <T,
X extends Throwable, C extends CompletionStage<? super T>>
CcatchingCompose
(C cfThis, Class<X> exceptionType, Function<? super X, ? extends CompletionStage<T>> fallback) Returns a new CompletionStage that, when given stage completes exceptionally with the given exceptionType, is composed using the results of the supplied function applied to given stage's exception.static <T,
X extends Throwable, C extends CompletionStage<? super T>>
CcatchingComposeAsync
(C cfThis, Class<X> exceptionType, Function<? super X, ? extends CompletionStage<T>> fallback) Returns a new CompletionStage that, when given stage completes exceptionally with the given exceptionType, is composed using the results of the supplied function applied to given stage's exception, using given stage's default asynchronous execution facility.static <T,
X extends Throwable, C extends CompletionStage<? super T>>
CcatchingComposeAsync
(C cfThis, Class<X> exceptionType, Function<? super X, ? extends CompletionStage<T>> fallback, Executor executor) Returns a new CompletionStage that, when given stage completes exceptionally with the given exceptionType, is composed using the results of the supplied function applied to given's exception, using the supplied Executor.static <T,
C extends CompletableFuture<? super T>>
CcffuCompleteOnTimeout
(C cfThis, T value, long timeout, TimeUnit unit) Completes given CompletableFuture with the given value if not otherwise completed before the given timeout.static <T,
C extends CompletableFuture<? super T>>
CcffuCompleteOnTimeout
(C cfThis, T value, Executor executorWhenTimeout, long timeout, TimeUnit unit) Completes given CompletableFuture with the given value if not otherwise completed before the given timeout.static <C extends CompletableFuture<?>>
CcffuOrTimeout
(C cfThis, long timeout, TimeUnit unit) Exceptionally completes given CompletableFuture with aTimeoutException
if not otherwise completed before the given timeout.static <C extends CompletableFuture<?>>
CcffuOrTimeout
(C cfThis, Executor executorWhenTimeout, long timeout, TimeUnit unit) Exceptionally completes given CompletableFuture with aTimeoutException
if not otherwise completed before the given timeout.static <T> CompletableFuture<T>[]
completableFutureListToArray
(List<CompletableFuture<T>> cfList) A convenient util method for converting inputCompletableFuture
list to CompletableFuture array.static <T,
C extends CompletableFuture<? super T>>
CcompleteAsync
(C cfThis, Supplier<? extends T> supplier) Completes given CompletableFuture with the result of the given Supplier function invoked from an asynchronous task using the default executor.static <T,
C extends CompletableFuture<? super T>>
CcompleteAsync
(C cfThis, Supplier<? extends T> supplier, Executor executor) Completes given CompletableFuture with the result of the given Supplier function invoked from an asynchronous task using the given executor.static <T> CompletionStage
<T> completedStage
(T value) Returns a new CompletionStage that is already completed with the given value and supports only those methods in interfaceCompletionStage
.static <C extends CompletableFuture<?>>
CcompleteExceptionallyAsync
(C cfThis, Supplier<? extends Throwable> supplier) If not already completed, completes given CompletableFuture with the exception result of the given Supplier function invoked from an asynchronous task using the default executor.static <C extends CompletableFuture<?>>
CcompleteExceptionallyAsync
(C cfThis, Supplier<? extends Throwable> supplier, Executor executor) If not already completed, completes given CompletableFuture with the exception result of the given Supplier function invoked from an asynchronous task using the given executor.static <T,
C extends CompletableFuture<? super T>>
CcompleteOnTimeout
(C cfThis, T value, long timeout, TimeUnit unit) Completes given CompletableFuture with the given value if not otherwise completed before the given timeout.static <T> CompletableFuture
<T> copy
(CompletableFuture<T> cfThis) Returns a new CompletableFuture that is completed normally with the same value as this CompletableFuture when it completes normally.static Executor
Returns the default Executor used for async methods that do not specify an Executor.static Executor
delayedExecutor
(long delay, TimeUnit unit) Returns a new Executor that submits a task to the default executor after the given delay (or no delay if non-positive).static Executor
delayedExecutor
(long delay, TimeUnit unit, Executor executor) Returns a new Executor that submits a task to the given base executor after the given delay (or no delay if non-positive).static <T,
C extends CompletionStage<? super T>>
CexceptionallyAsync
(C cfThis, Function<Throwable, ? extends T> fn) Returns a new CompletionStage that, when given stage completes exceptionally, is executed with given stage's exception as the argument to the supplied function, using given stage's default asynchronous execution facility.static <T,
C extends CompletionStage<? super T>>
CexceptionallyAsync
(C cfThis, Function<Throwable, ? extends T> fn, Executor executor) Returns a new CompletionStage that, when given stage completes exceptionally, is executed with given stage's exception as the argument to the supplied function, using the supplied Executor.static <T,
C extends CompletionStage<? super T>>
CexceptionallyCompose
(C cfThis, Function<Throwable, ? extends CompletionStage<T>> fn) Returns a new CompletableFuture that, when given CompletableFuture completes exceptionally, is composed using the results of the supplied function applied to given stage's exception.static <T,
C extends CompletionStage<? super T>>
CexceptionallyComposeAsync
(C cfThis, Function<Throwable, ? extends CompletionStage<T>> fn) Returns a new CompletableFuture that, when given CompletableFuture completes exceptionally, is composed using the results of the supplied function applied to given stage's exception, using given CompletableFuture's default asynchronous execution facility.static <T,
C extends CompletionStage<? super T>>
CexceptionallyComposeAsync
(C cfThis, Function<Throwable, ? extends CompletionStage<T>> fn, Executor executor) Returns a new CompletableFuture that, when given CompletableFuture completes exceptionally, is composed using the results of the supplied function applied to given stage's exception, using the supplied Executor.static Throwable
exceptionNow
(Future<?> cfThis) Returns the exception thrown by the task, without waiting.static <T> CompletableFuture
<T> Returns a new CompletableFuture that is already completed exceptionally with the given exception.static <T> CompletionStage
<T> failedStage
(Throwable ex) Returns a new CompletionStage that is already completed exceptionally with the given exception and supports only those methods in interfaceCompletionStage
.static <T> T
getSuccessNow
(CompletableFuture<? extends T> cfThis, T valueIfNotSuccess) Returns the result value if the given stage is completed successfully, else returns the given valueIfNotSuccess.static <T> T
join
(CompletableFuture<T> cfThis, long timeout, TimeUnit unit) Waits if necessary for at most the given time for the computation to complete, and then retrieves its result value when complete, or throws an (unchecked) exception if completed exceptionally.static <T> CompletionStage
<T> minimalCompletionStage
(CompletableFuture<T> cfThis) Returns a new CompletionStage that is completed normally with the same value as given CompletableFuture when it completes normally, and cannot be independently completed or otherwise used in ways not defined by the methods of interfaceCompletionStage
.static <T> CompletableFuture
<List<T>> mostSuccessResultsOf
(T valueIfNotSuccess, long timeout, TimeUnit unit, CompletionStage<? extends T>... cfs) Returns a new CompletableFuture with the most results in the same order of the given stages arguments in the given time(timeout
, aka as many results as possible in the given time).static <T> CompletableFuture
<List<T>> mostSuccessResultsOf
(T valueIfNotSuccess, Executor executorWhenTimeout, long timeout, TimeUnit unit, CompletionStage<? extends T>... cfs) Returns a new CompletableFuture with the most results in the same order of the given stages arguments in the given time(timeout
, aka as many results as possible in the given time).static <T1,
T2> CompletableFuture <Tuple2<T1, T2>> mostSuccessTupleOf
(long timeout, TimeUnit unit, CompletionStage<? extends T1> cf1, CompletionStage<? extends T2> cf2) Returns a new CompletableFuture with the most results in the same order of the given stages arguments in the given time(timeout
, aka as many results as possible in the given time).static <T1,
T2, T3>
CompletableFuture<Tuple3<T1, T2, T3>> mostSuccessTupleOf
(long timeout, TimeUnit unit, CompletionStage<? extends T1> cf1, CompletionStage<? extends T2> cf2, CompletionStage<? extends T3> cf3) Returns a new CompletableFuture with the most results in the same order of the given stages arguments in the given time(timeout
, aka as many results as possible in the given time).static <T1,
T2, T3, T4>
CompletableFuture<Tuple4<T1, T2, T3, T4>> mostSuccessTupleOf
(long timeout, TimeUnit unit, CompletionStage<? extends T1> cf1, CompletionStage<? extends T2> cf2, CompletionStage<? extends T3> cf3, CompletionStage<? extends T4> cf4) Returns a new CompletableFuture with the most results in the same order of the given stages arguments in the given time(timeout
, aka as many results as possible in the given time).static <T1,
T2, T3, T4, T5>
CompletableFuture<Tuple5<T1, T2, T3, T4, T5>> mostSuccessTupleOf
(long timeout, TimeUnit unit, CompletionStage<? extends T1> cf1, CompletionStage<? extends T2> cf2, CompletionStage<? extends T3> cf3, CompletionStage<? extends T4> cf4, CompletionStage<? extends T5> cf5) Returns a new CompletableFuture with the most results in the same order of the given stages arguments in the given time(timeout
, aka as many results as possible in the given time).static <T1,
T2> CompletableFuture <Tuple2<T1, T2>> mostSuccessTupleOf
(Executor executorWhenTimeout, long timeout, TimeUnit unit, CompletionStage<? extends T1> cf1, CompletionStage<? extends T2> cf2) Returns a new CompletableFuture with the most results in the same order of the given stages arguments in the given time(timeout
, aka as many results as possible in the given time).static <T1,
T2, T3>
CompletableFuture<Tuple3<T1, T2, T3>> mostSuccessTupleOf
(Executor executorWhenTimeout, long timeout, TimeUnit unit, CompletionStage<? extends T1> cf1, CompletionStage<? extends T2> cf2, CompletionStage<? extends T3> cf3) Returns a new CompletableFuture with the most results in the same order of the given stages arguments in the given time(timeout
, aka as many results as possible in the given time).static <T1,
T2, T3, T4>
CompletableFuture<Tuple4<T1, T2, T3, T4>> mostSuccessTupleOf
(Executor executorWhenTimeout, long timeout, TimeUnit unit, CompletionStage<? extends T1> cf1, CompletionStage<? extends T2> cf2, CompletionStage<? extends T3> cf3, CompletionStage<? extends T4> cf4) Returns a new CompletableFuture with the most results in the same order of the given stages arguments in the given time(timeout
, aka as many results as possible in the given time).static <T1,
T2, T3, T4, T5>
CompletableFuture<Tuple5<T1, T2, T3, T4, T5>> mostSuccessTupleOf
(Executor executorWhenTimeout, long timeout, TimeUnit unit, CompletionStage<? extends T1> cf1, CompletionStage<? extends T2> cf2, CompletionStage<? extends T3> cf3, CompletionStage<? extends T4> cf4, CompletionStage<? extends T5> cf5) Returns a new CompletableFuture with the most results in the same order of the given stages arguments in the given time(timeout
, aka as many results as possible in the given time).static CompletableFuture
<Void> mRunAnyAsync
(Runnable... actions) Returns a new CompletableFuture that is asynchronously completed when any tasks running in the CompletableFuture's default asynchronous execution facility.static CompletableFuture
<Void> mRunAnyAsync
(Executor executor, Runnable... actions) Returns a new CompletableFuture that is asynchronously completed when any tasks running in the given executor complete.static CompletableFuture
<Void> mRunAnySuccessAsync
(Runnable... actions) Returns a new CompletableFuture that is asynchronously successful when any tasks running in the CompletableFuture's default asynchronous execution facility success.static CompletableFuture
<Void> mRunAnySuccessAsync
(Executor executor, Runnable... actions) Returns a new CompletableFuture that is asynchronously successful when any tasks running in the given executor success.static CompletableFuture
<Void> Returns a new CompletableFuture that is asynchronously completed by tasks running in the CompletableFuture's default asynchronous execution facility after runs the given actions.static CompletableFuture
<Void> Returns a new CompletableFuture that is asynchronously completed by tasks running in the given Executor after runs the given actions.static CompletableFuture
<Void> mRunFastFailAsync
(Runnable... actions) Returns a new CompletableFuture that is asynchronously completed by tasks running in the CompletableFuture's default asynchronous execution facility after runs the given actions.static CompletableFuture
<Void> mRunFastFailAsync
(Executor executor, Runnable... actions) Returns a new CompletableFuture that is asynchronously completed by tasks running in the given Executor after runs the given actions.static <T> CompletableFuture
<List<T>> mSupplyAllSuccessAsync
(T valueIfFailed, Executor executor, Supplier<? extends T>... suppliers) Returns a new CompletableFuture that is asynchronously completed by tasks running in the given Executor with the successfully values obtained by calling the given Suppliers in the same order of the given Suppliers arguments.static <T> CompletableFuture
<List<T>> mSupplyAllSuccessAsync
(T valueIfFailed, Supplier<? extends T>... suppliers) Returns a new CompletableFuture that is asynchronously completed by tasks running in the CompletableFuture's default asynchronous execution facility with the successful values obtained by calling the given Suppliers in the same order of the given Suppliers arguments.static <T> CompletableFuture
<T> mSupplyAnyAsync
(Executor executor, Supplier<? extends T>... suppliers) Returns a new CompletableFuture that is completed when any of tasks running in the given Executor by calling the given Suppliers complete, with the same result.static <T> CompletableFuture
<T> mSupplyAnyAsync
(Supplier<? extends T>... suppliers) Returns a new CompletableFuture that is completed when any of tasks running in the CompletableFuture's default asynchronous execution facility by calling the given Suppliers complete, with the same result.static <T> CompletableFuture
<T> mSupplyAnySuccessAsync
(Executor executor, Supplier<? extends T>... suppliers) Returns a new CompletableFuture that is asynchronously successful when any of tasks running in the given executor by calling the given Suppliers success, with the same result.static <T> CompletableFuture
<T> mSupplyAnySuccessAsync
(Supplier<? extends T>... suppliers) Returns a new CompletableFuture that is asynchronously successful when any of tasks running in the CompletableFuture's default asynchronous execution facility by calling the given Suppliers success, with the same result.static <T> CompletableFuture
<List<T>> mSupplyAsync
(Executor executor, Supplier<? extends T>... suppliers) Returns a new CompletableFuture that is asynchronously completed by tasks running in the given Executor with the values obtained by calling the given Suppliers in the same order of the given Suppliers arguments.static <T> CompletableFuture
<List<T>> mSupplyAsync
(Supplier<? extends T>... suppliers) Returns a new CompletableFuture that is asynchronously completed by tasks running in the CompletableFuture's default asynchronous execution facility with the values obtained by calling the given Suppliers in the same order of the given Suppliers arguments.static <T> CompletableFuture
<List<T>> mSupplyFastFailAsync
(Executor executor, Supplier<? extends T>... suppliers) Returns a new CompletableFuture that is asynchronously completed by tasks running in the given Executor with the values obtained by calling the given Suppliers in the same order of the given Suppliers arguments.static <T> CompletableFuture
<List<T>> mSupplyFastFailAsync
(Supplier<? extends T>... suppliers) Returns a new CompletableFuture that is asynchronously completed by tasks running in the CompletableFuture's default asynchronous execution facility with the values obtained by calling the given Suppliers in the same order of the given Suppliers arguments.static <T> CompletableFuture
<List<T>> mSupplyMostSuccessAsync
(T valueIfNotSuccess, long timeout, TimeUnit unit, Supplier<? extends T>... suppliers) Returns a new CompletableFuture that is asynchronously completed by tasks running in the CompletableFuture's default asynchronous execution facility with the most values obtained by calling the given Suppliers in the given time(timeout
, aka as many results as possible in the given time) in the same order of the given Suppliers arguments.static <T> CompletableFuture
<List<T>> mSupplyMostSuccessAsync
(T valueIfNotSuccess, Executor executor, long timeout, TimeUnit unit, Supplier<? extends T>... suppliers) Returns a new CompletableFuture that is asynchronously completed by tasks running in the given Executor with the most values obtained by calling the given Suppliers in the given time(timeout
, aka as many results as possible in the given time) in the same order of the given Suppliers arguments.static <U> CompletableFuture
<U> newIncompleteFuture
(CompletableFuture<?> cfThis) Returns a new incomplete CompletableFuture of the type to be returned by a CompletionStage method.static <C extends CompletableFuture<?>>
CExceptionally completes given CompletableFuture with aTimeoutException
if not otherwise completed before the given timeout.static <T,
C extends CompletionStage<? extends T>>
Cpeek
(C cfThis, BiConsumer<? super T, ? super Throwable> action) Peeks the result by executing the given action when given stage completes, returns the given stage.static <T,
C extends CompletionStage<? extends T>>
CpeekAsync
(C cfThis, BiConsumer<? super T, ? super Throwable> action) Peeks the result by executing the given action when given stage completes, executes the given action using given stage's default asynchronous execution facility, returns the given stage.static <T,
C extends CompletionStage<? extends T>>
CpeekAsync
(C cfThis, BiConsumer<? super T, ? super Throwable> action, Executor executor) Peeks the result by executing the given action when given stage completes, executes the given action using the supplied Executor, returns the given stage.static <T> T
Returns the computed result, without waiting.static CompletableFuture
<Void> runAfterBothFastFail
(CompletableFuture<?> cfThis, CompletionStage<?> other, Runnable action) Returns a new CompletableFuture that, when two given stages both complete normally, executes the given action.static CompletableFuture
<Void> runAfterBothFastFailAsync
(CompletableFuture<?> cfThis, CompletionStage<?> other, Runnable action) Returns a new CompletableFuture that, when two given stages both complete normally, executes the given action using CompletableFuture's default asynchronous execution facility.static CompletableFuture
<Void> runAfterBothFastFailAsync
(CompletableFuture<?> cfThis, CompletionStage<?> other, Runnable action, Executor executor) Returns a new CompletableFuture that, when two given stages both complete normally, executes the given action using the supplied executor.static CompletableFuture
<Void> runAfterEitherSuccess
(CompletableFuture<?> cfThis, CompletionStage<?> other, Runnable action) Returns a new CompletableFuture that, when either given stage success, executes the given action.static CompletableFuture
<Void> runAfterEitherSuccessAsync
(CompletableFuture<?> cfThis, CompletionStage<?> other, Runnable action) Returns a new CompletableFuture that, when either given stage success, executes the given action using CompletableFuture's default asynchronous execution facility.static CompletableFuture
<Void> runAfterEitherSuccessAsync
(CompletableFuture<?> cfThis, CompletionStage<?> other, Runnable action, Executor executor) Returns a new CompletableFuture that, when either given stage success, executes the given action using the supplied executor.static CffuState
Returns the computation state(CffuState
), this method is equivalent toCompletableFuture.state()
with java version compatibility logic, so you can invoke in oldjava 18-
.static <T,
U> CompletableFuture <Void> thenAcceptBothFastFail
(CompletableFuture<? extends T> cfThis, CompletionStage<? extends U> other, BiConsumer<? super T, ? super U> action) Returns a new CompletableFuture that, when tow given stage both complete normally, is executed with the two results as arguments to the supplied action.static <T,
U> CompletableFuture <Void> thenAcceptBothFastFailAsync
(CompletableFuture<? extends T> cfThis, CompletionStage<? extends U> other, BiConsumer<? super T, ? super U> action) Returns a new CompletableFuture that, when tow given stage both complete normally, is executed using CompletableFuture's default asynchronous execution facility, with the two results as arguments to the supplied action.static <T,
U> CompletableFuture <Void> thenAcceptBothFastFailAsync
(CompletableFuture<? extends T> cfThis, CompletionStage<? extends U> other, BiConsumer<? super T, ? super U> action, Executor executor) Returns a new CompletableFuture that, when tow given stage both complete normally, is executed using the supplied executor, with the two results as arguments to the supplied action.static <T,
U, V> CompletableFuture <V> thenCombineFastFail
(CompletableFuture<? extends T> cfThis, CompletionStage<? extends U> other, BiFunction<? super T, ? super U, ? extends V> fn) Returns a new CompletableFuture that, when tow given stage both complete normally, is executed with the two results as arguments to the supplied function.static <T,
U, V> CompletableFuture <V> thenCombineFastFailAsync
(CompletableFuture<? extends T> cfThis, CompletionStage<? extends U> other, BiFunction<? super T, ? super U, ? extends V> fn) Returns a new CompletableFuture that, when tow given stage both complete normally, is executed using CompletableFuture's default asynchronous execution facility, with the two results as arguments to the supplied function.static <T,
U, V> CompletableFuture <V> thenCombineFastFailAsync
(CompletableFuture<? extends T> cfThis, CompletionStage<? extends U> other, BiFunction<? super T, ? super U, ? extends V> fn, Executor executor) Returns a new CompletableFuture that, when tow given stage both complete normally, is executed using the supplied executor, with the two results as arguments to the supplied function.static <T> CompletableFuture
<Void> thenMAcceptAnyAsync
(CompletableFuture<? extends T> cfThis, Executor executor, Consumer<? super T>... actions) Returns a new CompletableFuture that, when the given stage completes normally, is executed using the given Executor, with the given stage's result as the argument to the given actions.static <T> CompletableFuture
<Void> thenMAcceptAnyAsync
(CompletableFuture<? extends T> cfThis, Consumer<? super T>... actions) Returns a new CompletableFuture that, when the given stage completes normally, is executed using the CompletableFuture's default asynchronous execution facility, with the given stage's result as the argument to the given actions.static <T> CompletableFuture
<Void> thenMAcceptAnySuccessAsync
(CompletableFuture<? extends T> cfThis, Executor executor, Consumer<? super T>... actions) Returns a new CompletableFuture that, when the given stage completes normally, is executed using the given Executor, with the given stage's result as the argument to the given actions.static <T> CompletableFuture
<Void> thenMAcceptAnySuccessAsync
(CompletableFuture<? extends T> cfThis, Consumer<? super T>... actions) Returns a new CompletableFuture that, when the given stage completes normally, is executed using the CompletableFuture's default asynchronous execution facility, with the given stage's result as the argument to the given actions.static <T> CompletableFuture
<Void> thenMAcceptAsync
(CompletableFuture<? extends T> cfThis, Executor executor, Consumer<? super T>... actions) Returns a new CompletableFuture that, when the given stage completes normally, is executed using the given Executor, with the given stage's result as the argument to the given actions.static <T> CompletableFuture
<Void> thenMAcceptAsync
(CompletableFuture<? extends T> cfThis, Consumer<? super T>... actions) Returns a new CompletableFuture that, when the given stage completes normally, is executed using the CompletableFuture's default asynchronous execution facility, with the given stage's result as the argument to the given actions.static <T> CompletableFuture
<Void> thenMAcceptFastFailAsync
(CompletableFuture<? extends T> cfThis, Executor executor, Consumer<? super T>... actions) Returns a new CompletableFuture that, when the given stage completes normally, is executed using the given Executor, with the given stage's result as the argument to the given actions.static <T> CompletableFuture
<Void> thenMAcceptFastFailAsync
(CompletableFuture<? extends T> cfThis, Consumer<? super T>... actions) Returns a new CompletableFuture that, when the given stage completes normally, is executed using the CompletableFuture's default asynchronous execution facility, with the given stage's result as the argument to the given actions.static <T,
U> CompletableFuture <List<U>> thenMApplyAllSuccessAsync
(CompletableFuture<? extends T> cfThis, U valueIfFailed, Executor executor, Function<? super T, ? extends U>... fns) Returns a new CompletableFuture that, when the given stage completes normally, is executed in the given Executor with the successful values obtained by calling the given Functions (with the given stage's result as the argument to the given functions) in the same order of the given Functions arguments.static <T,
U> CompletableFuture <List<U>> thenMApplyAllSuccessAsync
(CompletableFuture<? extends T> cfThis, U valueIfFailed, Function<? super T, ? extends U>... fns) Returns a new CompletableFuture that, when the given stage completes normally, is executed in the CompletableFuture's default asynchronous execution facility with the successful values obtained by calling the given Functions (with the given stage's result as the argument to the given functions) in the same order of the given Functions arguments.static <T,
U> CompletableFuture <U> thenMApplyAnyAsync
(CompletableFuture<? extends T> cfThis, Executor executor, Function<? super T, ? extends U>... fns) Returns a new CompletableFuture that, when the given stage completes normally, is executed using the given Executor, with any completed result obtained by calling the given Functions (with the given stage's result as the argument to the given functions).static <T,
U> CompletableFuture <U> thenMApplyAnyAsync
(CompletableFuture<? extends T> cfThis, Function<? super T, ? extends U>... fns) Returns a new CompletableFuture that, when the given stage completes normally, is executed using the CompletableFuture's default asynchronous execution facility, with any completed result obtained by calling the given Functions (with the given stage's result as the argument to the given functions).static <T,
U> CompletableFuture <U> thenMApplyAnySuccessAsync
(CompletableFuture<? extends T> cfThis, Executor executor, Function<? super T, ? extends U>... fns) Returns a new CompletableFuture that, when the given stage completes normally, is executed using the given Executor, with any successful value obtained by calling the given Functions (with the given stage's result as the argument to the given functions).static <T,
U> CompletableFuture <U> thenMApplyAnySuccessAsync
(CompletableFuture<? extends T> cfThis, Function<? super T, ? extends U>... fns) Returns a new CompletableFuture that, when the given stage completes normally, is executed using the CompletableFuture's default asynchronous execution facility, with any successful value obtained by calling the given Functions (with the given stage's result as the argument to the given functions).static <T,
U> CompletableFuture <List<U>> thenMApplyAsync
(CompletableFuture<? extends T> cfThis, Executor executor, Function<? super T, ? extends U>... fns) Returns a new CompletableFuture that, when the given stage completes normally, is executed using the given Executor, with the values obtained by calling the given Functions (with the given stage's result as the argument to the given functions) in the same order of the given Functions arguments.static <T,
U> CompletableFuture <List<U>> thenMApplyAsync
(CompletableFuture<? extends T> cfThis, Function<? super T, ? extends U>... fns) Returns a new CompletableFuture that, when the given stage completes normally, is executed using the CompletableFuture's default asynchronous execution facility, with the values obtained by calling the given Functions (with the given stage's result as the argument to the given functions) in the same order of the given Functions arguments.static <T,
U> CompletableFuture <List<U>> thenMApplyFastFailAsync
(CompletableFuture<? extends T> cfThis, Executor executor, Function<? super T, ? extends U>... fns) Returns a new CompletableFuture that, when the given stage completes normally, is executed using the given Executor, with the values obtained by calling the given Functions (with the given stage's result as the argument to the given functions) in the same order of the given Functions arguments.static <T,
U> CompletableFuture <List<U>> thenMApplyFastFailAsync
(CompletableFuture<? extends T> cfThis, Function<? super T, ? extends U>... fns) Returns a new CompletableFuture that, when the given stage completes normally, is executed using the CompletableFuture's default asynchronous execution facility, with the values obtained by calling the given Functions (with the given stage's result as the argument to the given functions) in the same order of the given Functions arguments.static <T,
U> CompletableFuture <List<U>> thenMApplyMostSuccessAsync
(CompletableFuture<? extends T> cfThis, U valueIfNotSuccess, long timeout, TimeUnit unit, Function<? super T, ? extends U>... fns) Returns a new CompletableFuture that, when the given stage completes normally, is executed using the CompletableFuture's default asynchronous execution facility, with the most values obtained by calling the given Functions (with the given stage's result as the argument to the given functions) in the given time(timeout
, aka as many results as possible in the given time) in the same order of the given Functions arguments.static <T,
U> CompletableFuture <List<U>> thenMApplyMostSuccessAsync
(CompletableFuture<? extends T> cfThis, U valueIfNotSuccess, Executor executor, long timeout, TimeUnit unit, Function<? super T, ? extends U>... fns) Returns a new CompletableFuture that, when the given stage completes normally, is executed using the given Executor, with the most values obtained by calling the given Functions (with the given stage's result as the argument to the given functions) in the given time(timeout
, aka as many results as possible in the given time) in the same order of the given Functions arguments.static CompletableFuture
<Void> thenMRunAnyAsync
(CompletableFuture<?> cfThis, Runnable... actions) Returns a new CompletableFuture that, when the given stage completes normally, executes the given actions using the CompletableFuture's default asynchronous execution facility.static CompletableFuture
<Void> thenMRunAnyAsync
(CompletableFuture<?> cfThis, Executor executor, Runnable... actions) Returns a new CompletableFuture that, when the given stage completes normally, executes the given actions using the given Executor.static CompletableFuture
<Void> thenMRunAnySuccessAsync
(CompletableFuture<?> cfThis, Runnable... actions) Returns a new CompletableFuture that, when the given stage completes normally, executes the given actions using the CompletableFuture's default asynchronous execution facility.static CompletableFuture
<Void> thenMRunAnySuccessAsync
(CompletableFuture<?> cfThis, Executor executor, Runnable... actions) Returns a new CompletableFuture that, when the given stage completes normally, executes the given actions using the given Executor.static CompletableFuture
<Void> thenMRunAsync
(CompletableFuture<?> cfThis, Runnable... actions) Returns a new CompletableFuture that, when the given stage completes normally, executes the given actions using the CompletableFuture's default asynchronous execution facility.static CompletableFuture
<Void> thenMRunAsync
(CompletableFuture<?> cfThis, Executor executor, Runnable... actions) Returns a new CompletableFuture that, when the given stage completes normally, executes the given actions using the given Executor.static CompletableFuture
<Void> thenMRunFastFailAsync
(CompletableFuture<?> cfThis, Runnable... actions) Returns a new CompletableFuture that, when the given stage completes normally, executes the given actions using the CompletableFuture's default asynchronous execution facility.static CompletableFuture
<Void> thenMRunFastFailAsync
(CompletableFuture<?> cfThis, Executor executor, Runnable... actions) Returns a new CompletableFuture that, when the given stage completes normally, executes the given actions using the given Executor.static <T,
U1, U2>
CompletableFuture<Tuple2<U1, U2>> thenTupleMApplyAllSuccessAsync
(CompletableFuture<? extends T> cfThis, Executor executor, Function<? super T, ? extends U1> fn1, Function<? super T, ? extends U2> fn2) Returns a new CompletableFuture that, when the given stage completes normally, is executed in the given Executor with the successful values obtained by calling the given Functions (with the given stage's result as the argument to the given functions) in the same order of the given Functions arguments.static <T,
U1, U2, U3>
CompletableFuture<Tuple3<U1, U2, U3>> thenTupleMApplyAllSuccessAsync
(CompletableFuture<? extends T> cfThis, Executor executor, Function<? super T, ? extends U1> fn1, Function<? super T, ? extends U2> fn2, Function<? super T, ? extends U3> fn3) Returns a new CompletableFuture that, when the given stage completes normally, is executed in the given Executor with the successful values obtained by calling the given Functions (with the given stage's result as the argument to the given functions) in the same order of the given Functions arguments.static <T,
U1, U2, U3, U4>
CompletableFuture<Tuple4<U1, U2, U3, U4>> thenTupleMApplyAllSuccessAsync
(CompletableFuture<? extends T> cfThis, Executor executor, Function<? super T, ? extends U1> fn1, Function<? super T, ? extends U2> fn2, Function<? super T, ? extends U3> fn3, Function<? super T, ? extends U4> fn4) Returns a new CompletableFuture that, when the given stage completes normally, is executed in the given Executor with the successful values obtained by calling the given Functions (with the given stage's result as the argument to the given functions) in the same order of the given Functions arguments.static <T,
U1, U2, U3, U4, U5>
CompletableFuture<Tuple5<U1, U2, U3, U4, U5>> thenTupleMApplyAllSuccessAsync
(CompletableFuture<? extends T> cfThis, Executor executor, Function<? super T, ? extends U1> fn1, Function<? super T, ? extends U2> fn2, Function<? super T, ? extends U3> fn3, Function<? super T, ? extends U4> fn4, Function<? super T, ? extends U5> fn5) Returns a new CompletableFuture that, when the given stage completes normally, is executed in the given Executor with the successful values obtained by calling the given Functions (with the given stage's result as the argument to the given functions) in the same order of the given Functions arguments.static <T,
U1, U2>
CompletableFuture<Tuple2<U1, U2>> thenTupleMApplyAllSuccessAsync
(CompletableFuture<? extends T> cfThis, Function<? super T, ? extends U1> fn1, Function<? super T, ? extends U2> fn2) Returns a new CompletableFuture that, when the given stage completes normally, is executed in the CompletableFuture's default asynchronous execution facility with the successful values obtained by calling the given Functions (with the given stage's result as the argument to the given functions).static <T,
U1, U2, U3>
CompletableFuture<Tuple3<U1, U2, U3>> thenTupleMApplyAllSuccessAsync
(CompletableFuture<? extends T> cfThis, Function<? super T, ? extends U1> fn1, Function<? super T, ? extends U2> fn2, Function<? super T, ? extends U3> fn3) Returns a new CompletableFuture that, when the given stage completes normally, is executed in the CompletableFuture's default asynchronous execution facility with the successful values obtained by calling the given Functions (with the given stage's result as the argument to the given functions) in the same order of the given Functions arguments.static <T,
U1, U2, U3, U4>
CompletableFuture<Tuple4<U1, U2, U3, U4>> thenTupleMApplyAllSuccessAsync
(CompletableFuture<? extends T> cfThis, Function<? super T, ? extends U1> fn1, Function<? super T, ? extends U2> fn2, Function<? super T, ? extends U3> fn3, Function<? super T, ? extends U4> fn4) Returns a new CompletableFuture that, when the given stage completes normally, is executed in the CompletableFuture's default asynchronous execution facility with the successful values obtained by calling the given Functions (with the given stage's result as the argument to the given functions) in the same order of the given Functions arguments.static <T,
U1, U2, U3, U4, U5>
CompletableFuture<Tuple5<U1, U2, U3, U4, U5>> thenTupleMApplyAllSuccessAsync
(CompletableFuture<? extends T> cfThis, Function<? super T, ? extends U1> fn1, Function<? super T, ? extends U2> fn2, Function<? super T, ? extends U3> fn3, Function<? super T, ? extends U4> fn4, Function<? super T, ? extends U5> fn5) Returns a new CompletableFuture that, when the given stage completes normally, is executed in the CompletableFuture's default asynchronous execution facility with the successful values obtained by calling the given Functions (with the given stage's result as the argument to the given functions) in the same order of the given Functions arguments.static <T,
U1, U2>
CompletableFuture<Tuple2<U1, U2>> thenTupleMApplyAsync
(CompletableFuture<? extends T> cfThis, Executor executor, Function<? super T, ? extends U1> fn1, Function<? super T, ? extends U2> fn2) Returns a new CompletableFuture that, when the given stage completes normally, is executed using the given Executor, with the values obtained by calling the given Functions (with the given stage's result as the argument to the given functions) in the same order of the given Functions arguments.static <T,
U1, U2, U3>
CompletableFuture<Tuple3<U1, U2, U3>> thenTupleMApplyAsync
(CompletableFuture<? extends T> cfThis, Executor executor, Function<? super T, ? extends U1> fn1, Function<? super T, ? extends U2> fn2, Function<? super T, ? extends U3> fn3) Returns a new CompletableFuture that, when the given stage completes normally, is executed using the given Executor, with the values obtained by calling the given Functions (with the given stage's result as the argument to the given functions) in the same order of the given Functions arguments.static <T,
U1, U2, U3, U4>
CompletableFuture<Tuple4<U1, U2, U3, U4>> thenTupleMApplyAsync
(CompletableFuture<? extends T> cfThis, Executor executor, Function<? super T, ? extends U1> fn1, Function<? super T, ? extends U2> fn2, Function<? super T, ? extends U3> fn3, Function<? super T, ? extends U4> fn4) Returns a new CompletableFuture that, when the given stage completes normally, is executed using the given Executor, with the values obtained by calling the given Functions (with the given stage's result as the argument to the given functions) in the same order of the given Functions arguments.static <T,
U1, U2, U3, U4, U5>
CompletableFuture<Tuple5<U1, U2, U3, U4, U5>> thenTupleMApplyAsync
(CompletableFuture<? extends T> cfThis, Executor executor, Function<? super T, ? extends U1> fn1, Function<? super T, ? extends U2> fn2, Function<? super T, ? extends U3> fn3, Function<? super T, ? extends U4> fn4, Function<? super T, ? extends U5> fn5) Returns a new CompletableFuture that, when the given stage completes normally, is executed using the given Executor, with the values obtained by calling the given Functions (with the given stage's result as the argument to the given functions) in the same order of the given Functions arguments.static <T,
U1, U2>
CompletableFuture<Tuple2<U1, U2>> thenTupleMApplyAsync
(CompletableFuture<? extends T> cfThis, Function<? super T, ? extends U1> fn1, Function<? super T, ? extends U2> fn2) Returns a new CompletableFuture that, when the given stage completes normally, is executed using the CompletableFuture's default asynchronous execution facility, with the values obtained by calling the given Functions (with the given stage's result as the argument to the given functions) in the same order of the given Functions arguments.static <T,
U1, U2, U3>
CompletableFuture<Tuple3<U1, U2, U3>> thenTupleMApplyAsync
(CompletableFuture<? extends T> cfThis, Function<? super T, ? extends U1> fn1, Function<? super T, ? extends U2> fn2, Function<? super T, ? extends U3> fn3) Returns a new CompletableFuture that, when the given stage completes normally, is executed using the CompletableFuture's default asynchronous execution facility, with the values obtained by calling the given Functions (with the given stage's result as the argument to the given functions) in the same order of the given Functions arguments.static <T,
U1, U2, U3, U4>
CompletableFuture<Tuple4<U1, U2, U3, U4>> thenTupleMApplyAsync
(CompletableFuture<? extends T> cfThis, Function<? super T, ? extends U1> fn1, Function<? super T, ? extends U2> fn2, Function<? super T, ? extends U3> fn3, Function<? super T, ? extends U4> fn4) Returns a new CompletableFuture that, when the given stage completes normally, is executed using the CompletableFuture's default asynchronous execution facility, with the values obtained by calling the given Functions (with the given stage's result as the argument to the given functions) in the same order of the given Functions arguments.static <T,
U1, U2, U3, U4, U5>
CompletableFuture<Tuple5<U1, U2, U3, U4, U5>> thenTupleMApplyAsync
(CompletableFuture<? extends T> cfThis, Function<? super T, ? extends U1> fn1, Function<? super T, ? extends U2> fn2, Function<? super T, ? extends U3> fn3, Function<? super T, ? extends U4> fn4, Function<? super T, ? extends U5> fn5) Returns a new CompletableFuture that, when the given stage completes normally, is executed using the CompletableFuture's default asynchronous execution facility, with the values obtained by calling the given Functions (with the given stage's result as the argument to the given functions) in the same order of the given Functions arguments.static <T,
U1, U2>
CompletableFuture<Tuple2<U1, U2>> thenTupleMApplyFastFailAsync
(CompletableFuture<? extends T> cfThis, Executor executor, Function<? super T, ? extends U1> fn1, Function<? super T, ? extends U2> fn2) Returns a new CompletableFuture that, when the given stage completes normally, is executed using the given Executor, with the values obtained by calling the given Functions (with the given stage's result as the argument to the given functions) in the same order of the given Functions arguments.static <T,
U1, U2, U3>
CompletableFuture<Tuple3<U1, U2, U3>> thenTupleMApplyFastFailAsync
(CompletableFuture<? extends T> cfThis, Executor executor, Function<? super T, ? extends U1> fn1, Function<? super T, ? extends U2> fn2, Function<? super T, ? extends U3> fn3) Returns a new CompletableFuture that, when the given stage completes normally, is executed using the given Executor, with the values obtained by calling the given Functions (with the given stage's result as the argument to the given functions) in the same order of the given Functions arguments.static <T,
U1, U2, U3, U4>
CompletableFuture<Tuple4<U1, U2, U3, U4>> thenTupleMApplyFastFailAsync
(CompletableFuture<? extends T> cfThis, Executor executor, Function<? super T, ? extends U1> fn1, Function<? super T, ? extends U2> fn2, Function<? super T, ? extends U3> fn3, Function<? super T, ? extends U4> fn4) Returns a new CompletableFuture that, when the given stage completes normally, is executed using the given Executor, with the values obtained by calling the given Functions (with the given stage's result as the argument to the given functions) in the same order of the given Functions arguments.static <T,
U1, U2, U3, U4, U5>
CompletableFuture<Tuple5<U1, U2, U3, U4, U5>> thenTupleMApplyFastFailAsync
(CompletableFuture<? extends T> cfThis, Executor executor, Function<? super T, ? extends U1> fn1, Function<? super T, ? extends U2> fn2, Function<? super T, ? extends U3> fn3, Function<? super T, ? extends U4> fn4, Function<? super T, ? extends U5> fn5) Returns a new CompletableFuture that, when the given stage completes normally, is executed using the given Executor, with the values obtained by calling the given Functions (with the given stage's result as the argument to the given functions) in the same order of the given Functions arguments.static <T,
U1, U2>
CompletableFuture<Tuple2<U1, U2>> thenTupleMApplyFastFailAsync
(CompletableFuture<? extends T> cfThis, Function<? super T, ? extends U1> fn1, Function<? super T, ? extends U2> fn2) Returns a new CompletableFuture that, when the given stage completes normally, is executed using the CompletableFuture's default asynchronous execution facility, with the values obtained by calling the given Functions (with the given stage's result as the argument to the given functions) in the same order of the given Functions arguments.static <T,
U1, U2, U3>
CompletableFuture<Tuple3<U1, U2, U3>> thenTupleMApplyFastFailAsync
(CompletableFuture<? extends T> cfThis, Function<? super T, ? extends U1> fn1, Function<? super T, ? extends U2> fn2, Function<? super T, ? extends U3> fn3) Returns a new CompletableFuture that, when the given stage completes normally, is executed using the CompletableFuture's default asynchronous execution facility, with the values obtained by calling the given Functions (with the given stage's result as the argument to the given functions) in the same order of the given Functions arguments.static <T,
U1, U2, U3, U4>
CompletableFuture<Tuple4<U1, U2, U3, U4>> thenTupleMApplyFastFailAsync
(CompletableFuture<? extends T> cfThis, Function<? super T, ? extends U1> fn1, Function<? super T, ? extends U2> fn2, Function<? super T, ? extends U3> fn3, Function<? super T, ? extends U4> fn4) Returns a new CompletableFuture that, when the given stage completes normally, is executed using the CompletableFuture's default asynchronous execution facility, with the values obtained by calling the given Functions (with the given stage's result as the argument to the given functions) in the same order of the given Functions arguments.static <T,
U1, U2, U3, U4, U5>
CompletableFuture<Tuple5<U1, U2, U3, U4, U5>> thenTupleMApplyFastFailAsync
(CompletableFuture<? extends T> cfThis, Function<? super T, ? extends U1> fn1, Function<? super T, ? extends U2> fn2, Function<? super T, ? extends U3> fn3, Function<? super T, ? extends U4> fn4, Function<? super T, ? extends U5> fn5) Returns a new CompletableFuture that, when the given stage completes normally, is executed using the CompletableFuture's default asynchronous execution facility, with the values obtained by calling the given Functions (with the given stage's result as the argument to the given functions) in the same order of the given Functions arguments.static <T,
U1, U2>
CompletableFuture<Tuple2<U1, U2>> thenTupleMApplyMostSuccessAsync
(CompletableFuture<? extends T> cfThis, long timeout, TimeUnit unit, Function<? super T, ? extends U1> fn1, Function<? super T, ? extends U2> fn2) Returns a new CompletableFuture that, when the given stage completes normally, is executed using the CompletableFuture's default asynchronous execution facility, with the most values obtained by calling the given Functions (with the given stage's result as the argument to the given functions) in the given time(timeout
, aka as many results as possible in the given time) in the same order of the given Functions arguments.static <T,
U1, U2, U3>
CompletableFuture<Tuple3<U1, U2, U3>> thenTupleMApplyMostSuccessAsync
(CompletableFuture<? extends T> cfThis, long timeout, TimeUnit unit, Function<? super T, ? extends U1> fn1, Function<? super T, ? extends U2> fn2, Function<? super T, ? extends U3> fn3) Returns a new CompletableFuture that, when the given stage completes normally, is executed using the CompletableFuture's default asynchronous execution facility, with the most values obtained by calling the given Functions (with the given stage's result as the argument to the given functions) in the given time(timeout
, aka as many results as possible in the given time) in the same order of the given Functions arguments.static <T,
U1, U2, U3, U4>
CompletableFuture<Tuple4<U1, U2, U3, U4>> thenTupleMApplyMostSuccessAsync
(CompletableFuture<? extends T> cfThis, long timeout, TimeUnit unit, Function<? super T, ? extends U1> fn1, Function<? super T, ? extends U2> fn2, Function<? super T, ? extends U3> fn3, Function<? super T, ? extends U4> fn4) Returns a new CompletableFuture that, when the given stage completes normally, is executed using the CompletableFuture's default asynchronous execution facility, with the most values obtained by calling the given Functions (with the given stage's result as the argument to the given functions) in the given time(timeout
, aka as many results as possible in the given time) in the same order of the given Functions arguments.static <T,
U1, U2, U3, U4, U5>
CompletableFuture<Tuple5<U1, U2, U3, U4, U5>> thenTupleMApplyMostSuccessAsync
(CompletableFuture<? extends T> cfThis, long timeout, TimeUnit unit, Function<? super T, ? extends U1> fn1, Function<? super T, ? extends U2> fn2, Function<? super T, ? extends U3> fn3, Function<? super T, ? extends U4> fn4, Function<? super T, ? extends U5> fn5) Returns a new CompletableFuture that, when the given stage completes normally, is executed using the CompletableFuture's default asynchronous execution facility, with the most values obtained by calling the given Functions (with the given stage's result as the argument to the given functions) in the given time(timeout
, aka as many results as possible in the given time) in the same order of the given Functions arguments.static <T,
U1, U2>
CompletableFuture<Tuple2<U1, U2>> thenTupleMApplyMostSuccessAsync
(CompletableFuture<? extends T> cfThis, Executor executor, long timeout, TimeUnit unit, Function<? super T, ? extends U1> fn1, Function<? super T, ? extends U2> fn2) Returns a new CompletableFuture that, when the given stage completes normally, is executed using the given Executor, with the most values obtained by calling the given Functions (with the given stage's result as the argument to the given functions) in the given time(timeout
, aka as many results as possible in the given time) in the same order of the given Functions arguments.static <T,
U1, U2, U3>
CompletableFuture<Tuple3<U1, U2, U3>> thenTupleMApplyMostSuccessAsync
(CompletableFuture<? extends T> cfThis, Executor executor, long timeout, TimeUnit unit, Function<? super T, ? extends U1> fn1, Function<? super T, ? extends U2> fn2, Function<? super T, ? extends U3> fn3) Returns a new CompletableFuture that, when the given stage completes normally, is executed using the given Executor, with the most values obtained by calling the given Functions (with the given stage's result as the argument to the given functions) in the given time(timeout
, aka as many results as possible in the given time) in the same order of the given Functions arguments.static <T,
U1, U2, U3, U4>
CompletableFuture<Tuple4<U1, U2, U3, U4>> thenTupleMApplyMostSuccessAsync
(CompletableFuture<? extends T> cfThis, Executor executor, long timeout, TimeUnit unit, Function<? super T, ? extends U1> fn1, Function<? super T, ? extends U2> fn2, Function<? super T, ? extends U3> fn3, Function<? super T, ? extends U4> fn4) Returns a new CompletableFuture that, when the given stage completes normally, is executed using the given Executor, with the most values obtained by calling the given Functions (with the given stage's result as the argument to the given functions) in the given time(timeout
, aka as many results as possible in the given time) in the same order of the given Functions arguments.static <T,
U1, U2, U3, U4, U5>
CompletableFuture<Tuple5<U1, U2, U3, U4, U5>> thenTupleMApplyMostSuccessAsync
(CompletableFuture<? extends T> cfThis, Executor executor, long timeout, TimeUnit unit, Function<? super T, ? extends U1> fn1, Function<? super T, ? extends U2> fn2, Function<? super T, ? extends U3> fn3, Function<? super T, ? extends U4> fn4, Function<? super T, ? extends U5> fn5) Returns a new CompletableFuture that, when the given stage completes normally, is executed using the given Executor, with the most values obtained by calling the given Functions (with the given stage's result as the argument to the given functions) in the given time(timeout
, aka as many results as possible in the given time) in the same order of the given Functions arguments.static <T> CompletableFuture<T>[]
toCompletableFutureArray
(CompletionStage<T>... stages) A convenient util method for converting inputCompletionStage
(includingCffu
/CompletableFuture
) array element byCompletionStage.toCompletableFuture()
.static <T1,
T2> CompletableFuture <Tuple2<T1, T2>> tupleMSupplyAllSuccessAsync
(Executor executor, Supplier<? extends T1> supplier1, Supplier<? extends T2> supplier2) Returns a new CompletableFuture that is asynchronously completed by tasks running in the given executor with the successfully values obtained by calling the given Suppliers in the same order of the given Suppliers arguments.static <T1,
T2, T3>
CompletableFuture<Tuple3<T1, T2, T3>> tupleMSupplyAllSuccessAsync
(Executor executor, Supplier<? extends T1> supplier1, Supplier<? extends T2> supplier2, Supplier<? extends T3> supplier3) Returns a new CompletableFuture that is asynchronously completed by tasks running in the given executor with the successfully values obtained by calling the given Suppliers in the same order of the given Suppliers arguments.static <T1,
T2, T3, T4>
CompletableFuture<Tuple4<T1, T2, T3, T4>> tupleMSupplyAllSuccessAsync
(Executor executor, Supplier<? extends T1> supplier1, Supplier<? extends T2> supplier2, Supplier<? extends T3> supplier3, Supplier<? extends T4> supplier4) Returns a new CompletableFuture that is asynchronously completed by tasks running in the given executor with the successfully values obtained by calling the given Suppliers in the same order of the given Suppliers arguments.static <T1,
T2, T3, T4, T5>
CompletableFuture<Tuple5<T1, T2, T3, T4, T5>> tupleMSupplyAllSuccessAsync
(Executor executor, Supplier<? extends T1> supplier1, Supplier<? extends T2> supplier2, Supplier<? extends T3> supplier3, Supplier<? extends T4> supplier4, Supplier<? extends T5> supplier5) Returns a new CompletableFuture that is asynchronously completed by tasks running in the given executor with the successfully values obtained by calling the given Suppliers in the same order of the given Suppliers arguments.static <T1,
T2> CompletableFuture <Tuple2<T1, T2>> tupleMSupplyAllSuccessAsync
(Supplier<? extends T1> supplier1, Supplier<? extends T2> supplier2) Returns a new CompletableFuture that is asynchronously completed by tasks running in the CompletableFuture's default asynchronous execution facility with the successful values obtained by calling the given Suppliers in the same order of the given Suppliers arguments.static <T1,
T2, T3>
CompletableFuture<Tuple3<T1, T2, T3>> tupleMSupplyAllSuccessAsync
(Supplier<? extends T1> supplier1, Supplier<? extends T2> supplier2, Supplier<? extends T3> supplier3) Returns a new CompletableFuture that is asynchronously completed by tasks running in the CompletableFuture's default asynchronous execution facility with the successful values obtained by calling the given Suppliers in the same order of the given Suppliers arguments.static <T1,
T2, T3, T4>
CompletableFuture<Tuple4<T1, T2, T3, T4>> tupleMSupplyAllSuccessAsync
(Supplier<? extends T1> supplier1, Supplier<? extends T2> supplier2, Supplier<? extends T3> supplier3, Supplier<? extends T4> supplier4) Returns a new CompletableFuture that is asynchronously completed by tasks running in the CompletableFuture's default asynchronous execution facility with the successful values obtained by calling the given Suppliers in the same order of the given Suppliers arguments.static <T1,
T2, T3, T4, T5>
CompletableFuture<Tuple5<T1, T2, T3, T4, T5>> tupleMSupplyAllSuccessAsync
(Supplier<? extends T1> supplier1, Supplier<? extends T2> supplier2, Supplier<? extends T3> supplier3, Supplier<? extends T4> supplier4, Supplier<? extends T5> supplier5) Returns a new CompletableFuture that is asynchronously completed by tasks running in the CompletableFuture's default asynchronous execution facility with the successful values obtained by calling the given Suppliers in the same order of the given Suppliers arguments.static <T1,
T2> CompletableFuture <Tuple2<T1, T2>> tupleMSupplyAsync
(Executor executor, Supplier<? extends T1> supplier1, Supplier<? extends T2> supplier2) Returns a new CompletableFuture that is asynchronously completed by tasks running in the given Executor with the values obtained by calling the given Suppliers in the same order of the given Suppliers arguments.static <T1,
T2, T3>
CompletableFuture<Tuple3<T1, T2, T3>> tupleMSupplyAsync
(Executor executor, Supplier<? extends T1> supplier1, Supplier<? extends T2> supplier2, Supplier<? extends T3> supplier3) Returns a new CompletableFuture that is asynchronously completed by tasks running in the given Executor with the values obtained by calling the given Suppliers in the same order of the given Suppliers arguments.static <T1,
T2, T3, T4>
CompletableFuture<Tuple4<T1, T2, T3, T4>> tupleMSupplyAsync
(Executor executor, Supplier<? extends T1> supplier1, Supplier<? extends T2> supplier2, Supplier<? extends T3> supplier3, Supplier<? extends T4> supplier4) Returns a new CompletableFuture that is asynchronously completed by tasks running in the given Executor with the values obtained by calling the given Suppliers in the same order of the given Suppliers arguments.static <T1,
T2, T3, T4, T5>
CompletableFuture<Tuple5<T1, T2, T3, T4, T5>> tupleMSupplyAsync
(Executor executor, Supplier<? extends T1> supplier1, Supplier<? extends T2> supplier2, Supplier<? extends T3> supplier3, Supplier<? extends T4> supplier4, Supplier<? extends T5> supplier5) Returns a new CompletableFuture that is asynchronously completed by tasks running in the given Executor with the values obtained by calling the given Suppliers in the same order of the given Suppliers arguments.static <T1,
T2> CompletableFuture <Tuple2<T1, T2>> tupleMSupplyAsync
(Supplier<? extends T1> supplier1, Supplier<? extends T2> supplier2) Returns a new CompletableFuture that is asynchronously completed by tasks running in the CompletableFuture's default asynchronous execution facility with the values obtained by calling the given Suppliers in the same order of the given Suppliers arguments.static <T1,
T2, T3>
CompletableFuture<Tuple3<T1, T2, T3>> tupleMSupplyAsync
(Supplier<? extends T1> supplier1, Supplier<? extends T2> supplier2, Supplier<? extends T3> supplier3) Returns a new CompletableFuture that is asynchronously completed by tasks running in the CompletableFuture's default asynchronous execution facility with the values obtained by calling the given Suppliers in the same order of the given Suppliers arguments.static <T1,
T2, T3, T4>
CompletableFuture<Tuple4<T1, T2, T3, T4>> tupleMSupplyAsync
(Supplier<? extends T1> supplier1, Supplier<? extends T2> supplier2, Supplier<? extends T3> supplier3, Supplier<? extends T4> supplier4) Returns a new CompletableFuture that is asynchronously completed by tasks running in the CompletableFuture's default asynchronous execution facility with the values obtained by calling the given Suppliers in the same order of the given Suppliers arguments.static <T1,
T2, T3, T4, T5>
CompletableFuture<Tuple5<T1, T2, T3, T4, T5>> tupleMSupplyAsync
(Supplier<? extends T1> supplier1, Supplier<? extends T2> supplier2, Supplier<? extends T3> supplier3, Supplier<? extends T4> supplier4, Supplier<? extends T5> supplier5) Returns a new CompletableFuture that is asynchronously completed by tasks running in the CompletableFuture's default asynchronous execution facility with the values obtained by calling the given Suppliers in the same order of the given Suppliers arguments.static <T1,
T2> CompletableFuture <Tuple2<T1, T2>> tupleMSupplyFastFailAsync
(Executor executor, Supplier<? extends T1> supplier1, Supplier<? extends T2> supplier2) Returns a new CompletableFuture that is asynchronously completed by tasks running in the given Executor with the values obtained by calling the given Suppliers in the same order of the given Suppliers arguments.static <T1,
T2, T3>
CompletableFuture<Tuple3<T1, T2, T3>> tupleMSupplyFastFailAsync
(Executor executor, Supplier<? extends T1> supplier1, Supplier<? extends T2> supplier2, Supplier<? extends T3> supplier3) Returns a new CompletableFuture that is asynchronously completed by tasks running in the given Executor with the values obtained by calling the given Suppliers in the same order of the given Suppliers arguments.static <T1,
T2, T3, T4>
CompletableFuture<Tuple4<T1, T2, T3, T4>> tupleMSupplyFastFailAsync
(Executor executor, Supplier<? extends T1> supplier1, Supplier<? extends T2> supplier2, Supplier<? extends T3> supplier3, Supplier<? extends T4> supplier4) Returns a new CompletableFuture that is asynchronously completed by tasks running in the given Executor with the values obtained by calling the given Suppliers in the same order of the given Suppliers arguments.static <T1,
T2, T3, T4, T5>
CompletableFuture<Tuple5<T1, T2, T3, T4, T5>> tupleMSupplyFastFailAsync
(Executor executor, Supplier<? extends T1> supplier1, Supplier<? extends T2> supplier2, Supplier<? extends T3> supplier3, Supplier<? extends T4> supplier4, Supplier<? extends T5> supplier5) Returns a new CompletableFuture that is asynchronously completed by tasks running in the given Executor with the values obtained by calling the given Suppliers in the same order of the given Suppliers arguments.static <T1,
T2> CompletableFuture <Tuple2<T1, T2>> tupleMSupplyFastFailAsync
(Supplier<? extends T1> supplier1, Supplier<? extends T2> supplier2) Returns a new CompletableFuture that is asynchronously completed by tasks running in the CompletableFuture's default asynchronous execution facility with the values obtained by calling the given Suppliers in the same order of the given Suppliers arguments.static <T1,
T2, T3>
CompletableFuture<Tuple3<T1, T2, T3>> tupleMSupplyFastFailAsync
(Supplier<? extends T1> supplier1, Supplier<? extends T2> supplier2, Supplier<? extends T3> supplier3) Returns a new CompletableFuture that is asynchronously completed by tasks running in the CompletableFuture's default asynchronous execution facility with the values obtained by calling the given Suppliers in the same order of the given Suppliers arguments.static <T1,
T2, T3, T4>
CompletableFuture<Tuple4<T1, T2, T3, T4>> tupleMSupplyFastFailAsync
(Supplier<? extends T1> supplier1, Supplier<? extends T2> supplier2, Supplier<? extends T3> supplier3, Supplier<? extends T4> supplier4) Returns a new CompletableFuture that is asynchronously completed by tasks running in the CompletableFuture's default asynchronous execution facility with the values obtained by calling the given Suppliers in the same order of the given Suppliers arguments.static <T1,
T2, T3, T4, T5>
CompletableFuture<Tuple5<T1, T2, T3, T4, T5>> tupleMSupplyFastFailAsync
(Supplier<? extends T1> supplier1, Supplier<? extends T2> supplier2, Supplier<? extends T3> supplier3, Supplier<? extends T4> supplier4, Supplier<? extends T5> supplier5) Returns a new CompletableFuture that is asynchronously completed by tasks running in the CompletableFuture's default asynchronous execution facility with the values obtained by calling the given Suppliers in the same order of the given Suppliers arguments.static <T1,
T2> CompletableFuture <Tuple2<T1, T2>> tupleMSupplyMostSuccessAsync
(long timeout, TimeUnit unit, Supplier<? extends T1> supplier1, Supplier<? extends T2> supplier2) Returns a new CompletableFuture that is asynchronously completed by tasks running in the CompletableFuture's default asynchronous execution facility with the most values obtained by calling the given Suppliers in the given time(timeout
, aka as many results as possible in the given time) in the same order of the given Suppliers arguments.static <T1,
T2, T3>
CompletableFuture<Tuple3<T1, T2, T3>> tupleMSupplyMostSuccessAsync
(long timeout, TimeUnit unit, Supplier<? extends T1> supplier1, Supplier<? extends T2> supplier2, Supplier<? extends T3> supplier3) Returns a new CompletableFuture that is asynchronously completed by tasks running in the CompletableFuture's default asynchronous execution facility with the most values obtained by calling the given Suppliers in the given time(timeout
, aka as many results as possible in the given time) in the same order of the given Suppliers arguments.static <T1,
T2, T3, T4>
CompletableFuture<Tuple4<T1, T2, T3, T4>> tupleMSupplyMostSuccessAsync
(long timeout, TimeUnit unit, Supplier<? extends T1> supplier1, Supplier<? extends T2> supplier2, Supplier<? extends T3> supplier3, Supplier<? extends T4> supplier4) Returns a new CompletableFuture that is asynchronously completed by tasks running in the CompletableFuture's default asynchronous execution facility with the most values obtained by calling the given Suppliers in the given time(timeout
, aka as many results as possible in the given time) in the same order of the given Suppliers arguments.static <T1,
T2, T3, T4, T5>
CompletableFuture<Tuple5<T1, T2, T3, T4, T5>> tupleMSupplyMostSuccessAsync
(long timeout, TimeUnit unit, Supplier<? extends T1> supplier1, Supplier<? extends T2> supplier2, Supplier<? extends T3> supplier3, Supplier<? extends T4> supplier4, Supplier<? extends T5> supplier5) Returns a new CompletableFuture that is asynchronously completed by tasks running in the CompletableFuture's default asynchronous execution facility with the most values obtained by calling the given Suppliers in the given time(timeout
, aka as many results as possible in the given time) in the same order of the given Suppliers arguments.static <T1,
T2> CompletableFuture <Tuple2<T1, T2>> tupleMSupplyMostSuccessAsync
(Executor executor, long timeout, TimeUnit unit, Supplier<? extends T1> supplier1, Supplier<? extends T2> supplier2) Returns a new CompletableFuture that is asynchronously completed by tasks running in the given Executor with the most values obtained by calling the given Suppliers in the given time(timeout
, aka as many results as possible in the given time) in the same order of the given Suppliers arguments.static <T1,
T2, T3>
CompletableFuture<Tuple3<T1, T2, T3>> tupleMSupplyMostSuccessAsync
(Executor executor, long timeout, TimeUnit unit, Supplier<? extends T1> supplier1, Supplier<? extends T2> supplier2, Supplier<? extends T3> supplier3) Returns a new CompletableFuture that is asynchronously completed by tasks running in the given Executor with the most values obtained by calling the given Suppliers in the given time(timeout
, aka as many results as possible in the given time) in the same order of the given Suppliers arguments.static <T1,
T2, T3, T4>
CompletableFuture<Tuple4<T1, T2, T3, T4>> tupleMSupplyMostSuccessAsync
(Executor executor, long timeout, TimeUnit unit, Supplier<? extends T1> supplier1, Supplier<? extends T2> supplier2, Supplier<? extends T3> supplier3, Supplier<? extends T4> supplier4) Returns a new CompletableFuture that is asynchronously completed by tasks running in the given Executor with the most values obtained by calling the given Suppliers in the given time(timeout
, aka as many results as possible in the given time) in the same order of the given Suppliers arguments.static <T1,
T2, T3, T4, T5>
CompletableFuture<Tuple5<T1, T2, T3, T4, T5>> tupleMSupplyMostSuccessAsync
(Executor executor, long timeout, TimeUnit unit, Supplier<? extends T1> supplier1, Supplier<? extends T2> supplier2, Supplier<? extends T3> supplier3, Supplier<? extends T4> supplier4, Supplier<? extends T5> supplier5) Returns a new CompletableFuture that is asynchronously completed by tasks running in the given Executor with the most values obtained by calling the given Suppliers in the given time(timeout
, aka as many results as possible in the given time) in the same order of the given Suppliers arguments.static Throwable
A convenient util method for unwrapping CF exception (CompletionException
/ExecutionException
) to the biz exception.
-
Method Details
-
mSupplyFastFailAsync
@SafeVarargs public static <T> CompletableFuture<List<T>> mSupplyFastFailAsync(Supplier<? extends T>... suppliers) Returns a new CompletableFuture that is asynchronously completed by tasks running in the CompletableFuture's default asynchronous execution facility with the values obtained by calling the given Suppliers in the same order of the given Suppliers arguments.- Type Parameters:
T
- the suppliers' return type- Parameters:
suppliers
- the suppliers returning the value to be used to complete the returned CompletableFuture- Returns:
- the new CompletableFuture
- See Also:
-
mSupplyFastFailAsync
@SafeVarargs public static <T> CompletableFuture<List<T>> mSupplyFastFailAsync(Executor executor, Supplier<? extends T>... suppliers) Returns a new CompletableFuture that is asynchronously completed by tasks running in the given Executor with the values obtained by calling the given Suppliers in the same order of the given Suppliers arguments.- Type Parameters:
T
- the suppliers' return type- Parameters:
executor
- the executor to use for asynchronous executionsuppliers
- the suppliers returning the value to be used to complete the returned CompletableFuture- Returns:
- the new CompletableFuture
- See Also:
-
mSupplyAllSuccessAsync
@SafeVarargs public static <T> CompletableFuture<List<T>> mSupplyAllSuccessAsync(@Nullable T valueIfFailed, Supplier<? extends T>... suppliers) Returns a new CompletableFuture that is asynchronously completed by tasks running in the CompletableFuture's default asynchronous execution facility with the successful values obtained by calling the given Suppliers in the same order of the given Suppliers arguments.If the given supplier failed, use the given valueIfFailed.
- Type Parameters:
T
- the suppliers' return type- Parameters:
valueIfFailed
- the value to return if not failedsuppliers
- the suppliers returning the value to be used to complete the returned CompletableFuture- Returns:
- the new CompletableFuture
- See Also:
-
mSupplyAllSuccessAsync
@SafeVarargs public static <T> CompletableFuture<List<T>> mSupplyAllSuccessAsync(@Nullable T valueIfFailed, Executor executor, Supplier<? extends T>... suppliers) Returns a new CompletableFuture that is asynchronously completed by tasks running in the given Executor with the successfully values obtained by calling the given Suppliers in the same order of the given Suppliers arguments.If the given supplier failed, use the given valueIfFailed.
- Type Parameters:
T
- the suppliers' return type- Parameters:
valueIfFailed
- the value to return if not failedexecutor
- the executor to use for asynchronous executionsuppliers
- the suppliers returning the value to be used to complete the returned CompletableFuture- Returns:
- the new CompletableFuture
- See Also:
-
mSupplyMostSuccessAsync
@SafeVarargs public static <T> CompletableFuture<List<T>> mSupplyMostSuccessAsync(@Nullable T valueIfNotSuccess, long timeout, TimeUnit unit, Supplier<? extends T>... suppliers) Returns a new CompletableFuture that is asynchronously completed by tasks running in the CompletableFuture's default asynchronous execution facility with the most values obtained by calling the given Suppliers in the given time(timeout
, aka as many results as possible in the given time) in the same order of the given Suppliers arguments.If the given supplier is successful in the given time, the return result is the completed value; Otherwise the given valueIfNotSuccess.
- Type Parameters:
T
- the suppliers' return type- Parameters:
valueIfNotSuccess
- the value to return if not completed successfullytimeout
- how long to wait in units ofunit
unit
- aTimeUnit
determining how to interpret thetimeout
parametersuppliers
- the suppliers returning the value to be used to complete the returned CompletableFuture- Returns:
- the new CompletableFuture
- See Also:
-
mSupplyMostSuccessAsync
@SafeVarargs public static <T> CompletableFuture<List<T>> mSupplyMostSuccessAsync(@Nullable T valueIfNotSuccess, Executor executor, long timeout, TimeUnit unit, Supplier<? extends T>... suppliers) Returns a new CompletableFuture that is asynchronously completed by tasks running in the given Executor with the most values obtained by calling the given Suppliers in the given time(timeout
, aka as many results as possible in the given time) in the same order of the given Suppliers arguments.If the given supplier is successful in the given time, the return result is the completed value; Otherwise the given valueIfNotSuccess.
- Type Parameters:
T
- the suppliers' return type- Parameters:
valueIfNotSuccess
- the value to return if not completed successfullyexecutor
- the executor to use for asynchronous executiontimeout
- how long to wait in units ofunit
unit
- aTimeUnit
determining how to interpret thetimeout
parametersuppliers
- the suppliers returning the value to be used to complete the returned CompletableFuture- Returns:
- the new CompletableFuture
- See Also:
-
mSupplyAsync
@SafeVarargs public static <T> CompletableFuture<List<T>> mSupplyAsync(Supplier<? extends T>... suppliers) Returns a new CompletableFuture that is asynchronously completed by tasks running in the CompletableFuture's default asynchronous execution facility with the values obtained by calling the given Suppliers in the same order of the given Suppliers arguments.- Type Parameters:
T
- the suppliers' return type- Parameters:
suppliers
- the suppliers returning the value to be used to complete the returned CompletableFuture- Returns:
- the new CompletableFuture
- See Also:
-
mSupplyAsync
@SafeVarargs public static <T> CompletableFuture<List<T>> mSupplyAsync(Executor executor, Supplier<? extends T>... suppliers) Returns a new CompletableFuture that is asynchronously completed by tasks running in the given Executor with the values obtained by calling the given Suppliers in the same order of the given Suppliers arguments.- Type Parameters:
T
- the suppliers' return type- Parameters:
executor
- the executor to use for asynchronous executionsuppliers
- the suppliers returning the value to be used to complete the returned CompletableFuture- Returns:
- the new CompletableFuture
- See Also:
-
mSupplyAnySuccessAsync
@SafeVarargs public static <T> CompletableFuture<T> mSupplyAnySuccessAsync(Supplier<? extends T>... suppliers) Returns a new CompletableFuture that is asynchronously successful when any of tasks running in the CompletableFuture's default asynchronous execution facility by calling the given Suppliers success, with the same result. Otherwise, all the given tasks complete exceptionally, the returned CompletableFuture also does so, with a CompletionException holding an exception from any of the given stages as its cause. If no suppliers are provided, returns a new CompletableFuture that is already completed exceptionally with a CompletionException holding aNoCfsProvidedException
as its cause.- Type Parameters:
T
- the suppliers' return type- Parameters:
suppliers
- the suppliers returning the value to be used to complete the returned CompletableFuture- Returns:
- the new CompletableFuture
- See Also:
-
mSupplyAnySuccessAsync
@SafeVarargs public static <T> CompletableFuture<T> mSupplyAnySuccessAsync(Executor executor, Supplier<? extends T>... suppliers) Returns a new CompletableFuture that is asynchronously successful when any of tasks running in the given executor by calling the given Suppliers success, with the same result. Otherwise, all the given tasks complete exceptionally, the returned CompletableFuture also does so, with a CompletionException holding an exception from any of the given stages as its cause. If no suppliers are provided, returns a new CompletableFuture that is already completed exceptionally with a CompletionException holding aNoCfsProvidedException
as its cause.- Type Parameters:
T
- the suppliers' return type- Parameters:
executor
- the executor to use for asynchronous executionsuppliers
- the suppliers returning the value to be used to complete the returned CompletableFuture- Returns:
- the new CompletableFuture
- See Also:
-
mSupplyAnyAsync
@SafeVarargs public static <T> CompletableFuture<T> mSupplyAnyAsync(Supplier<? extends T>... suppliers) Returns a new CompletableFuture that is completed when any of tasks running in the CompletableFuture's default asynchronous execution facility by calling the given Suppliers complete, with the same result. Otherwise, if it completed exceptionally, the returned CompletableFuture also does so, with a CompletionException holding this exception as its cause. If no suppliers are provided, returns an incomplete CompletableFuture.- Type Parameters:
T
- the suppliers' return type- Parameters:
suppliers
- the suppliers returning the value to be used to complete the returned CompletableFuture- Returns:
- the new CompletableFuture
- See Also:
-
mSupplyAnyAsync
@SafeVarargs public static <T> CompletableFuture<T> mSupplyAnyAsync(Executor executor, Supplier<? extends T>... suppliers) Returns a new CompletableFuture that is completed when any of tasks running in the given Executor by calling the given Suppliers complete, with the same result. Otherwise, if it completed exceptionally, the returned CompletableFuture also does so, with a CompletionException holding this exception as its cause. If no suppliers are provided, returns an incomplete CompletableFuture.- Type Parameters:
T
- the suppliers' return type- Parameters:
executor
- the executor to use for asynchronous executionsuppliers
- the suppliers returning the value to be used to complete the returned CompletableFuture- Returns:
- the new CompletableFuture
- See Also:
-
mRunFastFailAsync
Returns a new CompletableFuture that is asynchronously completed by tasks running in the CompletableFuture's default asynchronous execution facility after runs the given actions.- Parameters:
actions
- the actions to run before completing the returned CompletableFuture- Returns:
- the new CompletableFuture
- See Also:
-
mRunFastFailAsync
Returns a new CompletableFuture that is asynchronously completed by tasks running in the given Executor after runs the given actions.- Parameters:
executor
- the executor to use for asynchronous executionactions
- the actions to run before completing the returned CompletableFuture- Returns:
- the new CompletableFuture
- See Also:
-
mRunAsync
Returns a new CompletableFuture that is asynchronously completed by tasks running in the CompletableFuture's default asynchronous execution facility after runs the given actions.- Parameters:
actions
- the actions to run before completing the returned CompletableFuture- Returns:
- the new CompletableFuture
- See Also:
-
mRunAsync
Returns a new CompletableFuture that is asynchronously completed by tasks running in the given Executor after runs the given actions.- Parameters:
executor
- the executor to use for asynchronous executionactions
- the actions to run before completing the returned CompletableFuture- Returns:
- the new CompletableFuture
- See Also:
-
mRunAnySuccessAsync
Returns a new CompletableFuture that is asynchronously successful when any tasks running in the CompletableFuture's default asynchronous execution facility success.- Parameters:
actions
- the actions to run to complete the returned CompletableFuture- Returns:
- the new CompletableFuture
- See Also:
-
mRunAnySuccessAsync
Returns a new CompletableFuture that is asynchronously successful when any tasks running in the given executor success.- Parameters:
executor
- the executor to use for asynchronous executionactions
- the actions to run to complete the returned CompletableFuture- Returns:
- the new CompletableFuture
- See Also:
-
mRunAnyAsync
Returns a new CompletableFuture that is asynchronously completed when any tasks running in the CompletableFuture's default asynchronous execution facility.- Parameters:
actions
- the actions to run to complete the returned CompletableFuture- Returns:
- the new CompletableFuture
- See Also:
-
mRunAnyAsync
Returns a new CompletableFuture that is asynchronously completed when any tasks running in the given executor complete.- Parameters:
executor
- the executor to use for asynchronous executionactions
- the actions to run to complete the returned CompletableFuture- Returns:
- the new CompletableFuture
- See Also:
-
tupleMSupplyFastFailAsync
public static <T1,T2> CompletableFuture<Tuple2<T1,T2>> tupleMSupplyFastFailAsync(Supplier<? extends T1> supplier1, Supplier<? extends T2> supplier2) Returns a new CompletableFuture that is asynchronously completed by tasks running in the CompletableFuture's default asynchronous execution facility with the values obtained by calling the given Suppliers in the same order of the given Suppliers arguments.- Returns:
- the new CompletableFuture
- See Also:
-
tupleMSupplyFastFailAsync
public static <T1,T2> CompletableFuture<Tuple2<T1,T2>> tupleMSupplyFastFailAsync(Executor executor, Supplier<? extends T1> supplier1, Supplier<? extends T2> supplier2) Returns a new CompletableFuture that is asynchronously completed by tasks running in the given Executor with the values obtained by calling the given Suppliers in the same order of the given Suppliers arguments.- Parameters:
executor
- the executor to use for asynchronous execution- Returns:
- the new CompletableFuture
- See Also:
-
tupleMSupplyFastFailAsync
public static <T1,T2, CompletableFuture<Tuple3<T1,T3> T2, tupleMSupplyFastFailAsyncT3>> (Supplier<? extends T1> supplier1, Supplier<? extends T2> supplier2, Supplier<? extends T3> supplier3) Returns a new CompletableFuture that is asynchronously completed by tasks running in the CompletableFuture's default asynchronous execution facility with the values obtained by calling the given Suppliers in the same order of the given Suppliers arguments.- Returns:
- the new CompletableFuture
- See Also:
-
tupleMSupplyFastFailAsync
public static <T1,T2, CompletableFuture<Tuple3<T1,T3> T2, tupleMSupplyFastFailAsyncT3>> (Executor executor, Supplier<? extends T1> supplier1, Supplier<? extends T2> supplier2, Supplier<? extends T3> supplier3) Returns a new CompletableFuture that is asynchronously completed by tasks running in the given Executor with the values obtained by calling the given Suppliers in the same order of the given Suppliers arguments.- Parameters:
executor
- the executor to use for asynchronous execution- Returns:
- the new CompletableFuture
- See Also:
-
tupleMSupplyFastFailAsync
public static <T1,T2, CompletableFuture<Tuple4<T1,T3, T4> T2, tupleMSupplyFastFailAsyncT3, T4>> (Supplier<? extends T1> supplier1, Supplier<? extends T2> supplier2, Supplier<? extends T3> supplier3, Supplier<? extends T4> supplier4) Returns a new CompletableFuture that is asynchronously completed by tasks running in the CompletableFuture's default asynchronous execution facility with the values obtained by calling the given Suppliers in the same order of the given Suppliers arguments.- Returns:
- the new CompletableFuture
- See Also:
-
tupleMSupplyFastFailAsync
public static <T1,T2, CompletableFuture<Tuple4<T1,T3, T4> T2, tupleMSupplyFastFailAsyncT3, T4>> (Executor executor, Supplier<? extends T1> supplier1, Supplier<? extends T2> supplier2, Supplier<? extends T3> supplier3, Supplier<? extends T4> supplier4) Returns a new CompletableFuture that is asynchronously completed by tasks running in the given Executor with the values obtained by calling the given Suppliers in the same order of the given Suppliers arguments.- Parameters:
executor
- the executor to use for asynchronous execution- Returns:
- the new CompletableFuture
- See Also:
-
tupleMSupplyFastFailAsync
public static <T1,T2, CompletableFuture<Tuple5<T1,T3, T4, T5> T2, tupleMSupplyFastFailAsyncT3, T4, T5>> (Supplier<? extends T1> supplier1, Supplier<? extends T2> supplier2, Supplier<? extends T3> supplier3, Supplier<? extends T4> supplier4, Supplier<? extends T5> supplier5) Returns a new CompletableFuture that is asynchronously completed by tasks running in the CompletableFuture's default asynchronous execution facility with the values obtained by calling the given Suppliers in the same order of the given Suppliers arguments.- Returns:
- the new CompletableFuture
- See Also:
-
tupleMSupplyFastFailAsync
public static <T1,T2, CompletableFuture<Tuple5<T1,T3, T4, T5> T2, tupleMSupplyFastFailAsyncT3, T4, T5>> (Executor executor, Supplier<? extends T1> supplier1, Supplier<? extends T2> supplier2, Supplier<? extends T3> supplier3, Supplier<? extends T4> supplier4, Supplier<? extends T5> supplier5) Returns a new CompletableFuture that is asynchronously completed by tasks running in the given Executor with the values obtained by calling the given Suppliers in the same order of the given Suppliers arguments.- Parameters:
executor
- the executor to use for asynchronous execution- Returns:
- the new CompletableFuture
- See Also:
-
tupleMSupplyAllSuccessAsync
public static <T1,T2> CompletableFuture<Tuple2<T1,T2>> tupleMSupplyAllSuccessAsync(Supplier<? extends T1> supplier1, Supplier<? extends T2> supplier2) Returns a new CompletableFuture that is asynchronously completed by tasks running in the CompletableFuture's default asynchronous execution facility with the successful values obtained by calling the given Suppliers in the same order of the given Suppliers arguments.If the given supplier failed, use
null
.- Returns:
- the new CompletableFuture
- See Also:
-
tupleMSupplyAllSuccessAsync
public static <T1,T2> CompletableFuture<Tuple2<T1,T2>> tupleMSupplyAllSuccessAsync(Executor executor, Supplier<? extends T1> supplier1, Supplier<? extends T2> supplier2) Returns a new CompletableFuture that is asynchronously completed by tasks running in the given executor with the successfully values obtained by calling the given Suppliers in the same order of the given Suppliers arguments.If the given supplier failed, use
null
.- Parameters:
executor
- the executor to use for asynchronous execution- Returns:
- the new CompletableFuture
- See Also:
-
tupleMSupplyAllSuccessAsync
public static <T1,T2, CompletableFuture<Tuple3<T1,T3> T2, tupleMSupplyAllSuccessAsyncT3>> (Supplier<? extends T1> supplier1, Supplier<? extends T2> supplier2, Supplier<? extends T3> supplier3) Returns a new CompletableFuture that is asynchronously completed by tasks running in the CompletableFuture's default asynchronous execution facility with the successful values obtained by calling the given Suppliers in the same order of the given Suppliers arguments.If the given supplier failed, use
null
.- Returns:
- the new CompletableFuture
- See Also:
-
tupleMSupplyAllSuccessAsync
public static <T1,T2, CompletableFuture<Tuple3<T1,T3> T2, tupleMSupplyAllSuccessAsyncT3>> (Executor executor, Supplier<? extends T1> supplier1, Supplier<? extends T2> supplier2, Supplier<? extends T3> supplier3) Returns a new CompletableFuture that is asynchronously completed by tasks running in the given executor with the successfully values obtained by calling the given Suppliers in the same order of the given Suppliers arguments.If the given supplier failed, use
null
.- Parameters:
executor
- the executor to use for asynchronous execution- Returns:
- the new CompletableFuture
- See Also:
-
tupleMSupplyAllSuccessAsync
public static <T1,T2, CompletableFuture<Tuple4<T1,T3, T4> T2, tupleMSupplyAllSuccessAsyncT3, T4>> (Supplier<? extends T1> supplier1, Supplier<? extends T2> supplier2, Supplier<? extends T3> supplier3, Supplier<? extends T4> supplier4) Returns a new CompletableFuture that is asynchronously completed by tasks running in the CompletableFuture's default asynchronous execution facility with the successful values obtained by calling the given Suppliers in the same order of the given Suppliers arguments.If the given supplier failed, use
null
.- Returns:
- the new CompletableFuture
- See Also:
-
tupleMSupplyAllSuccessAsync
public static <T1,T2, CompletableFuture<Tuple4<T1,T3, T4> T2, tupleMSupplyAllSuccessAsyncT3, T4>> (Executor executor, Supplier<? extends T1> supplier1, Supplier<? extends T2> supplier2, Supplier<? extends T3> supplier3, Supplier<? extends T4> supplier4) Returns a new CompletableFuture that is asynchronously completed by tasks running in the given executor with the successfully values obtained by calling the given Suppliers in the same order of the given Suppliers arguments.If the given supplier failed, use
null
.- Parameters:
executor
- the executor to use for asynchronous execution- Returns:
- the new CompletableFuture
- See Also:
-
tupleMSupplyAllSuccessAsync
public static <T1,T2, CompletableFuture<Tuple5<T1,T3, T4, T5> T2, tupleMSupplyAllSuccessAsyncT3, T4, T5>> (Supplier<? extends T1> supplier1, Supplier<? extends T2> supplier2, Supplier<? extends T3> supplier3, Supplier<? extends T4> supplier4, Supplier<? extends T5> supplier5) Returns a new CompletableFuture that is asynchronously completed by tasks running in the CompletableFuture's default asynchronous execution facility with the successful values obtained by calling the given Suppliers in the same order of the given Suppliers arguments.If the given supplier failed, use
null
.- Returns:
- the new CompletableFuture
- See Also:
-
tupleMSupplyAllSuccessAsync
public static <T1,T2, CompletableFuture<Tuple5<T1,T3, T4, T5> T2, tupleMSupplyAllSuccessAsyncT3, T4, T5>> (Executor executor, Supplier<? extends T1> supplier1, Supplier<? extends T2> supplier2, Supplier<? extends T3> supplier3, Supplier<? extends T4> supplier4, Supplier<? extends T5> supplier5) Returns a new CompletableFuture that is asynchronously completed by tasks running in the given executor with the successfully values obtained by calling the given Suppliers in the same order of the given Suppliers arguments.If the given supplier failed, use
null
.- Parameters:
executor
- the executor to use for asynchronous execution- Returns:
- the new CompletableFuture
- See Also:
-
tupleMSupplyMostSuccessAsync
public static <T1,T2> CompletableFuture<Tuple2<T1,T2>> tupleMSupplyMostSuccessAsync(long timeout, TimeUnit unit, Supplier<? extends T1> supplier1, Supplier<? extends T2> supplier2) Returns a new CompletableFuture that is asynchronously completed by tasks running in the CompletableFuture's default asynchronous execution facility with the most values obtained by calling the given Suppliers in the given time(timeout
, aka as many results as possible in the given time) in the same order of the given Suppliers arguments.If the given supplier is successful in the given time, the return result is the completed value; Otherwise
null
.- Parameters:
timeout
- how long to wait in units ofunit
unit
- aTimeUnit
determining how to interpret thetimeout
parameter- Returns:
- the new CompletableFuture
- See Also:
-
tupleMSupplyMostSuccessAsync
public static <T1,T2> CompletableFuture<Tuple2<T1,T2>> tupleMSupplyMostSuccessAsync(Executor executor, long timeout, TimeUnit unit, Supplier<? extends T1> supplier1, Supplier<? extends T2> supplier2) Returns a new CompletableFuture that is asynchronously completed by tasks running in the given Executor with the most values obtained by calling the given Suppliers in the given time(timeout
, aka as many results as possible in the given time) in the same order of the given Suppliers arguments.If the given supplier is successful in the given time, the return result is the completed value; Otherwise
null
.- Parameters:
executor
- the executor to use for asynchronous executiontimeout
- how long to wait in units ofunit
unit
- aTimeUnit
determining how to interpret thetimeout
parameter- Returns:
- the new CompletableFuture
- See Also:
-
tupleMSupplyMostSuccessAsync
public static <T1,T2, CompletableFuture<Tuple3<T1,T3> T2, tupleMSupplyMostSuccessAsyncT3>> (long timeout, TimeUnit unit, Supplier<? extends T1> supplier1, Supplier<? extends T2> supplier2, Supplier<? extends T3> supplier3) Returns a new CompletableFuture that is asynchronously completed by tasks running in the CompletableFuture's default asynchronous execution facility with the most values obtained by calling the given Suppliers in the given time(timeout
, aka as many results as possible in the given time) in the same order of the given Suppliers arguments.If the given supplier is successful in the given time, the return result is the completed value; Otherwise
null
.- Parameters:
timeout
- how long to wait in units ofunit
unit
- aTimeUnit
determining how to interpret thetimeout
parameter- Returns:
- the new CompletableFuture
- See Also:
-
tupleMSupplyMostSuccessAsync
public static <T1,T2, CompletableFuture<Tuple3<T1,T3> T2, tupleMSupplyMostSuccessAsyncT3>> (Executor executor, long timeout, TimeUnit unit, Supplier<? extends T1> supplier1, Supplier<? extends T2> supplier2, Supplier<? extends T3> supplier3) Returns a new CompletableFuture that is asynchronously completed by tasks running in the given Executor with the most values obtained by calling the given Suppliers in the given time(timeout
, aka as many results as possible in the given time) in the same order of the given Suppliers arguments.If the given supplier is successful in the given time, the return result is the completed value; Otherwise
null
.- Parameters:
executor
- the executor to use for asynchronous executiontimeout
- how long to wait in units ofunit
unit
- aTimeUnit
determining how to interpret thetimeout
parameter- Returns:
- the new CompletableFuture
- See Also:
-
tupleMSupplyMostSuccessAsync
public static <T1,T2, CompletableFuture<Tuple4<T1,T3, T4> T2, tupleMSupplyMostSuccessAsyncT3, T4>> (long timeout, TimeUnit unit, Supplier<? extends T1> supplier1, Supplier<? extends T2> supplier2, Supplier<? extends T3> supplier3, Supplier<? extends T4> supplier4) Returns a new CompletableFuture that is asynchronously completed by tasks running in the CompletableFuture's default asynchronous execution facility with the most values obtained by calling the given Suppliers in the given time(timeout
, aka as many results as possible in the given time) in the same order of the given Suppliers arguments.If the given supplier is successful in the given time, the return result is the completed value; Otherwise
null
.- Parameters:
timeout
- how long to wait in units ofunit
unit
- aTimeUnit
determining how to interpret thetimeout
parameter- Returns:
- the new CompletableFuture
- See Also:
-
tupleMSupplyMostSuccessAsync
public static <T1,T2, CompletableFuture<Tuple4<T1,T3, T4> T2, tupleMSupplyMostSuccessAsyncT3, T4>> (Executor executor, long timeout, TimeUnit unit, Supplier<? extends T1> supplier1, Supplier<? extends T2> supplier2, Supplier<? extends T3> supplier3, Supplier<? extends T4> supplier4) Returns a new CompletableFuture that is asynchronously completed by tasks running in the given Executor with the most values obtained by calling the given Suppliers in the given time(timeout
, aka as many results as possible in the given time) in the same order of the given Suppliers arguments.If the given supplier is successful in the given time, the return result is the completed value; Otherwise
null
.- Parameters:
executor
- the executor to use for asynchronous executiontimeout
- how long to wait in units ofunit
unit
- aTimeUnit
determining how to interpret thetimeout
parameter- Returns:
- the new CompletableFuture
- See Also:
-
tupleMSupplyMostSuccessAsync
public static <T1,T2, CompletableFuture<Tuple5<T1,T3, T4, T5> T2, tupleMSupplyMostSuccessAsyncT3, T4, T5>> (long timeout, TimeUnit unit, Supplier<? extends T1> supplier1, Supplier<? extends T2> supplier2, Supplier<? extends T3> supplier3, Supplier<? extends T4> supplier4, Supplier<? extends T5> supplier5) Returns a new CompletableFuture that is asynchronously completed by tasks running in the CompletableFuture's default asynchronous execution facility with the most values obtained by calling the given Suppliers in the given time(timeout
, aka as many results as possible in the given time) in the same order of the given Suppliers arguments.If the given supplier is successful in the given time, the return result is the completed value; Otherwise
null
.- Parameters:
timeout
- how long to wait in units ofunit
unit
- aTimeUnit
determining how to interpret thetimeout
parameter- Returns:
- the new CompletableFuture
- See Also:
-
tupleMSupplyMostSuccessAsync
public static <T1,T2, CompletableFuture<Tuple5<T1,T3, T4, T5> T2, tupleMSupplyMostSuccessAsyncT3, T4, T5>> (Executor executor, long timeout, TimeUnit unit, Supplier<? extends T1> supplier1, Supplier<? extends T2> supplier2, Supplier<? extends T3> supplier3, Supplier<? extends T4> supplier4, Supplier<? extends T5> supplier5) Returns a new CompletableFuture that is asynchronously completed by tasks running in the given Executor with the most values obtained by calling the given Suppliers in the given time(timeout
, aka as many results as possible in the given time) in the same order of the given Suppliers arguments.If the given supplier is successful in the given time, the return result is the completed value; Otherwise
null
.- Parameters:
executor
- the executor to use for asynchronous executiontimeout
- how long to wait in units ofunit
unit
- aTimeUnit
determining how to interpret thetimeout
parameter- Returns:
- the new CompletableFuture
- See Also:
-
tupleMSupplyAsync
public static <T1,T2> CompletableFuture<Tuple2<T1,T2>> tupleMSupplyAsync(Supplier<? extends T1> supplier1, Supplier<? extends T2> supplier2) Returns a new CompletableFuture that is asynchronously completed by tasks running in the CompletableFuture's default asynchronous execution facility with the values obtained by calling the given Suppliers in the same order of the given Suppliers arguments.- Returns:
- the new CompletableFuture
- See Also:
-
tupleMSupplyAsync
public static <T1,T2> CompletableFuture<Tuple2<T1,T2>> tupleMSupplyAsync(Executor executor, Supplier<? extends T1> supplier1, Supplier<? extends T2> supplier2) Returns a new CompletableFuture that is asynchronously completed by tasks running in the given Executor with the values obtained by calling the given Suppliers in the same order of the given Suppliers arguments.- Parameters:
executor
- the executor to use for asynchronous execution- Returns:
- the new CompletableFuture
- See Also:
-
tupleMSupplyAsync
public static <T1,T2, CompletableFuture<Tuple3<T1,T3> T2, tupleMSupplyAsyncT3>> (Supplier<? extends T1> supplier1, Supplier<? extends T2> supplier2, Supplier<? extends T3> supplier3) Returns a new CompletableFuture that is asynchronously completed by tasks running in the CompletableFuture's default asynchronous execution facility with the values obtained by calling the given Suppliers in the same order of the given Suppliers arguments.- Returns:
- the new CompletableFuture
- See Also:
-
tupleMSupplyAsync
public static <T1,T2, CompletableFuture<Tuple3<T1,T3> T2, tupleMSupplyAsyncT3>> (Executor executor, Supplier<? extends T1> supplier1, Supplier<? extends T2> supplier2, Supplier<? extends T3> supplier3) Returns a new CompletableFuture that is asynchronously completed by tasks running in the given Executor with the values obtained by calling the given Suppliers in the same order of the given Suppliers arguments.- Parameters:
executor
- the executor to use for asynchronous execution- Returns:
- the new CompletableFuture
- See Also:
-
tupleMSupplyAsync
public static <T1,T2, CompletableFuture<Tuple4<T1,T3, T4> T2, tupleMSupplyAsyncT3, T4>> (Supplier<? extends T1> supplier1, Supplier<? extends T2> supplier2, Supplier<? extends T3> supplier3, Supplier<? extends T4> supplier4) Returns a new CompletableFuture that is asynchronously completed by tasks running in the CompletableFuture's default asynchronous execution facility with the values obtained by calling the given Suppliers in the same order of the given Suppliers arguments.- Returns:
- the new CompletableFuture
- See Also:
-
tupleMSupplyAsync
public static <T1,T2, CompletableFuture<Tuple4<T1,T3, T4> T2, tupleMSupplyAsyncT3, T4>> (Executor executor, Supplier<? extends T1> supplier1, Supplier<? extends T2> supplier2, Supplier<? extends T3> supplier3, Supplier<? extends T4> supplier4) Returns a new CompletableFuture that is asynchronously completed by tasks running in the given Executor with the values obtained by calling the given Suppliers in the same order of the given Suppliers arguments.- Parameters:
executor
- the executor to use for asynchronous execution- Returns:
- the new CompletableFuture
- See Also:
-
tupleMSupplyAsync
public static <T1,T2, CompletableFuture<Tuple5<T1,T3, T4, T5> T2, tupleMSupplyAsyncT3, T4, T5>> (Supplier<? extends T1> supplier1, Supplier<? extends T2> supplier2, Supplier<? extends T3> supplier3, Supplier<? extends T4> supplier4, Supplier<? extends T5> supplier5) Returns a new CompletableFuture that is asynchronously completed by tasks running in the CompletableFuture's default asynchronous execution facility with the values obtained by calling the given Suppliers in the same order of the given Suppliers arguments.- Returns:
- the new CompletableFuture
- See Also:
-
tupleMSupplyAsync
public static <T1,T2, CompletableFuture<Tuple5<T1,T3, T4, T5> T2, tupleMSupplyAsyncT3, T4, T5>> (Executor executor, Supplier<? extends T1> supplier1, Supplier<? extends T2> supplier2, Supplier<? extends T3> supplier3, Supplier<? extends T4> supplier4, Supplier<? extends T5> supplier5) Returns a new CompletableFuture that is asynchronously completed by tasks running in the given Executor with the values obtained by calling the given Suppliers in the same order of the given Suppliers arguments.- Parameters:
executor
- the executor to use for asynchronous execution- Returns:
- the new CompletableFuture
- See Also:
-
allResultsFastFailOf
@Contract(pure=true) @SafeVarargs public static <T> CompletableFuture<List<T>> allResultsFastFailOf(CompletionStage<? extends T>... cfs) Returns a new CompletableFuture that is successful with the results in the same order of the given stages arguments when all the given stages success; If any of the given stages complete exceptionally, then the returned CompletableFuture also does so *without* waiting other incomplete given stages, with a CompletionException holding this exception as its cause. If no stages are provided, returns a CompletableFuture completed with the value empty list.This method is the same as
allResultsOf(CompletionStage[])
except for the fast-fail behavior.- Parameters:
cfs
- the stages- Returns:
- a new CompletableFuture that is successful when all the given stages success
- Throws:
NullPointerException
- if the array or any of its elements arenull
-
allSuccessResultsOf
@Contract(pure=true) @SafeVarargs public static <T> CompletableFuture<List<T>> allSuccessResultsOf(@Nullable T valueIfFailed, CompletionStage<? extends T>... cfs) Returns a new CompletableFuture that is successful with the results in the same order of the given stages arguments when all the given stages completed; If the given stage complete exceptionally, treat it successful with value valueIfFailed. If no stages are provided, returns a CompletableFuture completed with the value empty list.- Parameters:
valueIfFailed
- the value to return if not completed successfullycfs
- the stages- Throws:
NullPointerException
- if the array or any of its elements arenull
- See Also:
-
mostSuccessResultsOf
@Contract(pure=true) @SafeVarargs public static <T> CompletableFuture<List<T>> mostSuccessResultsOf(@Nullable T valueIfNotSuccess, long timeout, TimeUnit unit, CompletionStage<? extends T>... cfs) Returns a new CompletableFuture with the most results in the same order of the given stages arguments in the given time(timeout
, aka as many results as possible in the given time).If the given stage is successful, its result is the completed value; Otherwise the given valueIfNotSuccess.
- Parameters:
valueIfNotSuccess
- the value to return if not completed successfullytimeout
- how long to wait in units ofunit
unit
- aTimeUnit
determining how to interpret thetimeout
parametercfs
- the stages- See Also:
-
mostSuccessResultsOf
@Contract(pure=true) @SafeVarargs public static <T> CompletableFuture<List<T>> mostSuccessResultsOf(@Nullable T valueIfNotSuccess, Executor executorWhenTimeout, long timeout, TimeUnit unit, CompletionStage<? extends T>... cfs) Returns a new CompletableFuture with the most results in the same order of the given stages arguments in the given time(timeout
, aka as many results as possible in the given time).If the given stage is successful, its result is the completed value; Otherwise the given valueIfNotSuccess.
- Parameters:
valueIfNotSuccess
- the value to return if not completed successfullyexecutorWhenTimeout
- the async executor when triggered by timeouttimeout
- how long to wait in units ofunit
unit
- aTimeUnit
determining how to interpret thetimeout
parametercfs
- the stages- See Also:
-
allResultsOf
@Contract(pure=true) @SafeVarargs public static <T> CompletableFuture<List<T>> allResultsOf(CompletionStage<? extends T>... cfs) Returns a new CompletableFuture with the results in the same order of the given stages arguments, the new CompletableFuture is completed when all the given stages complete; If any of the given stages complete exceptionally, then the returned CompletableFuture also does so, with a CompletionException holding this exception as its cause. If no stages are provided, returns a CompletableFuture completed with the value empty list.This method is the same as
allOf(CompletionStage[])
, except that the returned CompletableFuture contains the results of the given stages.- Parameters:
cfs
- the stages- Returns:
- a new CompletableFuture that is completed when all the given stages complete
- Throws:
NullPointerException
- if the array or any of its elements arenull
- See Also:
-
allFastFailOf
Returns a new CompletableFuture that is successful when all the given stages success; If any of the given stages complete exceptionally, then the returned CompletableFuture also does so *without* waiting other incomplete given stages, with a CompletionException holding this exception as its cause. Otherwise, the results, if any, of the given stages are not reflected in the returned CompletableFuture(CompletableFuture<Void>
), but may be obtained by inspecting them individually. If no stages are provided, returns a CompletableFuture completed with the valuenull
.This method is the same as
allOf(CompletionStage[])
except for the fast-fail behavior.If you need the results of given stages, prefer below methods:
allResultsFastFailOf(CompletionStage[])
allTupleFastFailOf(CompletionStage, CompletionStage)
/allTupleFastFailOf(CompletionStage, CompletionStage, CompletionStage, CompletionStage, CompletionStage)
(provided overloaded methods with 2~5 input)
If you need the successful results of given stages in the given time, prefer below methods:
- Parameters:
cfs
- the stages- Returns:
- a new CompletableFuture that is successful when all the given stages success
- Throws:
NullPointerException
- if the array or any of its elements arenull
-
allOf
Returns a new CompletableFuture that is completed when all the given stages complete; If any of the given stages complete exceptionally, then the returned CompletableFuture also does so, with a CompletionException holding this exception as its cause. Otherwise, the results, if any, of the given stages are not reflected in the returned CompletableFuture(CompletableFuture<Void>
), but may be obtained by inspecting them individually. If no stages are provided, returns a CompletableFuture completed with the valuenull
.This method is the same as
CompletableFuture.allOf(CompletableFuture[])
, except that the parameter type is more genericCompletionStage
instead ofCompletableFuture
.If you need the results of given stages, prefer below methods:
allResultsOf(CompletionStage[])
allTupleOf(CompletionStage, CompletionStage)
/allTupleOf(CompletionStage, CompletionStage, CompletionStage, CompletionStage, CompletionStage)
If you need the successful results of given stages in the given time, prefer below methods:
- Parameters:
cfs
- the stages- Returns:
- a new CompletableFuture that is completed when all the given stages complete
- Throws:
NullPointerException
- if the array or any of its elements arenull
-
anySuccessOf
@Contract(pure=true) @SafeVarargs public static <T> CompletableFuture<T> anySuccessOf(CompletionStage<? extends T>... cfs) Returns a new CompletableFuture that is successful when any of the given stages success, with the same result. Otherwise, all the given stages complete exceptionally, the returned CompletableFuture also does so, with a CompletionException holding an exception from any of the given stages as its cause. If no stages are provided, returns a new CompletableFuture that is already completed exceptionally with a CompletionException holding aNoCfsProvidedException
as its cause.This method is the same as
anyOf(CompletionStage[])
except for the any-success behavior instead of any-complete.- Parameters:
cfs
- the stages- Returns:
- a new CompletableFuture that is successful when any of the given stages success, with the same result
- Throws:
NullPointerException
- if the array or any of its elements arenull
-
anyOf
@Contract(pure=true) @SafeVarargs public static <T> CompletableFuture<T> anyOf(CompletionStage<? extends T>... cfs) Returns a new CompletableFuture that is completed when any of the given stages complete, with the same result. Otherwise, if it completed exceptionally, the returned CompletableFuture also does so, with a CompletionException holding this exception as its cause. If no stages are provided, returns an incomplete CompletableFuture.This method is the same as
CompletableFuture.anyOf(CompletableFuture[])
, except that the parameter type is more genericCompletionStage
instead ofCompletableFuture
, and the return type is more specificT
instead ofObject
.- Parameters:
cfs
- the stages- Returns:
- a new CompletableFuture that is completed with the result or exception from any of the given stages when one completes
- Throws:
NullPointerException
- if the array or any of its elements arenull
- See Also:
-
allTupleFastFailOf
@Contract(pure=true) public static <T1,T2> CompletableFuture<Tuple2<T1,T2>> allTupleFastFailOf(CompletionStage<? extends T1> cf1, CompletionStage<? extends T2> cf2) Returns a new CompletableFuture that is successful when the given stages success. If any of the given stages complete exceptionally, then the returned CompletableFuture also does so *without* waiting other incomplete given stages, with a CompletionException holding this exception as its cause.- Returns:
- a new CompletableFuture that is successful when the given stages success
- Throws:
NullPointerException
- if any of the given stages arenull
- See Also:
-
allTupleFastFailOf
@Contract(pure=true) public static <T1,T2, CompletableFuture<Tuple3<T1,T3> T2, allTupleFastFailOfT3>> (CompletionStage<? extends T1> cf1, CompletionStage<? extends T2> cf2, CompletionStage<? extends T3> cf3) Returns a new CompletableFuture that is successful when the given stages success. If any of the given stages complete exceptionally, then the returned CompletableFuture also does so *without* waiting other incomplete given stages, with a CompletionException holding this exception as its cause.- Returns:
- a new CompletableFuture that is successful when the given stages success
- Throws:
NullPointerException
- if any of the given stages arenull
- See Also:
-
allTupleFastFailOf
@Contract(pure=true) public static <T1,T2, CompletableFuture<Tuple4<T1,T3, T4> T2, allTupleFastFailOfT3, T4>> (CompletionStage<? extends T1> cf1, CompletionStage<? extends T2> cf2, CompletionStage<? extends T3> cf3, CompletionStage<? extends T4> cf4) Returns a new CompletableFuture that is successful when the given stages success. If any of the given stages complete exceptionally, then the returned CompletableFuture also does so *without* waiting other incomplete given stages, with a CompletionException holding this exception as its cause.- Returns:
- a new CompletableFuture that is successful when the given stages success
- Throws:
NullPointerException
- if any of the given stages arenull
- See Also:
-
allTupleFastFailOf
@Contract(pure=true) public static <T1,T2, CompletableFuture<Tuple5<T1,T3, T4, T5> T2, allTupleFastFailOfT3, T4, T5>> (CompletionStage<? extends T1> cf1, CompletionStage<? extends T2> cf2, CompletionStage<? extends T3> cf3, CompletionStage<? extends T4> cf4, CompletionStage<? extends T5> cf5) Returns a new CompletableFuture that is successful when the given stages success. If any of the given stages complete exceptionally, then the returned CompletableFuture also does so *without* waiting other incomplete given stages, with a CompletionException holding this exception as its cause.- Returns:
- a new CompletableFuture that is successful when the given stages success
- Throws:
NullPointerException
- if any of the given stages arenull
- See Also:
-
allSuccessTupleOf
@Contract(pure=true) public static <T1,T2> CompletableFuture<Tuple2<T1,T2>> allSuccessTupleOf(CompletionStage<? extends T1> cf1, CompletionStage<? extends T2> cf2) Returns a new CompletableFuture that is successful with the results of the given stages arguments when all the given stages completed; If the given stage complete exceptionally, treat it successful with value valueIfFailed.- Returns:
- a new CompletableFuture
- Throws:
NullPointerException
- if any of the given stages arenull
- See Also:
-
allSuccessTupleOf
@Contract(pure=true) public static <T1,T2, CompletableFuture<Tuple3<T1,T3> T2, allSuccessTupleOfT3>> (CompletionStage<? extends T1> cf1, CompletionStage<? extends T2> cf2, CompletionStage<? extends T3> cf3) Returns a new CompletableFuture that is successful with the results of the given stages arguments when all the given stages completed; If the given stage complete exceptionally, treat it successful with value valueIfFailed.- Returns:
- a new CompletableFuture
- Throws:
NullPointerException
- if any of the given stages arenull
- See Also:
-
allSuccessTupleOf
@Contract(pure=true) public static <T1,T2, CompletableFuture<Tuple4<T1,T3, T4> T2, allSuccessTupleOfT3, T4>> (CompletionStage<? extends T1> cf1, CompletionStage<? extends T2> cf2, CompletionStage<? extends T3> cf3, CompletionStage<? extends T4> cf4) Returns a new CompletableFuture that is successful with the results of the given stages arguments when all the given stages completed; If the given stage complete exceptionally, treat it successful with value valueIfFailed.- Returns:
- a new CompletableFuture
- Throws:
NullPointerException
- if any of the given stages arenull
- See Also:
-
allSuccessTupleOf
@Contract(pure=true) public static <T1,T2, CompletableFuture<Tuple5<T1,T3, T4, T5> T2, allSuccessTupleOfT3, T4, T5>> (CompletionStage<? extends T1> cf1, CompletionStage<? extends T2> cf2, CompletionStage<? extends T3> cf3, CompletionStage<? extends T4> cf4, CompletionStage<? extends T5> cf5) Returns a new CompletableFuture that is successful with the results of the given stages arguments when all the given stages completed; If the given stage complete exceptionally, treat it successful with value valueIfFailed.- Returns:
- a new CompletableFuture
- Throws:
NullPointerException
- if any of the given stages arenull
- See Also:
-
mostSuccessTupleOf
@Contract(pure=true) public static <T1,T2> CompletableFuture<Tuple2<T1,T2>> mostSuccessTupleOf(long timeout, TimeUnit unit, CompletionStage<? extends T1> cf1, CompletionStage<? extends T2> cf2) Returns a new CompletableFuture with the most results in the same order of the given stages arguments in the given time(timeout
, aka as many results as possible in the given time).If the given stage is successful, its result is the completed value; Otherwise the value
null
.- Parameters:
timeout
- how long to wait in units ofunit
unit
- aTimeUnit
determining how to interpret thetimeout
parameter- Returns:
- a new CompletableFuture
- See Also:
-
mostSuccessTupleOf
@Contract(pure=true) public static <T1,T2> CompletableFuture<Tuple2<T1,T2>> mostSuccessTupleOf(Executor executorWhenTimeout, long timeout, TimeUnit unit, CompletionStage<? extends T1> cf1, CompletionStage<? extends T2> cf2) Returns a new CompletableFuture with the most results in the same order of the given stages arguments in the given time(timeout
, aka as many results as possible in the given time).If the given stage is successful, its result is the completed value; Otherwise the value
null
.- Parameters:
executorWhenTimeout
- the async executor when triggered by timeouttimeout
- how long to wait in units ofunit
unit
- aTimeUnit
determining how to interpret thetimeout
parameter- Returns:
- a new CompletableFuture
- See Also:
-
mostSuccessTupleOf
@Contract(pure=true) public static <T1,T2, CompletableFuture<Tuple3<T1,T3> T2, mostSuccessTupleOfT3>> (long timeout, TimeUnit unit, CompletionStage<? extends T1> cf1, CompletionStage<? extends T2> cf2, CompletionStage<? extends T3> cf3) Returns a new CompletableFuture with the most results in the same order of the given stages arguments in the given time(timeout
, aka as many results as possible in the given time).If the given stage is successful, its result is the completed value; Otherwise the value
null
.- Parameters:
timeout
- how long to wait in units ofunit
unit
- aTimeUnit
determining how to interpret thetimeout
parameter- Returns:
- a new CompletableFuture
- See Also:
-
mostSuccessTupleOf
@Contract(pure=true) public static <T1,T2, CompletableFuture<Tuple3<T1,T3> T2, mostSuccessTupleOfT3>> (Executor executorWhenTimeout, long timeout, TimeUnit unit, CompletionStage<? extends T1> cf1, CompletionStage<? extends T2> cf2, CompletionStage<? extends T3> cf3) Returns a new CompletableFuture with the most results in the same order of the given stages arguments in the given time(timeout
, aka as many results as possible in the given time).If the given stage is successful, its result is the completed value; Otherwise the value
null
.- Parameters:
executorWhenTimeout
- the async executor when triggered by timeouttimeout
- how long to wait in units ofunit
unit
- aTimeUnit
determining how to interpret thetimeout
parameter- Returns:
- a new CompletableFuture
- See Also:
-
mostSuccessTupleOf
@Contract(pure=true) public static <T1,T2, CompletableFuture<Tuple4<T1,T3, T4> T2, mostSuccessTupleOfT3, T4>> (long timeout, TimeUnit unit, CompletionStage<? extends T1> cf1, CompletionStage<? extends T2> cf2, CompletionStage<? extends T3> cf3, CompletionStage<? extends T4> cf4) Returns a new CompletableFuture with the most results in the same order of the given stages arguments in the given time(timeout
, aka as many results as possible in the given time).If the given stage is successful, its result is the completed value; Otherwise the value
null
.- Parameters:
timeout
- how long to wait in units ofunit
unit
- aTimeUnit
determining how to interpret thetimeout
parameter- Returns:
- a new CompletableFuture
- See Also:
-
mostSuccessTupleOf
@Contract(pure=true) public static <T1,T2, CompletableFuture<Tuple4<T1,T3, T4> T2, mostSuccessTupleOfT3, T4>> (Executor executorWhenTimeout, long timeout, TimeUnit unit, CompletionStage<? extends T1> cf1, CompletionStage<? extends T2> cf2, CompletionStage<? extends T3> cf3, CompletionStage<? extends T4> cf4) Returns a new CompletableFuture with the most results in the same order of the given stages arguments in the given time(timeout
, aka as many results as possible in the given time).If the given stage is successful, its result is the completed value; Otherwise the value
null
.- Parameters:
executorWhenTimeout
- the async executor when triggered by timeouttimeout
- how long to wait in units ofunit
unit
- aTimeUnit
determining how to interpret thetimeout
parameter- Returns:
- a new CompletableFuture
- See Also:
-
mostSuccessTupleOf
@Contract(pure=true) public static <T1,T2, CompletableFuture<Tuple5<T1,T3, T4, T5> T2, mostSuccessTupleOfT3, T4, T5>> (long timeout, TimeUnit unit, CompletionStage<? extends T1> cf1, CompletionStage<? extends T2> cf2, CompletionStage<? extends T3> cf3, CompletionStage<? extends T4> cf4, CompletionStage<? extends T5> cf5) Returns a new CompletableFuture with the most results in the same order of the given stages arguments in the given time(timeout
, aka as many results as possible in the given time).If the given stage is successful, its result is the completed value; Otherwise the value
null
.- Parameters:
timeout
- how long to wait in units ofunit
unit
- aTimeUnit
determining how to interpret thetimeout
parameter- Returns:
- a new CompletableFuture
- See Also:
-
mostSuccessTupleOf
@Contract(pure=true) public static <T1,T2, CompletableFuture<Tuple5<T1,T3, T4, T5> T2, mostSuccessTupleOfT3, T4, T5>> (Executor executorWhenTimeout, long timeout, TimeUnit unit, CompletionStage<? extends T1> cf1, CompletionStage<? extends T2> cf2, CompletionStage<? extends T3> cf3, CompletionStage<? extends T4> cf4, CompletionStage<? extends T5> cf5) Returns a new CompletableFuture with the most results in the same order of the given stages arguments in the given time(timeout
, aka as many results as possible in the given time).If the given stage is successful, its result is the completed value; Otherwise the value
null
.- Parameters:
executorWhenTimeout
- the async executor when triggered by timeouttimeout
- how long to wait in units ofunit
unit
- aTimeUnit
determining how to interpret thetimeout
parameter- Returns:
- a new CompletableFuture
- See Also:
-
allTupleOf
@Contract(pure=true) public static <T1,T2> CompletableFuture<Tuple2<T1,T2>> allTupleOf(CompletionStage<? extends T1> cf1, CompletionStage<? extends T2> cf2) Returns a new CompletableFuture that is completed when the given stages complete. If any of the given stages complete exceptionally, then the returned CompletableFuture also does so, with a CompletionException holding this exception as its cause.- Returns:
- a new CompletableFuture that is completed when the given stages complete
- Throws:
NullPointerException
- if any of the given stages arenull
- See Also:
-
allTupleOf
@Contract(pure=true) public static <T1,T2, CompletableFuture<Tuple3<T1,T3> T2, allTupleOfT3>> (CompletionStage<? extends T1> cf1, CompletionStage<? extends T2> cf2, CompletionStage<? extends T3> cf3) Returns a new CompletableFuture that is completed when the given stages complete. If any of the given stages complete exceptionally, then the returned CompletableFuture also does so, with a CompletionException holding this exception as its cause.- Returns:
- a new CompletableFuture that is completed when the given stages complete
- Throws:
NullPointerException
- if any of the given stages arenull
- See Also:
-
allTupleOf
@Contract(pure=true) public static <T1,T2, CompletableFuture<Tuple4<T1,T3, T4> T2, allTupleOfT3, T4>> (CompletionStage<? extends T1> cf1, CompletionStage<? extends T2> cf2, CompletionStage<? extends T3> cf3, CompletionStage<? extends T4> cf4) Returns a new CompletableFuture that is completed when the given stages complete. If any of the given stages complete exceptionally, then the returned CompletableFuture also does so, with a CompletionException holding this exception as its cause.- Returns:
- a new CompletableFuture that is completed when the given stages complete
- Throws:
NullPointerException
- if any of the given stages arenull
- See Also:
-
allTupleOf
@Contract(pure=true) public static <T1,T2, CompletableFuture<Tuple5<T1,T3, T4, T5> T2, allTupleOfT3, T4, T5>> (CompletionStage<? extends T1> cf1, CompletionStage<? extends T2> cf2, CompletionStage<? extends T3> cf3, CompletionStage<? extends T4> cf4, CompletionStage<? extends T5> cf5) Returns a new CompletableFuture that is completed when the given stages complete. If any of the given stages complete exceptionally, then the returned CompletableFuture also does so, with a CompletionException holding this exception as its cause.- Returns:
- a new CompletableFuture that is completed when the given stages complete
- Throws:
NullPointerException
- if any of the given stages arenull
- See Also:
-
failedFuture
Returns a new CompletableFuture that is already completed exceptionally with the given exception.- Type Parameters:
T
- the type of the value- Parameters:
ex
- the exception- Returns:
- the exceptionally completed CompletableFuture
-
completedStage
Returns a new CompletionStage that is already completed with the given value and supports only those methods in interfaceCompletionStage
.CAUTION:
if run on old Java 8(not support *minimal* CompletionStage), just return a *normal* CompletableFuture which is NOT with a *minimal* CompletionStage.- Type Parameters:
T
- the type of the value- Parameters:
value
- the value- Returns:
- the completed CompletionStage
-
failedStage
Returns a new CompletionStage that is already completed exceptionally with the given exception and supports only those methods in interfaceCompletionStage
.CAUTION:
if run on old Java 8(not support *minimal* CompletionStage), just return a *normal* CompletableFuture which is NOT with a *minimal* CompletionStage.- Type Parameters:
T
- the type of the value- Parameters:
ex
- the exception- Returns:
- the exceptionally completed CompletionStage
-
delayedExecutor
Returns a new Executor that submits a task to the default executor after the given delay (or no delay if non-positive). Each delay commences upon invocation of the returned executor'sexecute
method.- Parameters:
delay
- how long to delay, in units ofunit
unit
- aTimeUnit
determining how to interpret thedelay
parameter- Returns:
- the new delayed executor
-
delayedExecutor
@Contract(pure=true) public static Executor delayedExecutor(long delay, TimeUnit unit, Executor executor) Returns a new Executor that submits a task to the given base executor after the given delay (or no delay if non-positive). Each delay commences upon invocation of the returned executor'sexecute
method.- Parameters:
delay
- how long to delay, in units ofunit
unit
- aTimeUnit
determining how to interpret thedelay
parameterexecutor
- the base executor- Returns:
- the new delayed executor
-
defaultExecutor
Returns the default Executor used for async methods that do not specify an Executor. This class uses theForkJoinPool.commonPool()
if it supports more than one parallel thread, or else an Executor using one thread per async task.
CAUTION: This executor may be not suitable for common biz use(io intensive). -
thenMApplyFastFailAsync
@SafeVarargs public static <T,U> CompletableFuture<List<U>> thenMApplyFastFailAsync(CompletableFuture<? extends T> cfThis, Function<? super T, ? extends U>... fns) Returns a new CompletableFuture that, when the given stage completes normally, is executed using the CompletableFuture's default asynchronous execution facility, with the values obtained by calling the given Functions (with the given stage's result as the argument to the given functions) in the same order of the given Functions arguments.- Type Parameters:
U
- the functions' return type- Parameters:
fns
- the functions to use to compute the values of the returned CompletableFuture- Returns:
- the new CompletableFuture
-
thenMApplyFastFailAsync
@SafeVarargs public static <T,U> CompletableFuture<List<U>> thenMApplyFastFailAsync(CompletableFuture<? extends T> cfThis, Executor executor, Function<? super T, ? extends U>... fns) Returns a new CompletableFuture that, when the given stage completes normally, is executed using the given Executor, with the values obtained by calling the given Functions (with the given stage's result as the argument to the given functions) in the same order of the given Functions arguments.- Type Parameters:
U
- the functions' return type- Parameters:
executor
- the executor to use for asynchronous executionfns
- the functions to use to compute the values of the returned CompletableFuture- Returns:
- the new CompletableFuture
-
thenMApplyAllSuccessAsync
@SafeVarargs public static <T,U> CompletableFuture<List<U>> thenMApplyAllSuccessAsync(CompletableFuture<? extends T> cfThis, @Nullable U valueIfFailed, Function<? super T, ? extends U>... fns) Returns a new CompletableFuture that, when the given stage completes normally, is executed in the CompletableFuture's default asynchronous execution facility with the successful values obtained by calling the given Functions (with the given stage's result as the argument to the given functions) in the same order of the given Functions arguments.If the given Functions failed, use the given valueIfFailed.
- Type Parameters:
U
- the functions' return type- Parameters:
valueIfFailed
- the value to return if not completed successfullyfns
- the functions to use to compute the values of the returned CompletableFuture- Returns:
- the new CompletableFuture
-
thenMApplyAllSuccessAsync
@SafeVarargs public static <T,U> CompletableFuture<List<U>> thenMApplyAllSuccessAsync(CompletableFuture<? extends T> cfThis, @Nullable U valueIfFailed, Executor executor, Function<? super T, ? extends U>... fns) Returns a new CompletableFuture that, when the given stage completes normally, is executed in the given Executor with the successful values obtained by calling the given Functions (with the given stage's result as the argument to the given functions) in the same order of the given Functions arguments.If the given Functions failed, use the given valueIfFailed.
- Type Parameters:
U
- the functions' return type- Parameters:
valueIfFailed
- the value to return if not completed successfullyfns
- the functions to use to compute the values of the returned CompletableFuture- Returns:
- the new CompletableFuture
-
thenMApplyMostSuccessAsync
@SafeVarargs public static <T,U> CompletableFuture<List<U>> thenMApplyMostSuccessAsync(CompletableFuture<? extends T> cfThis, @Nullable U valueIfNotSuccess, long timeout, TimeUnit unit, Function<? super T, ? extends U>... fns) Returns a new CompletableFuture that, when the given stage completes normally, is executed using the CompletableFuture's default asynchronous execution facility, with the most values obtained by calling the given Functions (with the given stage's result as the argument to the given functions) in the given time(timeout
, aka as many results as possible in the given time) in the same order of the given Functions arguments.If the given function is successful in the given time, the return result is the completed value; Otherwise the given valueIfNotSuccess.
- Type Parameters:
U
- the functions' return type- Parameters:
valueIfNotSuccess
- the value to return if not completed successfullytimeout
- how long to wait in units ofunit
unit
- aTimeUnit
determining how to interpret thetimeout
parameterfns
- the functions to use to compute the values of the returned CompletableFuture- Returns:
- the new CompletableFuture
-
thenMApplyMostSuccessAsync
@SafeVarargs public static <T,U> CompletableFuture<List<U>> thenMApplyMostSuccessAsync(CompletableFuture<? extends T> cfThis, @Nullable U valueIfNotSuccess, Executor executor, long timeout, TimeUnit unit, Function<? super T, ? extends U>... fns) Returns a new CompletableFuture that, when the given stage completes normally, is executed using the given Executor, with the most values obtained by calling the given Functions (with the given stage's result as the argument to the given functions) in the given time(timeout
, aka as many results as possible in the given time) in the same order of the given Functions arguments.If the given function is successful in the given time, the return result is the completed value; Otherwise the given valueIfNotSuccess.
- Type Parameters:
U
- the functions' return type- Parameters:
valueIfNotSuccess
- the value to return if not completed successfullyexecutor
- the executor to use for asynchronous executiontimeout
- how long to wait in units ofunit
unit
- aTimeUnit
determining how to interpret thetimeout
parameterfns
- the functions to use to compute the values of the returned CompletableFuture- Returns:
- the new CompletableFuture
-
thenMApplyAsync
@SafeVarargs public static <T,U> CompletableFuture<List<U>> thenMApplyAsync(CompletableFuture<? extends T> cfThis, Function<? super T, ? extends U>... fns) Returns a new CompletableFuture that, when the given stage completes normally, is executed using the CompletableFuture's default asynchronous execution facility, with the values obtained by calling the given Functions (with the given stage's result as the argument to the given functions) in the same order of the given Functions arguments.- Type Parameters:
U
- the functions' return type- Parameters:
fns
- the functions to use to compute the values of the returned CompletableFuture- Returns:
- the new CompletableFuture
-
thenMApplyAsync
@SafeVarargs public static <T,U> CompletableFuture<List<U>> thenMApplyAsync(CompletableFuture<? extends T> cfThis, Executor executor, Function<? super T, ? extends U>... fns) Returns a new CompletableFuture that, when the given stage completes normally, is executed using the given Executor, with the values obtained by calling the given Functions (with the given stage's result as the argument to the given functions) in the same order of the given Functions arguments.- Type Parameters:
U
- the functions' return type- Parameters:
executor
- the executor to use for asynchronous executionfns
- the functions to use to compute the values of the returned CompletableFuture- Returns:
- the new CompletableFuture
-
thenMApplyAnySuccessAsync
@SafeVarargs public static <T,U> CompletableFuture<U> thenMApplyAnySuccessAsync(CompletableFuture<? extends T> cfThis, Function<? super T, ? extends U>... fns) Returns a new CompletableFuture that, when the given stage completes normally, is executed using the CompletableFuture's default asynchronous execution facility, with any successful value obtained by calling the given Functions (with the given stage's result as the argument to the given functions).- Type Parameters:
U
- the functions' return type- Parameters:
fns
- the functions to use to compute the values of the returned CompletableFuture- Returns:
- the new CompletableFuture
-
thenMApplyAnySuccessAsync
@SafeVarargs public static <T,U> CompletableFuture<U> thenMApplyAnySuccessAsync(CompletableFuture<? extends T> cfThis, Executor executor, Function<? super T, ? extends U>... fns) Returns a new CompletableFuture that, when the given stage completes normally, is executed using the given Executor, with any successful value obtained by calling the given Functions (with the given stage's result as the argument to the given functions).- Type Parameters:
U
- the functions' return type- Parameters:
executor
- the executor to use for asynchronous executionfns
- the functions to use to compute the values of the returned CompletableFuture- Returns:
- the new CompletableFuture
-
thenMApplyAnyAsync
@SafeVarargs public static <T,U> CompletableFuture<U> thenMApplyAnyAsync(CompletableFuture<? extends T> cfThis, Function<? super T, ? extends U>... fns) Returns a new CompletableFuture that, when the given stage completes normally, is executed using the CompletableFuture's default asynchronous execution facility, with any completed result obtained by calling the given Functions (with the given stage's result as the argument to the given functions).- Type Parameters:
U
- the functions' return type- Parameters:
fns
- the functions to use to compute the values of the returned CompletableFuture- Returns:
- the new CompletableFuture
-
thenMApplyAnyAsync
@SafeVarargs public static <T,U> CompletableFuture<U> thenMApplyAnyAsync(CompletableFuture<? extends T> cfThis, Executor executor, Function<? super T, ? extends U>... fns) Returns a new CompletableFuture that, when the given stage completes normally, is executed using the given Executor, with any completed result obtained by calling the given Functions (with the given stage's result as the argument to the given functions).- Type Parameters:
U
- the functions' return type- Parameters:
executor
- the executor to use for asynchronous executionfns
- the functions to use to compute the values of the returned CompletableFuture- Returns:
- the new CompletableFuture
-
thenMAcceptFastFailAsync
@SafeVarargs public static <T> CompletableFuture<Void> thenMAcceptFastFailAsync(CompletableFuture<? extends T> cfThis, Consumer<? super T>... actions) Returns a new CompletableFuture that, when the given stage completes normally, is executed using the CompletableFuture's default asynchronous execution facility, with the given stage's result as the argument to the given actions.- Parameters:
actions
- the actions to perform before completing the returned CompletableFuture- Returns:
- the new CompletableFuture
-
thenMAcceptFastFailAsync
@SafeVarargs public static <T> CompletableFuture<Void> thenMAcceptFastFailAsync(CompletableFuture<? extends T> cfThis, Executor executor, Consumer<? super T>... actions) Returns a new CompletableFuture that, when the given stage completes normally, is executed using the given Executor, with the given stage's result as the argument to the given actions.- Parameters:
executor
- the executor to use for asynchronous executionactions
- the actions to perform before completing the returned CompletableFuture- Returns:
- the new CompletableFuture
-
thenMAcceptAsync
@SafeVarargs public static <T> CompletableFuture<Void> thenMAcceptAsync(CompletableFuture<? extends T> cfThis, Consumer<? super T>... actions) Returns a new CompletableFuture that, when the given stage completes normally, is executed using the CompletableFuture's default asynchronous execution facility, with the given stage's result as the argument to the given actions.- Parameters:
actions
- the actions to perform before completing the returned CompletableFuture- Returns:
- the new CompletableFuture
-
thenMAcceptAsync
@SafeVarargs public static <T> CompletableFuture<Void> thenMAcceptAsync(CompletableFuture<? extends T> cfThis, Executor executor, Consumer<? super T>... actions) Returns a new CompletableFuture that, when the given stage completes normally, is executed using the given Executor, with the given stage's result as the argument to the given actions.- Parameters:
executor
- the executor to use for asynchronous executionactions
- the actions to perform before completing the returned CompletableFuture- Returns:
- the new CompletableFuture
-
thenMAcceptAnySuccessAsync
@SafeVarargs public static <T> CompletableFuture<Void> thenMAcceptAnySuccessAsync(CompletableFuture<? extends T> cfThis, Consumer<? super T>... actions) Returns a new CompletableFuture that, when the given stage completes normally, is executed using the CompletableFuture's default asynchronous execution facility, with the given stage's result as the argument to the given actions.- Parameters:
actions
- the actions to perform before completing the returned CompletableFuture- Returns:
- the new CompletableFuture
-
thenMAcceptAnySuccessAsync
@SafeVarargs public static <T> CompletableFuture<Void> thenMAcceptAnySuccessAsync(CompletableFuture<? extends T> cfThis, Executor executor, Consumer<? super T>... actions) Returns a new CompletableFuture that, when the given stage completes normally, is executed using the given Executor, with the given stage's result as the argument to the given actions.- Parameters:
executor
- the executor to use for asynchronous executionactions
- the actions to perform before completing the returned CompletableFuture- Returns:
- the new CompletableFuture
-
thenMAcceptAnyAsync
@SafeVarargs public static <T> CompletableFuture<Void> thenMAcceptAnyAsync(CompletableFuture<? extends T> cfThis, Consumer<? super T>... actions) Returns a new CompletableFuture that, when the given stage completes normally, is executed using the CompletableFuture's default asynchronous execution facility, with the given stage's result as the argument to the given actions.- Parameters:
actions
- the actions to perform before completing the returned CompletableFuture- Returns:
- the new CompletableFuture
-
thenMAcceptAnyAsync
@SafeVarargs public static <T> CompletableFuture<Void> thenMAcceptAnyAsync(CompletableFuture<? extends T> cfThis, Executor executor, Consumer<? super T>... actions) Returns a new CompletableFuture that, when the given stage completes normally, is executed using the given Executor, with the given stage's result as the argument to the given actions.- Parameters:
executor
- the executor to use for asynchronous executionactions
- the actions to perform before completing the returned CompletableFuture- Returns:
- the new CompletableFuture
-
thenMRunFastFailAsync
public static CompletableFuture<Void> thenMRunFastFailAsync(CompletableFuture<?> cfThis, Runnable... actions) Returns a new CompletableFuture that, when the given stage completes normally, executes the given actions using the CompletableFuture's default asynchronous execution facility.- Parameters:
actions
- the actions to perform before completing the returned CompletableFuture- Returns:
- the new CompletableFuture
- See Also:
-
thenMRunFastFailAsync
public static CompletableFuture<Void> thenMRunFastFailAsync(CompletableFuture<?> cfThis, Executor executor, Runnable... actions) Returns a new CompletableFuture that, when the given stage completes normally, executes the given actions using the given Executor.- Parameters:
executor
- the executor to use for asynchronous executionactions
- the actions to perform before completing the returned CompletableFuture- Returns:
- the new CompletableFuture
- See Also:
-
thenMRunAsync
public static CompletableFuture<Void> thenMRunAsync(CompletableFuture<?> cfThis, Runnable... actions) Returns a new CompletableFuture that, when the given stage completes normally, executes the given actions using the CompletableFuture's default asynchronous execution facility.- Parameters:
actions
- the actions to perform before completing the returned CompletableFuture- Returns:
- the new CompletableFuture
- See Also:
-
thenMRunAsync
public static CompletableFuture<Void> thenMRunAsync(CompletableFuture<?> cfThis, Executor executor, Runnable... actions) Returns a new CompletableFuture that, when the given stage completes normally, executes the given actions using the given Executor.- Parameters:
executor
- the executor to use for asynchronous executionactions
- the actions to perform before completing the returned CompletableFuture- Returns:
- the new CompletableFuture
- See Also:
-
thenMRunAnySuccessAsync
public static CompletableFuture<Void> thenMRunAnySuccessAsync(CompletableFuture<?> cfThis, Runnable... actions) Returns a new CompletableFuture that, when the given stage completes normally, executes the given actions using the CompletableFuture's default asynchronous execution facility.- Parameters:
actions
- the actions to perform before completing the returned CompletableFuture- Returns:
- the new CompletableFuture
- See Also:
-
thenMRunAnySuccessAsync
public static CompletableFuture<Void> thenMRunAnySuccessAsync(CompletableFuture<?> cfThis, Executor executor, Runnable... actions) Returns a new CompletableFuture that, when the given stage completes normally, executes the given actions using the given Executor.- Parameters:
executor
- the executor to use for asynchronous executionactions
- the actions to perform before completing the returned CompletableFuture- Returns:
- the new CompletableFuture
- See Also:
-
thenMRunAnyAsync
public static CompletableFuture<Void> thenMRunAnyAsync(CompletableFuture<?> cfThis, Runnable... actions) Returns a new CompletableFuture that, when the given stage completes normally, executes the given actions using the CompletableFuture's default asynchronous execution facility.- Parameters:
actions
- the actions to perform before completing the returned CompletableFuture- Returns:
- the new CompletableFuture
- See Also:
-
thenMRunAnyAsync
public static CompletableFuture<Void> thenMRunAnyAsync(CompletableFuture<?> cfThis, Executor executor, Runnable... actions) Returns a new CompletableFuture that, when the given stage completes normally, executes the given actions using the given Executor.- Parameters:
executor
- the executor to use for asynchronous executionactions
- the actions to perform before completing the returned CompletableFuture- Returns:
- the new CompletableFuture
- See Also:
-
thenTupleMApplyFastFailAsync
public static <T,U1, CompletableFuture<Tuple2<U1,U2> U2>> thenTupleMApplyFastFailAsync(CompletableFuture<? extends T> cfThis, Function<? super T, ? extends U1> fn1, Function<? super T, ? extends U2> fn2) Returns a new CompletableFuture that, when the given stage completes normally, is executed using the CompletableFuture's default asynchronous execution facility, with the values obtained by calling the given Functions (with the given stage's result as the argument to the given functions) in the same order of the given Functions arguments.- Returns:
- the new CompletableFuture
-
thenTupleMApplyFastFailAsync
public static <T,U1, CompletableFuture<Tuple2<U1,U2> U2>> thenTupleMApplyFastFailAsync(CompletableFuture<? extends T> cfThis, Executor executor, Function<? super T, ? extends U1> fn1, Function<? super T, ? extends U2> fn2) Returns a new CompletableFuture that, when the given stage completes normally, is executed using the given Executor, with the values obtained by calling the given Functions (with the given stage's result as the argument to the given functions) in the same order of the given Functions arguments.- Parameters:
executor
- the executor to use for asynchronous execution- Returns:
- the new CompletableFuture
-
thenTupleMApplyFastFailAsync
public static <T,U1, CompletableFuture<Tuple3<U1,U2, U3> U2, thenTupleMApplyFastFailAsyncU3>> (CompletableFuture<? extends T> cfThis, Function<? super T, ? extends U1> fn1, Function<? super T, ? extends U2> fn2, Function<? super T, ? extends U3> fn3) Returns a new CompletableFuture that, when the given stage completes normally, is executed using the CompletableFuture's default asynchronous execution facility, with the values obtained by calling the given Functions (with the given stage's result as the argument to the given functions) in the same order of the given Functions arguments.- Returns:
- the new CompletableFuture
-
thenTupleMApplyFastFailAsync
public static <T,U1, CompletableFuture<Tuple3<U1,U2, U3> U2, thenTupleMApplyFastFailAsyncU3>> (CompletableFuture<? extends T> cfThis, Executor executor, Function<? super T, ? extends U1> fn1, Function<? super T, ? extends U2> fn2, Function<? super T, ? extends U3> fn3) Returns a new CompletableFuture that, when the given stage completes normally, is executed using the given Executor, with the values obtained by calling the given Functions (with the given stage's result as the argument to the given functions) in the same order of the given Functions arguments.- Parameters:
executor
- the executor to use for asynchronous execution- Returns:
- the new CompletableFuture
-
thenTupleMApplyFastFailAsync
public static <T,U1, CompletableFuture<Tuple4<U1,U2, U3, U4> U2, thenTupleMApplyFastFailAsyncU3, U4>> (CompletableFuture<? extends T> cfThis, Function<? super T, ? extends U1> fn1, Function<? super T, ? extends U2> fn2, Function<? super T, ? extends U3> fn3, Function<? super T, ? extends U4> fn4) Returns a new CompletableFuture that, when the given stage completes normally, is executed using the CompletableFuture's default asynchronous execution facility, with the values obtained by calling the given Functions (with the given stage's result as the argument to the given functions) in the same order of the given Functions arguments.- Returns:
- the new CompletableFuture
-
thenTupleMApplyFastFailAsync
public static <T,U1, CompletableFuture<Tuple4<U1,U2, U3, U4> U2, thenTupleMApplyFastFailAsyncU3, U4>> (CompletableFuture<? extends T> cfThis, Executor executor, Function<? super T, ? extends U1> fn1, Function<? super T, ? extends U2> fn2, Function<? super T, ? extends U3> fn3, Function<? super T, ? extends U4> fn4) Returns a new CompletableFuture that, when the given stage completes normally, is executed using the given Executor, with the values obtained by calling the given Functions (with the given stage's result as the argument to the given functions) in the same order of the given Functions arguments.- Parameters:
executor
- the executor to use for asynchronous execution- Returns:
- the new CompletableFuture
-
thenTupleMApplyFastFailAsync
public static <T,U1, CompletableFuture<Tuple5<U1,U2, U3, U4, U5> U2, thenTupleMApplyFastFailAsyncU3, U4, U5>> (CompletableFuture<? extends T> cfThis, Function<? super T, ? extends U1> fn1, Function<? super T, ? extends U2> fn2, Function<? super T, ? extends U3> fn3, Function<? super T, ? extends U4> fn4, Function<? super T, ? extends U5> fn5) Returns a new CompletableFuture that, when the given stage completes normally, is executed using the CompletableFuture's default asynchronous execution facility, with the values obtained by calling the given Functions (with the given stage's result as the argument to the given functions) in the same order of the given Functions arguments.- Returns:
- the new CompletableFuture
-
thenTupleMApplyFastFailAsync
public static <T,U1, CompletableFuture<Tuple5<U1,U2, U3, U4, U5> U2, thenTupleMApplyFastFailAsyncU3, U4, U5>> (CompletableFuture<? extends T> cfThis, Executor executor, Function<? super T, ? extends U1> fn1, Function<? super T, ? extends U2> fn2, Function<? super T, ? extends U3> fn3, Function<? super T, ? extends U4> fn4, Function<? super T, ? extends U5> fn5) Returns a new CompletableFuture that, when the given stage completes normally, is executed using the given Executor, with the values obtained by calling the given Functions (with the given stage's result as the argument to the given functions) in the same order of the given Functions arguments.- Parameters:
executor
- the executor to use for asynchronous execution- Returns:
- the new CompletableFuture
-
thenTupleMApplyAllSuccessAsync
public static <T,U1, CompletableFuture<Tuple2<U1,U2> U2>> thenTupleMApplyAllSuccessAsync(CompletableFuture<? extends T> cfThis, Function<? super T, ? extends U1> fn1, Function<? super T, ? extends U2> fn2) Returns a new CompletableFuture that, when the given stage completes normally, is executed in the CompletableFuture's default asynchronous execution facility with the successful values obtained by calling the given Functions (with the given stage's result as the argument to the given functions).If the given Functions failed, use
null
.- Returns:
- the new CompletableFuture
-
thenTupleMApplyAllSuccessAsync
public static <T,U1, CompletableFuture<Tuple2<U1,U2> U2>> thenTupleMApplyAllSuccessAsync(CompletableFuture<? extends T> cfThis, Executor executor, Function<? super T, ? extends U1> fn1, Function<? super T, ? extends U2> fn2) Returns a new CompletableFuture that, when the given stage completes normally, is executed in the given Executor with the successful values obtained by calling the given Functions (with the given stage's result as the argument to the given functions) in the same order of the given Functions arguments.If the given Functions failed, use
null
.- Parameters:
executor
- the executor to use for asynchronous execution- Returns:
- the new CompletableFuture
-
thenTupleMApplyAllSuccessAsync
public static <T,U1, CompletableFuture<Tuple3<U1,U2, U3> U2, thenTupleMApplyAllSuccessAsyncU3>> (CompletableFuture<? extends T> cfThis, Function<? super T, ? extends U1> fn1, Function<? super T, ? extends U2> fn2, Function<? super T, ? extends U3> fn3) Returns a new CompletableFuture that, when the given stage completes normally, is executed in the CompletableFuture's default asynchronous execution facility with the successful values obtained by calling the given Functions (with the given stage's result as the argument to the given functions) in the same order of the given Functions arguments.If the given Functions failed, use
null
.- Returns:
- the new CompletableFuture
-
thenTupleMApplyAllSuccessAsync
public static <T,U1, CompletableFuture<Tuple3<U1,U2, U3> U2, thenTupleMApplyAllSuccessAsyncU3>> (CompletableFuture<? extends T> cfThis, Executor executor, Function<? super T, ? extends U1> fn1, Function<? super T, ? extends U2> fn2, Function<? super T, ? extends U3> fn3) Returns a new CompletableFuture that, when the given stage completes normally, is executed in the given Executor with the successful values obtained by calling the given Functions (with the given stage's result as the argument to the given functions) in the same order of the given Functions arguments.If the given Functions failed, use
null
.- Parameters:
executor
- the executor to use for asynchronous execution- Returns:
- the new CompletableFuture
-
thenTupleMApplyAllSuccessAsync
public static <T,U1, CompletableFuture<Tuple4<U1,U2, U3, U4> U2, thenTupleMApplyAllSuccessAsyncU3, U4>> (CompletableFuture<? extends T> cfThis, Function<? super T, ? extends U1> fn1, Function<? super T, ? extends U2> fn2, Function<? super T, ? extends U3> fn3, Function<? super T, ? extends U4> fn4) Returns a new CompletableFuture that, when the given stage completes normally, is executed in the CompletableFuture's default asynchronous execution facility with the successful values obtained by calling the given Functions (with the given stage's result as the argument to the given functions) in the same order of the given Functions arguments.If the given Functions failed, use
null
.- Returns:
- the new CompletableFuture
-
thenTupleMApplyAllSuccessAsync
public static <T,U1, CompletableFuture<Tuple4<U1,U2, U3, U4> U2, thenTupleMApplyAllSuccessAsyncU3, U4>> (CompletableFuture<? extends T> cfThis, Executor executor, Function<? super T, ? extends U1> fn1, Function<? super T, ? extends U2> fn2, Function<? super T, ? extends U3> fn3, Function<? super T, ? extends U4> fn4) Returns a new CompletableFuture that, when the given stage completes normally, is executed in the given Executor with the successful values obtained by calling the given Functions (with the given stage's result as the argument to the given functions) in the same order of the given Functions arguments.If the given Functions failed, use
null
.- Parameters:
executor
- the executor to use for asynchronous execution- Returns:
- the new CompletableFuture
-
thenTupleMApplyAllSuccessAsync
public static <T,U1, CompletableFuture<Tuple5<U1,U2, U3, U4, U5> U2, thenTupleMApplyAllSuccessAsyncU3, U4, U5>> (CompletableFuture<? extends T> cfThis, Function<? super T, ? extends U1> fn1, Function<? super T, ? extends U2> fn2, Function<? super T, ? extends U3> fn3, Function<? super T, ? extends U4> fn4, Function<? super T, ? extends U5> fn5) Returns a new CompletableFuture that, when the given stage completes normally, is executed in the CompletableFuture's default asynchronous execution facility with the successful values obtained by calling the given Functions (with the given stage's result as the argument to the given functions) in the same order of the given Functions arguments.If the given Functions failed, use
null
.- Returns:
- the new CompletableFuture
-
thenTupleMApplyAllSuccessAsync
public static <T,U1, CompletableFuture<Tuple5<U1,U2, U3, U4, U5> U2, thenTupleMApplyAllSuccessAsyncU3, U4, U5>> (CompletableFuture<? extends T> cfThis, Executor executor, Function<? super T, ? extends U1> fn1, Function<? super T, ? extends U2> fn2, Function<? super T, ? extends U3> fn3, Function<? super T, ? extends U4> fn4, Function<? super T, ? extends U5> fn5) Returns a new CompletableFuture that, when the given stage completes normally, is executed in the given Executor with the successful values obtained by calling the given Functions (with the given stage's result as the argument to the given functions) in the same order of the given Functions arguments.If the given Functions failed, use
null
.- Parameters:
executor
- the executor to use for asynchronous execution- Returns:
- the new CompletableFuture
-
thenTupleMApplyMostSuccessAsync
public static <T,U1, CompletableFuture<Tuple2<U1,U2> U2>> thenTupleMApplyMostSuccessAsync(CompletableFuture<? extends T> cfThis, long timeout, TimeUnit unit, Function<? super T, ? extends U1> fn1, Function<? super T, ? extends U2> fn2) Returns a new CompletableFuture that, when the given stage completes normally, is executed using the CompletableFuture's default asynchronous execution facility, with the most values obtained by calling the given Functions (with the given stage's result as the argument to the given functions) in the given time(timeout
, aka as many results as possible in the given time) in the same order of the given Functions arguments.If the given function is successful in the given time, the return result is the completed value; Otherwise the given valueIfNotSuccess.
- Parameters:
timeout
- how long to wait in units ofunit
unit
- aTimeUnit
determining how to interpret thetimeout
parameter- Returns:
- the new CompletableFuture
-
thenTupleMApplyMostSuccessAsync
public static <T,U1, CompletableFuture<Tuple2<U1,U2> U2>> thenTupleMApplyMostSuccessAsync(CompletableFuture<? extends T> cfThis, Executor executor, long timeout, TimeUnit unit, Function<? super T, ? extends U1> fn1, Function<? super T, ? extends U2> fn2) Returns a new CompletableFuture that, when the given stage completes normally, is executed using the given Executor, with the most values obtained by calling the given Functions (with the given stage's result as the argument to the given functions) in the given time(timeout
, aka as many results as possible in the given time) in the same order of the given Functions arguments.If the given function is successful in the given time, the return result is the completed value; Otherwise the given valueIfNotSuccess.
- Parameters:
executor
- the executor to use for asynchronous executiontimeout
- how long to wait in units ofunit
unit
- aTimeUnit
determining how to interpret thetimeout
parameter- Returns:
- the new CompletableFuture
-
thenTupleMApplyMostSuccessAsync
public static <T,U1, CompletableFuture<Tuple3<U1,U2, U3> U2, thenTupleMApplyMostSuccessAsyncU3>> (CompletableFuture<? extends T> cfThis, long timeout, TimeUnit unit, Function<? super T, ? extends U1> fn1, Function<? super T, ? extends U2> fn2, Function<? super T, ? extends U3> fn3) Returns a new CompletableFuture that, when the given stage completes normally, is executed using the CompletableFuture's default asynchronous execution facility, with the most values obtained by calling the given Functions (with the given stage's result as the argument to the given functions) in the given time(timeout
, aka as many results as possible in the given time) in the same order of the given Functions arguments.If the given function is successful in the given time, the return result is the completed value; Otherwise the given valueIfNotSuccess.
- Parameters:
timeout
- how long to wait in units ofunit
unit
- aTimeUnit
determining how to interpret thetimeout
parameter- Returns:
- the new CompletableFuture
-
thenTupleMApplyMostSuccessAsync
public static <T,U1, CompletableFuture<Tuple3<U1,U2, U3> U2, thenTupleMApplyMostSuccessAsyncU3>> (CompletableFuture<? extends T> cfThis, Executor executor, long timeout, TimeUnit unit, Function<? super T, ? extends U1> fn1, Function<? super T, ? extends U2> fn2, Function<? super T, ? extends U3> fn3) Returns a new CompletableFuture that, when the given stage completes normally, is executed using the given Executor, with the most values obtained by calling the given Functions (with the given stage's result as the argument to the given functions) in the given time(timeout
, aka as many results as possible in the given time) in the same order of the given Functions arguments.If the given function is successful in the given time, the return result is the completed value; Otherwise the given valueIfNotSuccess.
- Parameters:
executor
- the executor to use for asynchronous executiontimeout
- how long to wait in units ofunit
unit
- aTimeUnit
determining how to interpret thetimeout
parameter- Returns:
- the new CompletableFuture
-
thenTupleMApplyMostSuccessAsync
public static <T,U1, CompletableFuture<Tuple4<U1,U2, U3, U4> U2, thenTupleMApplyMostSuccessAsyncU3, U4>> (CompletableFuture<? extends T> cfThis, long timeout, TimeUnit unit, Function<? super T, ? extends U1> fn1, Function<? super T, ? extends U2> fn2, Function<? super T, ? extends U3> fn3, Function<? super T, ? extends U4> fn4) Returns a new CompletableFuture that, when the given stage completes normally, is executed using the CompletableFuture's default asynchronous execution facility, with the most values obtained by calling the given Functions (with the given stage's result as the argument to the given functions) in the given time(timeout
, aka as many results as possible in the given time) in the same order of the given Functions arguments.If the given function is successful in the given time, the return result is the completed value; Otherwise the given valueIfNotSuccess.
- Parameters:
timeout
- how long to wait in units ofunit
unit
- aTimeUnit
determining how to interpret thetimeout
parameter- Returns:
- the new CompletableFuture
-
thenTupleMApplyMostSuccessAsync
public static <T,U1, CompletableFuture<Tuple4<U1,U2, U3, U4> U2, thenTupleMApplyMostSuccessAsyncU3, U4>> (CompletableFuture<? extends T> cfThis, Executor executor, long timeout, TimeUnit unit, Function<? super T, ? extends U1> fn1, Function<? super T, ? extends U2> fn2, Function<? super T, ? extends U3> fn3, Function<? super T, ? extends U4> fn4) Returns a new CompletableFuture that, when the given stage completes normally, is executed using the given Executor, with the most values obtained by calling the given Functions (with the given stage's result as the argument to the given functions) in the given time(timeout
, aka as many results as possible in the given time) in the same order of the given Functions arguments.If the given function is successful in the given time, the return result is the completed value; Otherwise the given valueIfNotSuccess.
- Parameters:
executor
- the executor to use for asynchronous executiontimeout
- how long to wait in units ofunit
unit
- aTimeUnit
determining how to interpret thetimeout
parameter- Returns:
- the new CompletableFuture
-
thenTupleMApplyMostSuccessAsync
public static <T,U1, CompletableFuture<Tuple5<U1,U2, U3, U4, U5> U2, thenTupleMApplyMostSuccessAsyncU3, U4, U5>> (CompletableFuture<? extends T> cfThis, long timeout, TimeUnit unit, Function<? super T, ? extends U1> fn1, Function<? super T, ? extends U2> fn2, Function<? super T, ? extends U3> fn3, Function<? super T, ? extends U4> fn4, Function<? super T, ? extends U5> fn5) Returns a new CompletableFuture that, when the given stage completes normally, is executed using the CompletableFuture's default asynchronous execution facility, with the most values obtained by calling the given Functions (with the given stage's result as the argument to the given functions) in the given time(timeout
, aka as many results as possible in the given time) in the same order of the given Functions arguments.If the given function is successful in the given time, the return result is the completed value; Otherwise the given valueIfNotSuccess.
- Parameters:
timeout
- how long to wait in units ofunit
unit
- aTimeUnit
determining how to interpret thetimeout
parameter- Returns:
- the new CompletableFuture
-
thenTupleMApplyMostSuccessAsync
public static <T,U1, CompletableFuture<Tuple5<U1,U2, U3, U4, U5> U2, thenTupleMApplyMostSuccessAsyncU3, U4, U5>> (CompletableFuture<? extends T> cfThis, Executor executor, long timeout, TimeUnit unit, Function<? super T, ? extends U1> fn1, Function<? super T, ? extends U2> fn2, Function<? super T, ? extends U3> fn3, Function<? super T, ? extends U4> fn4, Function<? super T, ? extends U5> fn5) Returns a new CompletableFuture that, when the given stage completes normally, is executed using the given Executor, with the most values obtained by calling the given Functions (with the given stage's result as the argument to the given functions) in the given time(timeout
, aka as many results as possible in the given time) in the same order of the given Functions arguments.If the given function is successful in the given time, the return result is the completed value; Otherwise the given valueIfNotSuccess.
- Parameters:
executor
- the executor to use for asynchronous executiontimeout
- how long to wait in units ofunit
unit
- aTimeUnit
determining how to interpret thetimeout
parameter- Returns:
- the new CompletableFuture
-
thenTupleMApplyAsync
public static <T,U1, CompletableFuture<Tuple2<U1,U2> U2>> thenTupleMApplyAsync(CompletableFuture<? extends T> cfThis, Function<? super T, ? extends U1> fn1, Function<? super T, ? extends U2> fn2) Returns a new CompletableFuture that, when the given stage completes normally, is executed using the CompletableFuture's default asynchronous execution facility, with the values obtained by calling the given Functions (with the given stage's result as the argument to the given functions) in the same order of the given Functions arguments.- Returns:
- the new CompletableFuture
-
thenTupleMApplyAsync
public static <T,U1, CompletableFuture<Tuple2<U1,U2> U2>> thenTupleMApplyAsync(CompletableFuture<? extends T> cfThis, Executor executor, Function<? super T, ? extends U1> fn1, Function<? super T, ? extends U2> fn2) Returns a new CompletableFuture that, when the given stage completes normally, is executed using the given Executor, with the values obtained by calling the given Functions (with the given stage's result as the argument to the given functions) in the same order of the given Functions arguments.- Parameters:
executor
- the executor to use for asynchronous execution- Returns:
- the new CompletableFuture
-
thenTupleMApplyAsync
public static <T,U1, CompletableFuture<Tuple3<U1,U2, U3> U2, thenTupleMApplyAsyncU3>> (CompletableFuture<? extends T> cfThis, Function<? super T, ? extends U1> fn1, Function<? super T, ? extends U2> fn2, Function<? super T, ? extends U3> fn3) Returns a new CompletableFuture that, when the given stage completes normally, is executed using the CompletableFuture's default asynchronous execution facility, with the values obtained by calling the given Functions (with the given stage's result as the argument to the given functions) in the same order of the given Functions arguments.- Returns:
- the new CompletableFuture
-
thenTupleMApplyAsync
public static <T,U1, CompletableFuture<Tuple3<U1,U2, U3> U2, thenTupleMApplyAsyncU3>> (CompletableFuture<? extends T> cfThis, Executor executor, Function<? super T, ? extends U1> fn1, Function<? super T, ? extends U2> fn2, Function<? super T, ? extends U3> fn3) Returns a new CompletableFuture that, when the given stage completes normally, is executed using the given Executor, with the values obtained by calling the given Functions (with the given stage's result as the argument to the given functions) in the same order of the given Functions arguments.- Parameters:
executor
- the executor to use for asynchronous execution- Returns:
- the new CompletableFuture
-
thenTupleMApplyAsync
public static <T,U1, CompletableFuture<Tuple4<U1,U2, U3, U4> U2, thenTupleMApplyAsyncU3, U4>> (CompletableFuture<? extends T> cfThis, Function<? super T, ? extends U1> fn1, Function<? super T, ? extends U2> fn2, Function<? super T, ? extends U3> fn3, Function<? super T, ? extends U4> fn4) Returns a new CompletableFuture that, when the given stage completes normally, is executed using the CompletableFuture's default asynchronous execution facility, with the values obtained by calling the given Functions (with the given stage's result as the argument to the given functions) in the same order of the given Functions arguments.- Returns:
- the new CompletableFuture
-
thenTupleMApplyAsync
public static <T,U1, CompletableFuture<Tuple4<U1,U2, U3, U4> U2, thenTupleMApplyAsyncU3, U4>> (CompletableFuture<? extends T> cfThis, Executor executor, Function<? super T, ? extends U1> fn1, Function<? super T, ? extends U2> fn2, Function<? super T, ? extends U3> fn3, Function<? super T, ? extends U4> fn4) Returns a new CompletableFuture that, when the given stage completes normally, is executed using the given Executor, with the values obtained by calling the given Functions (with the given stage's result as the argument to the given functions) in the same order of the given Functions arguments.- Parameters:
executor
- the executor to use for asynchronous execution- Returns:
- the new CompletableFuture
-
thenTupleMApplyAsync
public static <T,U1, CompletableFuture<Tuple5<U1,U2, U3, U4, U5> U2, thenTupleMApplyAsyncU3, U4, U5>> (CompletableFuture<? extends T> cfThis, Function<? super T, ? extends U1> fn1, Function<? super T, ? extends U2> fn2, Function<? super T, ? extends U3> fn3, Function<? super T, ? extends U4> fn4, Function<? super T, ? extends U5> fn5) Returns a new CompletableFuture that, when the given stage completes normally, is executed using the CompletableFuture's default asynchronous execution facility, with the values obtained by calling the given Functions (with the given stage's result as the argument to the given functions) in the same order of the given Functions arguments.- Returns:
- the new CompletableFuture
-
thenTupleMApplyAsync
public static <T,U1, CompletableFuture<Tuple5<U1,U2, U3, U4, U5> U2, thenTupleMApplyAsyncU3, U4, U5>> (CompletableFuture<? extends T> cfThis, Executor executor, Function<? super T, ? extends U1> fn1, Function<? super T, ? extends U2> fn2, Function<? super T, ? extends U3> fn3, Function<? super T, ? extends U4> fn4, Function<? super T, ? extends U5> fn5) Returns a new CompletableFuture that, when the given stage completes normally, is executed using the given Executor, with the values obtained by calling the given Functions (with the given stage's result as the argument to the given functions) in the same order of the given Functions arguments.- Parameters:
executor
- the executor to use for asynchronous execution- Returns:
- the new CompletableFuture
-
thenCombineFastFail
public static <T,U, CompletableFuture<V> thenCombineFastFailV> (CompletableFuture<? extends T> cfThis, CompletionStage<? extends U> other, BiFunction<? super T, ? super U, ? extends V> fn) Returns a new CompletableFuture that, when tow given stage both complete normally, is executed with the two results as arguments to the supplied function. if any of the given stage complete exceptionally, then the returned CompletableFuture also does so *without* waiting other incomplete given CompletionStage, with a CompletionException holding this exception as its cause.- Parameters:
fn
- the function to use to compute the value of the returned CompletableFuture- Returns:
- the new CompletableFuture
-
thenCombineFastFailAsync
public static <T,U, CompletableFuture<V> thenCombineFastFailAsyncV> (CompletableFuture<? extends T> cfThis, CompletionStage<? extends U> other, BiFunction<? super T, ? super U, ? extends V> fn) Returns a new CompletableFuture that, when tow given stage both complete normally, is executed using CompletableFuture's default asynchronous execution facility, with the two results as arguments to the supplied function. if any of the given stage complete exceptionally, then the returned CompletableFuture also does so *without* waiting other incomplete given CompletionStage, with a CompletionException holding this exception as its cause.- Parameters:
fn
- the function to use to compute the value of the returned CompletableFuture- Returns:
- the new CompletableFuture
-
thenCombineFastFailAsync
public static <T,U, CompletableFuture<V> thenCombineFastFailAsyncV> (CompletableFuture<? extends T> cfThis, CompletionStage<? extends U> other, BiFunction<? super T, ? super U, ? extends V> fn, Executor executor) Returns a new CompletableFuture that, when tow given stage both complete normally, is executed using the supplied executor, with the two results as arguments to the supplied function. if any of the given stage complete exceptionally, then the returned CompletableFuture also does so *without* waiting other incomplete given CompletionStage, with a CompletionException holding this exception as its cause.- Parameters:
fn
- the function to use to compute the value of the returned CompletableFuture- Returns:
- the new CompletableFuture
-
thenAcceptBothFastFail
public static <T,U> CompletableFuture<Void> thenAcceptBothFastFail(CompletableFuture<? extends T> cfThis, CompletionStage<? extends U> other, BiConsumer<? super T, ? super U> action) Returns a new CompletableFuture that, when tow given stage both complete normally, is executed with the two results as arguments to the supplied action. if any of the given stage complete exceptionally, then the returned CompletableFuture also does so *without* waiting other incomplete given CompletionStage, with a CompletionException holding this exception as its cause.- Parameters:
action
- the action to perform before completing the returned CompletableFuture- Returns:
- the new CompletableFuture
-
thenAcceptBothFastFailAsync
public static <T,U> CompletableFuture<Void> thenAcceptBothFastFailAsync(CompletableFuture<? extends T> cfThis, CompletionStage<? extends U> other, BiConsumer<? super T, ? super U> action) Returns a new CompletableFuture that, when tow given stage both complete normally, is executed using CompletableFuture's default asynchronous execution facility, with the two results as arguments to the supplied action. if any of the given stage complete exceptionally, then the returned CompletableFuture also does so *without* waiting other incomplete given CompletionStage, with a CompletionException holding this exception as its cause.- Parameters:
action
- the action to perform before completing the returned CompletableFuture- Returns:
- the new CompletableFuture
-
thenAcceptBothFastFailAsync
public static <T,U> CompletableFuture<Void> thenAcceptBothFastFailAsync(CompletableFuture<? extends T> cfThis, CompletionStage<? extends U> other, BiConsumer<? super T, ? super U> action, Executor executor) Returns a new CompletableFuture that, when tow given stage both complete normally, is executed using the supplied executor, with the two results as arguments to the supplied action. if any of the given stage complete exceptionally, then the returned CompletableFuture also does so *without* waiting other incomplete given CompletionStage, with a CompletionException holding this exception as its cause.- Parameters:
action
- the action to perform before completing the returned CompletableFuture- Returns:
- the new CompletableFuture
-
runAfterBothFastFail
public static CompletableFuture<Void> runAfterBothFastFail(CompletableFuture<?> cfThis, CompletionStage<?> other, Runnable action) Returns a new CompletableFuture that, when two given stages both complete normally, executes the given action. if any of the given stage complete exceptionally, then the returned CompletableFuture also does so *without* waiting other incomplete given CompletionStage, with a CompletionException holding this exception as its cause.- Parameters:
action
- the action to perform before completing the returned CompletableFuture- Returns:
- the new CompletableFuture
-
runAfterBothFastFailAsync
public static CompletableFuture<Void> runAfterBothFastFailAsync(CompletableFuture<?> cfThis, CompletionStage<?> other, Runnable action) Returns a new CompletableFuture that, when two given stages both complete normally, executes the given action using CompletableFuture's default asynchronous execution facility. if any of the given stage complete exceptionally, then the returned CompletableFuture also does so *without* waiting other incomplete given CompletionStage, with a CompletionException holding this exception as its cause.- Parameters:
action
- the action to perform before completing the returned CompletableFuture- Returns:
- the new CompletableFuture
-
runAfterBothFastFailAsync
public static CompletableFuture<Void> runAfterBothFastFailAsync(CompletableFuture<?> cfThis, CompletionStage<?> other, Runnable action, Executor executor) Returns a new CompletableFuture that, when two given stages both complete normally, executes the given action using the supplied executor. if any of the given stage complete exceptionally, then the returned CompletableFuture also does so *without* waiting other incomplete given CompletionStage, with a CompletionException holding this exception as its cause.- Parameters:
action
- the action to perform before completing the returned CompletableFuture- Returns:
- the new CompletableFuture
-
applyToEitherSuccess
public static <T,U> CompletableFuture<U> applyToEitherSuccess(CompletableFuture<? extends T> cfThis, CompletionStage<? extends T> other, Function<? super T, ? extends U> fn) Returns a new CompletableFuture that, when either given stage success, is executed with the corresponding result as argument to the supplied function.- Type Parameters:
U
- the function's return type- Parameters:
fn
- the function to use to compute the value of the returned CompletableFuture- Returns:
- the new CompletableFuture
-
applyToEitherSuccessAsync
public static <T,U> CompletableFuture<U> applyToEitherSuccessAsync(CompletableFuture<? extends T> cfThis, CompletionStage<? extends T> other, Function<? super T, ? extends U> fn) Returns a new CompletableFuture that, when either given stage success, is executed using this CompletableFuture's default asynchronous execution facility, with the corresponding result as argument to the supplied function.- Type Parameters:
U
- the function's return type- Parameters:
fn
- the function to use to compute the value of the returned CompletableFuture- Returns:
- the new CompletableFuture
-
applyToEitherSuccessAsync
public static <T,U> CompletableFuture<U> applyToEitherSuccessAsync(CompletableFuture<? extends T> cfThis, CompletionStage<? extends T> other, Function<? super T, ? extends U> fn, Executor executor) Returns a new CompletableFuture that, when either given stage success, is executed using the supplied executor, with the corresponding result as argument to the supplied function.- Type Parameters:
U
- the function's return type- Parameters:
fn
- the function to use to compute the value of the returned CompletableFutureexecutor
- the executor to use for asynchronous execution- Returns:
- the new CompletableFuture
-
acceptEitherSuccess
public static <T> CompletableFuture<Void> acceptEitherSuccess(CompletableFuture<? extends T> cfThis, CompletionStage<? extends T> other, Consumer<? super T> action) Returns a new CompletableFuture that, when either given stage success, is executed with the corresponding result as argument to the supplied action.- Parameters:
action
- the action to perform before completing the returned CompletableFuture- Returns:
- the new CompletableFuture
-
acceptEitherSuccessAsync
public static <T> CompletableFuture<Void> acceptEitherSuccessAsync(CompletableFuture<? extends T> cfThis, CompletionStage<? extends T> other, Consumer<? super T> action) Returns a new CompletableFuture that, when either given stage success, is executed using this CompletableFuture's default asynchronous execution facility, with the corresponding result as argument to the supplied action.- Parameters:
action
- the action to perform before completing the returned CompletableFuture- Returns:
- the new CompletableFuture
-
acceptEitherSuccessAsync
public static <T> CompletableFuture<Void> acceptEitherSuccessAsync(CompletableFuture<? extends T> cfThis, CompletionStage<? extends T> other, Consumer<? super T> action, Executor executor) Returns a new CompletableFuture that, when either given stage success, is executed using the supplied executor, with the corresponding result as argument to the supplied action.- Parameters:
action
- the action to perform before completing the returned CompletableFutureexecutor
- the executor to use for asynchronous execution- Returns:
- the new CompletableFuture
-
runAfterEitherSuccess
public static CompletableFuture<Void> runAfterEitherSuccess(CompletableFuture<?> cfThis, CompletionStage<?> other, Runnable action) Returns a new CompletableFuture that, when either given stage success, executes the given action. Otherwise, all two given CompletionStage complete exceptionally, the returned CompletableFuture also does so, with a CompletionException holding an exception from any of the given CompletionStage as its cause.- Parameters:
action
- the action to perform before completing the returned CompletableFuture- Returns:
- the new CompletableFuture
-
runAfterEitherSuccessAsync
public static CompletableFuture<Void> runAfterEitherSuccessAsync(CompletableFuture<?> cfThis, CompletionStage<?> other, Runnable action) Returns a new CompletableFuture that, when either given stage success, executes the given action using CompletableFuture's default asynchronous execution facility. Otherwise, all two given CompletionStage complete exceptionally, the returned CompletableFuture also does so, with a CompletionException holding an exception from any of the given CompletionStage as its cause.- Parameters:
action
- the action to perform before completing the returned CompletableFuture- Returns:
- the new CompletableFuture
-
runAfterEitherSuccessAsync
public static CompletableFuture<Void> runAfterEitherSuccessAsync(CompletableFuture<?> cfThis, CompletionStage<?> other, Runnable action, Executor executor) Returns a new CompletableFuture that, when either given stage success, executes the given action using the supplied executor. Otherwise, all two given CompletionStage complete exceptionally, the returned CompletableFuture also does so, with a CompletionException holding an exception from any of the given CompletionStage as its cause.- Parameters:
action
- the action to perform before completing the returned CompletableFuture- Returns:
- the new CompletableFuture
-
catching
public static <T,X extends Throwable, C catchingC extends CompletionStage<? super T>> (C cfThis, Class<X> exceptionType, Function<? super X, ? extends T> fallback) Returns a new CompletionStage that, when given stage completes exceptionally with the given exceptionType, is executed with given stage's exception as the argument to the supplied function. Otherwise, the returned stage contains same result as input CompletionStage.- Parameters:
exceptionType
- the exception type that triggers use offallback
. The exception type is matched against the input's exception. To avoid hiding bugs and other unrecoverable errors, callers should prefer more specific types, avoidingThrowable.class
in particular.fallback
- the Function to be called ifinput
fails with the expected exception type. The function's argument is the input's exception.- See Also:
-
catchingAsync
public static <T,X extends Throwable, C catchingAsyncC extends CompletionStage<? super T>> (C cfThis, Class<X> exceptionType, Function<? super X, ? extends T> fallback) Returns a new CompletionStage that, when given stage completes exceptionally with the given exceptionType, is executed with given stage's exception as the argument to the supplied function, using the given stage's default asynchronous execution facility. Otherwise, the returned stage contains same result as input CompletionStage.- Parameters:
exceptionType
- the exception type that triggers use offallback
. The exception type is matched against the input's exception. To avoid hiding bugs and other unrecoverable errors, callers should prefer more specific types, avoidingThrowable.class
in particular.fallback
- the Function to be called ifinput
fails with the expected exception type. The function's argument is the input's exception.- See Also:
-
catchingAsync
public static <T,X extends Throwable, C catchingAsyncC extends CompletionStage<? super T>> (C cfThis, Class<X> exceptionType, Function<? super X, ? extends T> fallback, Executor executor) Returns a new CompletionStage that, when given stage completes exceptionally with the given exceptionType, is executed with given stage's exception as the argument to the supplied function, using the supplied Executor. Otherwise, the returned stage contains same result as input CompletionStage.- Parameters:
exceptionType
- the exception type that triggers use offallback
. The exception type is matched against the input's exception. To avoid hiding bugs and other unrecoverable errors, callers should prefer more specific types, avoidingThrowable.class
in particular.fallback
- the Function to be called ifinput
fails with the expected exception type. The function's argument is the input's exception.executor
- the executor to use for asynchronous execution- See Also:
-
exceptionallyAsync
public static <T,C extends CompletionStage<? super T>> C exceptionallyAsync(C cfThis, Function<Throwable, ? extends T> fn) Returns a new CompletionStage that, when given stage completes exceptionally, is executed with given stage's exception as the argument to the supplied function, using given stage's default asynchronous execution facility. Otherwise, if given stage completes normally, then the returned stage also completes normally with the same value.- Parameters:
fn
- the function to use to compute the value of the returned CompletableFuture if given CompletionStage completed exceptionally- Returns:
- the new CompletableFuture
-
exceptionallyAsync
public static <T,C extends CompletionStage<? super T>> C exceptionallyAsync(C cfThis, Function<Throwable, ? extends T> fn, Executor executor) Returns a new CompletionStage that, when given stage completes exceptionally, is executed with given stage's exception as the argument to the supplied function, using the supplied Executor. Otherwise, if given stage completes normally, then the returned stage also completes normally with the same value.- Parameters:
fn
- the function to use to compute the value of the returned CompletableFuture if given CompletionStage completed exceptionallyexecutor
- the executor to use for asynchronous execution- Returns:
- the new CompletableFuture
-
cffuOrTimeout
public static <C extends CompletableFuture<?>> C cffuOrTimeout(C cfThis, long timeout, TimeUnit unit) Exceptionally completes given CompletableFuture with aTimeoutException
if not otherwise completed before the given timeout.Uses CompletableFuture's default asynchronous execution facility as
executorWhenTimeout
.- Parameters:
timeout
- how long to wait before completing exceptionally with a TimeoutException, in units ofunit
unit
- aTimeUnit
determining how to interpret thetimeout
parameter- Returns:
- the new CompletableFuture
- See Also:
-
cffuOrTimeout
public static <C extends CompletableFuture<?>> C cffuOrTimeout(C cfThis, Executor executorWhenTimeout, long timeout, TimeUnit unit) Exceptionally completes given CompletableFuture with aTimeoutException
if not otherwise completed before the given timeout.- Parameters:
executorWhenTimeout
- the async executor when triggered by timeouttimeout
- how long to wait before completing exceptionally with a TimeoutException, in units ofunit
unit
- aTimeUnit
determining how to interpret thetimeout
parameter- Returns:
- the new CompletableFuture
-
orTimeout
@Contract("_, _, _ -> param1") public static <C extends CompletableFuture<?>> C orTimeout(C cfThis, long timeout, TimeUnit unit) Exceptionally completes given CompletableFuture with aTimeoutException
if not otherwise completed before the given timeout.CAUTION: This method and
CompletableFuture.orTimeout(long, TimeUnit)
is UNSAFE!When triggered by timeout, the subsequent non-async actions of the dependent CompletableFutures are performed in the SINGLE thread builtin executor of CompletableFuture for delay execution (including timeout function). So the long-running subsequent non-async actions lead to the CompletableFuture dysfunction (including delay execution and timeout).
Strong recommend using the safe method
cffuOrTimeout(CompletableFuture, long, TimeUnit)
instead of this method andCompletableFuture.orTimeout(long, TimeUnit)
.Unless all subsequent actions of dependent CompletableFutures is ensured executing async (aka. the dependent CompletableFutures is created by async methods), using this method and
CompletableFuture.orTimeout(long, TimeUnit)
is one less thread switch of task execution when triggered by timeout.- Parameters:
timeout
- how long to wait before completing exceptionally with a TimeoutException, in units ofunit
unit
- aTimeUnit
determining how to interpret thetimeout
parameter- Returns:
- the given CompletableFuture
- See Also:
-
cffuCompleteOnTimeout
public static <T,C extends CompletableFuture<? super T>> C cffuCompleteOnTimeout(C cfThis, @Nullable T value, long timeout, TimeUnit unit) Completes given CompletableFuture with the given value if not otherwise completed before the given timeout.Uses CompletableFuture's default asynchronous execution facility as
executorWhenTimeout
.- Parameters:
value
- the value to use upon timeouttimeout
- how long to wait before completing normally with the given value, in units ofunit
unit
- aTimeUnit
determining how to interpret thetimeout
parameter- Returns:
- the new CompletableFuture
- See Also:
-
cffuCompleteOnTimeout
public static <T,C extends CompletableFuture<? super T>> C cffuCompleteOnTimeout(C cfThis, @Nullable T value, Executor executorWhenTimeout, long timeout, TimeUnit unit) Completes given CompletableFuture with the given value if not otherwise completed before the given timeout.- Parameters:
value
- the value to use upon timeoutexecutorWhenTimeout
- the async executor when triggered by timeouttimeout
- how long to wait before completing normally with the given value, in units ofunit
unit
- aTimeUnit
determining how to interpret thetimeout
parameter- Returns:
- the new CompletableFuture
-
completeOnTimeout
@Contract("_, _, _, _ -> param1") public static <T,C extends CompletableFuture<? super T>> C completeOnTimeout(C cfThis, @Nullable T value, long timeout, TimeUnit unit) Completes given CompletableFuture with the given value if not otherwise completed before the given timeout.CAUTION: This method and
CompletableFuture.completeOnTimeout(Object, long, TimeUnit)
is UNSAFE!When triggered by timeout, the subsequent non-async actions of the dependent CompletableFutures are performed in the SINGLE thread builtin executor of CompletableFuture for delay execution (including timeout function). So the long-running subsequent non-async actions lead to the CompletableFuture dysfunction (including delay execution and timeout).
Strong recommend using the safe method
cffuCompleteOnTimeout(CompletableFuture, Object, long, TimeUnit)
instead of this method andCompletableFuture.completeOnTimeout(Object, long, TimeUnit)
.Unless all subsequent actions of dependent CompletableFutures is ensured executing async (aka. the dependent CompletableFutures is created by async methods), using this method and
CompletableFuture.completeOnTimeout(Object, long, TimeUnit)
is one less thread switch of task execution when triggered by timeout.- Parameters:
value
- the value to use upon timeouttimeout
- how long to wait before completing normally with the given value, in units ofunit
unit
- aTimeUnit
determining how to interpret thetimeout
parameter- Returns:
- the given CompletableFuture
- See Also:
-
catchingCompose
public static <T,X extends Throwable, C catchingComposeC extends CompletionStage<? super T>> (C cfThis, Class<X> exceptionType, Function<? super X, ? extends CompletionStage<T>> fallback) Returns a new CompletionStage that, when given stage completes exceptionally with the given exceptionType, is composed using the results of the supplied function applied to given stage's exception.- Parameters:
exceptionType
- the exception type that triggers use offallback
. The exception type is matched against the input's exception. To avoid hiding bugs and other unrecoverable errors, callers should prefer more specific types, avoidingThrowable.class
in particular.fallback
- the Function to be called ifinput
fails with the expected exception type. The function's argument is the input's exception.- See Also:
-
catchingComposeAsync
public static <T,X extends Throwable, C catchingComposeAsyncC extends CompletionStage<? super T>> (C cfThis, Class<X> exceptionType, Function<? super X, ? extends CompletionStage<T>> fallback) Returns a new CompletionStage that, when given stage completes exceptionally with the given exceptionType, is composed using the results of the supplied function applied to given stage's exception, using given stage's default asynchronous execution facility.- Parameters:
exceptionType
- the exception type that triggers use offallback
. The exception type is matched against the input's exception. To avoid hiding bugs and other unrecoverable errors, callers should prefer more specific types, avoidingThrowable.class
in particular.fallback
- the Function to be called ifinput
fails with the expected exception type. The function's argument is the input's exception.- See Also:
-
catchingComposeAsync
public static <T,X extends Throwable, C catchingComposeAsyncC extends CompletionStage<? super T>> (C cfThis, Class<X> exceptionType, Function<? super X, ? extends CompletionStage<T>> fallback, Executor executor) Returns a new CompletionStage that, when given stage completes exceptionally with the given exceptionType, is composed using the results of the supplied function applied to given's exception, using the supplied Executor.- Parameters:
exceptionType
- the exception type that triggers use offallback
. The exception type is matched against the input's exception. To avoid hiding bugs and other unrecoverable errors, callers should prefer more specific types, avoidingThrowable.class
in particular.fallback
- the Function to be called ifinput
fails with the expected exception type. The function's argument is the input's exception.executor
- the executor to use for asynchronous execution- See Also:
-
exceptionallyCompose
public static <T,C extends CompletionStage<? super T>> C exceptionallyCompose(C cfThis, Function<Throwable, ? extends CompletionStage<T>> fn) Returns a new CompletableFuture that, when given CompletableFuture completes exceptionally, is composed using the results of the supplied function applied to given stage's exception.- Parameters:
fn
- the function to use to compute the returned CompletableFuture if given CompletionStage completed exceptionally- Returns:
- the new CompletableFuture
-
exceptionallyComposeAsync
public static <T,C extends CompletionStage<? super T>> C exceptionallyComposeAsync(C cfThis, Function<Throwable, ? extends CompletionStage<T>> fn) Returns a new CompletableFuture that, when given CompletableFuture completes exceptionally, is composed using the results of the supplied function applied to given stage's exception, using given CompletableFuture's default asynchronous execution facility.- Parameters:
fn
- the function to use to compute the returned CompletableFuture if given CompletionStage completed exceptionally- Returns:
- the new CompletableFuture
-
exceptionallyComposeAsync
public static <T,C extends CompletionStage<? super T>> C exceptionallyComposeAsync(C cfThis, Function<Throwable, ? extends CompletionStage<T>> fn, Executor executor) Returns a new CompletableFuture that, when given CompletableFuture completes exceptionally, is composed using the results of the supplied function applied to given stage's exception, using the supplied Executor.- Parameters:
fn
- the function to use to compute the returned CompletableFuture if given CompletionStage completed exceptionallyexecutor
- the executor to use for asynchronous execution- Returns:
- the new CompletableFuture
-
peek
@Contract("_, _ -> param1") public static <T,C extends CompletionStage<? extends T>> C peek(C cfThis, BiConsumer<? super T, ? super Throwable> action) Peeks the result by executing the given action when given stage completes, returns the given stage.When the given stage is complete, the given action is invoked with the result (or
null
if none) and the exception (ornull
if none) of given stage as arguments. Whether the supplied action throws an exception or not, the given stage is NOT affected.Unlike method
handle
and like methodwhenComplete
, this method is not designed to translate completion outcomes.- Parameters:
action
- the action to perform- Returns:
- the given stage
- See Also:
-
peekAsync
@Contract("_, _ -> param1") public static <T,C extends CompletionStage<? extends T>> C peekAsync(C cfThis, BiConsumer<? super T, ? super Throwable> action) Peeks the result by executing the given action when given stage completes, executes the given action using given stage's default asynchronous execution facility, returns the given stage.When the given stage is complete, the given action is invoked with the result (or
null
if none) and the exception (ornull
if none) of given stage as arguments. Whether the supplied action throws an exception or not, the given stage is NOT affected.Unlike method
handle
and like methodwhenComplete
, this method is not designed to translate completion outcomes.- Parameters:
action
- the action to perform- Returns:
- the given stage
- See Also:
-
peekAsync
@Contract("_, _, _ -> param1") public static <T,C extends CompletionStage<? extends T>> C peekAsync(C cfThis, BiConsumer<? super T, ? super Throwable> action, Executor executor) Peeks the result by executing the given action when given stage completes, executes the given action using the supplied Executor, returns the given stage.When the given stage is complete, the given action is invoked with the result (or
null
if none) and the exception (ornull
if none) of given stage as arguments. Whether the supplied action throws an exception or not, the given stage is NOT affected.Unlike method
handle
and like methodwhenComplete
, this method is not designed to translate completion outcomes.- Parameters:
action
- the action to perform- Returns:
- the given stage
- See Also:
-
join
@Blocking @Nullable public static <T> T join(CompletableFuture<T> cfThis, long timeout, TimeUnit unit) Waits if necessary for at most the given time for the computation to complete, and then retrieves its result value when complete, or throws an (unchecked) exception if completed exceptionally.NOTE:
Calling this methodresult = CompletableFutureUtils.join(cf, timeout, unit);
is the same as:
CAUTION:result = cf.copy() // defensive copy to avoid writing this cf unexpectedly .orTimeout(timeout, unit) .join();
if the wait timed out, this method throws an (unchecked)CompletionException
with theTimeoutException
as its cause; NOT throws a (checked)TimeoutException
likeCompletableFuture.get(long, TimeUnit)
.- Parameters:
timeout
- the maximum time to waitunit
- the time unit of the timeout argument- Returns:
- the result value
- Throws:
CancellationException
- if the computation was cancelledCompletionException
- if given future completed exceptionally or a completion computation threw an exception or the wait timed out(with theTimeoutException
as its cause)- See Also:
-
getSuccessNow
@Contract(pure=true) @Nullable public static <T> T getSuccessNow(CompletableFuture<? extends T> cfThis, @Nullable T valueIfNotSuccess) Returns the result value if the given stage is completed successfully, else returns the given valueIfNotSuccess.This method will not throw exceptions (CancellationException/CompletionException/ExecutionException/IllegalStateException/...).
- Parameters:
valueIfNotSuccess
- the value to return if not completed successfully- Returns:
- the result value, if completed successfully, else the given valueIfNotSuccess
-
resultNow
Returns the computed result, without waiting.This method is for cases where the caller knows that the task has already completed successfully, for example when filtering a stream of Future objects for the successful tasks and using a mapping operation to obtain a stream of results.
results = futures.stream() .filter(f -> f.state() == Future.State.SUCCESS) .map(Future::resultNow) .toList();
- Returns:
- the computed result
- Throws:
IllegalStateException
- if the task has not completed or the task did not complete with a result
-
exceptionNow
Returns the exception thrown by the task, without waiting.This method is for cases where the caller knows that the task has already completed with an exception.
- Returns:
- the exception thrown by the task
- Throws:
IllegalStateException
- if the task has not completed, the task completed normally, or the task was cancelled
-
state
Returns the computation state(CffuState
), this method is equivalent toCompletableFuture.state()
with java version compatibility logic, so you can invoke in oldjava 18-
.- Returns:
- the computation state
- See Also:
-
completeAsync
@Contract("_, _ -> param1") public static <T,C extends CompletableFuture<? super T>> C completeAsync(C cfThis, Supplier<? extends T> supplier) Completes given CompletableFuture with the result of the given Supplier function invoked from an asynchronous task using the default executor.- Parameters:
supplier
- a function returning the value to be used to complete given CompletableFuture- Returns:
- the given CompletableFuture
- See Also:
-
completeAsync
@Contract("_, _, _ -> param1") public static <T,C extends CompletableFuture<? super T>> C completeAsync(C cfThis, Supplier<? extends T> supplier, Executor executor) Completes given CompletableFuture with the result of the given Supplier function invoked from an asynchronous task using the given executor.- Parameters:
supplier
- a function returning the value to be used to complete given CompletableFutureexecutor
- the executor to use for asynchronous execution- Returns:
- the given CompletableFuture
- See Also:
-
completeExceptionallyAsync
@Contract("_, _ -> param1") public static <C extends CompletableFuture<?>> C completeExceptionallyAsync(C cfThis, Supplier<? extends Throwable> supplier) If not already completed, completes given CompletableFuture with the exception result of the given Supplier function invoked from an asynchronous task using the default executor.- Parameters:
supplier
- a function returning the value to be used to complete given CompletableFuture- Returns:
- the given CompletableFuture
- See Also:
-
completeExceptionallyAsync
@Contract("_, _, _ -> param1") public static <C extends CompletableFuture<?>> C completeExceptionallyAsync(C cfThis, Supplier<? extends Throwable> supplier, Executor executor) If not already completed, completes given CompletableFuture with the exception result of the given Supplier function invoked from an asynchronous task using the given executor.- Parameters:
supplier
- a function returning the value to be used to complete given CompletableFutureexecutor
- the executor to use for asynchronous execution- Returns:
- the given CompletableFuture
- See Also:
-
minimalCompletionStage
@Contract(pure=true) public static <T> CompletionStage<T> minimalCompletionStage(CompletableFuture<T> cfThis) Returns a new CompletionStage that is completed normally with the same value as given CompletableFuture when it completes normally, and cannot be independently completed or otherwise used in ways not defined by the methods of interfaceCompletionStage
. If given CompletableFuture completes exceptionally, then the returned CompletionStage completes exceptionally with a CompletionException with given exception as cause.CAUTION:
if run on old Java 8(not support *minimal* CompletionStage), just return a *normal* CompletableFuture which is NOT with a *minimal* CompletionStage.- Returns:
- the new CompletionStage
- See Also:
-
copy
Returns a new CompletableFuture that is completed normally with the same value as this CompletableFuture when it completes normally. If this CompletableFuture completes exceptionally, then the returned CompletableFuture completes exceptionally with a CompletionException with this exception as cause. The behavior is equivalent tothenApply(x -> x)
. This method may be useful as a form of "defensive copying", to prevent clients from completing, while still being able to arrange dependent actions.- Returns:
- the new CompletableFuture
- See Also:
-
newIncompleteFuture
@Contract(pure=true) public static <U> CompletableFuture<U> newIncompleteFuture(CompletableFuture<?> cfThis) Returns a new incomplete CompletableFuture of the type to be returned by a CompletionStage method.- Type Parameters:
U
- the type of the value- Returns:
- the new CompletableFuture
- See Also:
-
toCompletableFutureArray
@Contract(pure=true) @SafeVarargs public static <T> CompletableFuture<T>[] toCompletableFutureArray(CompletionStage<T>... stages) A convenient util method for converting inputCompletionStage
(includingCffu
/CompletableFuture
) array element byCompletionStage.toCompletableFuture()
.- See Also:
-
completableFutureListToArray
@Contract(pure=true) public static <T> CompletableFuture<T>[] completableFutureListToArray(List<CompletableFuture<T>> cfList) A convenient util method for converting inputCompletableFuture
list to CompletableFuture array.- See Also:
-
unwrapCfException
@Contract(value="null -> null; !null -> !null", pure=true) @Nullable public static Throwable unwrapCfException(@Nullable Throwable ex) A convenient util method for unwrapping CF exception (CompletionException
/ExecutionException
) to the biz exception.
-