diff --git a/README.md b/README.md index 67fcc829..58840a00 100644 --- a/README.md +++ b/README.md @@ -43,7 +43,7 @@ - [2. `cffu`功能介绍](#2-cffu%E5%8A%9F%E8%83%BD%E4%BB%8B%E7%BB%8D) - [2.1 返回多个运行`CF`的结果](#21-%E8%BF%94%E5%9B%9E%E5%A4%9A%E4%B8%AA%E8%BF%90%E8%A1%8Ccf%E7%9A%84%E7%BB%93%E6%9E%9C) - [2.2 支持设置缺省的业务线程池并封装可携带](#22-%E6%94%AF%E6%8C%81%E8%AE%BE%E7%BD%AE%E7%BC%BA%E7%9C%81%E7%9A%84%E4%B8%9A%E5%8A%A1%E7%BA%BF%E7%A8%8B%E6%B1%A0%E5%B9%B6%E5%B0%81%E8%A3%85%E5%8F%AF%E6%90%BA%E5%B8%A6) - - [2.3 高效灵活的并发执行策略(`allOfFastFail`/`anyOfSuccess`/`mostResultsOfSuccess`)](#23-%E9%AB%98%E6%95%88%E7%81%B5%E6%B4%BB%E7%9A%84%E5%B9%B6%E5%8F%91%E6%89%A7%E8%A1%8C%E7%AD%96%E7%95%A5alloffastfailanyofsuccessmostresultsofsuccess) + - [2.3 高效灵活的并发执行策略(`allResultsFastFailOf`/`anySuccessOf`/`mostSuccessResultsOf`)](#23-%E9%AB%98%E6%95%88%E7%81%B5%E6%B4%BB%E7%9A%84%E5%B9%B6%E5%8F%91%E6%89%A7%E8%A1%8C%E7%AD%96%E7%95%A5allResultsFastFailOfanysuccessofmostsuccessresultsof) - [2.4 支持超时的`join`的方法](#24-%E6%94%AF%E6%8C%81%E8%B6%85%E6%97%B6%E7%9A%84join%E7%9A%84%E6%96%B9%E6%B3%95) - [2.5 `Backport`支持`Java 8`](#25-backport%E6%94%AF%E6%8C%81java-8) - [2.6 返回具体类型的`anyOf`方法](#26-%E8%BF%94%E5%9B%9E%E5%85%B7%E4%BD%93%E7%B1%BB%E5%9E%8B%E7%9A%84anyof%E6%96%B9%E6%B3%95) @@ -64,12 +64,12 @@ - ☘️ **补全业务使用中缺失的功能** - 更方便的功能,如 - - `allResultsOfFastFail`/`allResultsOf`方法:返回多个`CF`的结果,而不是无返回结果`Void`(`CompletableFuture#allOf()`) - - `allTupleOfFastFail`/`allTupleOf`方法:返回多个`CF`不同类型的结果,而不是同一类型(`allResultsOf`) + - `allResultsFastFailOf`/`allResultsOf`方法:返回多个`CF`的结果,而不是无返回结果`Void`(`CompletableFuture#allOf()`) + - `allTupleFastFailOf`/`allTupleOf`方法:返回多个`CF`不同类型的结果,而不是同一类型(`allResultsOf`) - 更高效灵活的并发执行策略,如 - - `allResultsOfFastFail`/`allOfFastFail`方法:有`CF`失败时快速返回,而不再等待所有`CF`运行完成(`allOf`) - - `anyOfSuccess`方法:返回首个成功的`CF`结果,而不是首个完成(但可能失败)的`CF`(`anyOf`) - - `mostResultsOfSuccess`方法:返回指定时间内成功`CF`的结果,忽略失败或还没有运行完成的`CF`(使用缺省值) + - `allResultsFastFailOf`/`allFastFailOf`方法:有`CF`失败时快速返回,而不再等待所有`CF`运行完成(`allOf`) + - `anySuccessOf`方法:返回首个成功的`CF`结果,而不是首个完成(但可能失败)的`CF`(`anyOf`) + - `mostSuccessResultsOf`方法:返回指定时间内成功`CF`的结果,忽略失败或还没有运行完成的`CF`(使用缺省值) - 更安全的使用方式,如 - 支持设置缺省的业务线程池并封装可携带,`CffuFactory#builder(executor)`方法 - 支持超时的`join`的方法,`join(timeout, unit)`方法 @@ -178,8 +178,8 @@ public class CffuDemo { .orTimeout(1500, TimeUnit.MILLISECONDS); System.out.println("combined result: " + combined.get()); - final Cffu anyOfSuccess = cffuFactory.anyOfSuccess(longTaskC, longFailedTask); - System.out.println("anyOfSuccess result: " + anyOfSuccess.get()); + final Cffu anySuccessOf = cffuFactory.anySuccessOf(longTaskC, longFailedTask); + System.out.println("anySuccessOf result: " + anySuccessOf.get()); } } ``` @@ -219,8 +219,8 @@ public class CompletableFutureUtilsDemo { CompletableFutureUtils.orTimeout(combined, 1500, TimeUnit.MILLISECONDS); System.out.println("combined result: " + combinedWithTimeout.get()); - final CompletableFuture anyOfSuccess = CompletableFutureUtils.anyOfSuccess(longTaskC, longFailedTask); - System.out.println("anyOfSuccess result: " + anyOfSuccess.get()); + final CompletableFuture anySuccessOf = CompletableFutureUtils.anySuccessOf(longTaskC, longFailedTask); + System.out.println("anySuccessOf result: " + anySuccessOf.get()); } } ``` @@ -262,8 +262,8 @@ fun main() { .orTimeout(1500, TimeUnit.MILLISECONDS) println("combined result: ${combined.get()}") - val anyOfSuccess: Cffu = listOf(longTaskC, longFailedTask).anyOfSuccessCffu() - println("anyOfSuccess result: ${anyOfSuccess.get()}") + val anySuccessOf: Cffu = listOf(longTaskC, longFailedTask).anySuccessOfCffu() + println("anySuccessOf result: ${anySuccessOf.get()}") } ``` @@ -278,7 +278,7 @@ fun main() { - 需要在`allOf`方法之后再通过入参`CF`的读方法(如`join`/`get)`来获取结果 - 或是在传入的`Action`设置外部的变量,要注意多线程写的线程安全问题 ⚠️ -`cffu`的`allResultsOfFastFail`/`allResultsOf`方法提供了返回多个`CF`结果的功能,方便直接也规避了多线程写的线程安全问题。 +`cffu`的`allResultsFastFailOf`/`allResultsOf`方法提供了返回多个`CF`结果的功能,方便直接也规避了多线程写的线程安全问题。 示例代码如下: @@ -320,7 +320,7 @@ public class AllResultsOfDemo { > \# 完整可运行的Demo代码参见[`AllResultsOfDemo.java`](cffu-core/src/test/java/io/foldright/demo/AllResultsOfDemo.java)。 -上面多个相同结果类型的`CF`,`cffu`还提供了返回多个不同类型`CF`结果的方法,`allTupleOfFastFail`/`allTupleOf`方法。 +上面多个相同结果类型的`CF`,`cffu`还提供了返回多个不同类型`CF`结果的方法,`allTupleFastFailOf`/`allTupleOf`方法。 示例代码如下: @@ -416,27 +416,27 @@ public class DefaultExecutorSettingForCffu { > \# 完整可运行的Demo代码参见[`DefaultExecutorSettingForCffu.java`](cffu-core/src/test/java/io/foldright/demo/DefaultExecutorSettingForCffu.java)。 -### 2.3 高效灵活的并发执行策略(`allResultsOfFastFail`/`anyOfSuccess`/`mostResultsOfSuccess`) +### 2.3 高效灵活的并发执行策略(`allResultsFastFailOf`/`anySuccessOf`/`mostSuccessResultsOf`) - `CompletableFuture`的`allOf`方法会等待所有输入`CF`运行完成;即使有`CF`失败了也要等待后续`CF`运行完成,再返回一个失败的`CF`。 - 对于业务逻辑来说,这样失败且继续等待策略,减慢了业务响应性;会希望如果有输入`CF`失败了,则快速失败不再做于事无补的等待 - - `cffu`提供了相应的`allResultsOfFastFail`方法 - - `allOf`/`allResultsOfFastFail`两者都是,只有当所有的输入`CF`都成功时,才返回成功结果 + - `cffu`提供了相应的`allResultsFastFailOf`方法 + - `allOf`/`allResultsFastFailOf`两者都是,只有当所有的输入`CF`都成功时,才返回成功结果 - `CompletableFuture`的`anyOf`方法返回首个完成的`CF`(不会等待后续没有完成的`CF`,赛马模式);即使首个完成的`CF`是失败的,也会返回这个失败的`CF`结果。 - 对于业务逻辑来说,会希望赛马模式返回首个成功的`CF`结果,而不是首个完成但失败的`CF` - - `cffu`提供了相应的`anyOfSuccess`方法 - - `anyOfSuccess`只有当所有的输入`CF`都失败时,才返回失败结果 + - `cffu`提供了相应的`anySuccessOf`方法 + - `anySuccessOf`只有当所有的输入`CF`都失败时,才返回失败结果 - 返回指定时间内成功`CF`的结果,忽略失败或还没有运行完成的`CF`(使用缺省值) - 业务最终一致性时,能返回就尽量返回有的;对于没有及时返回还在运行中处理的`CF`,结果会写到分布式缓存中避免重复计算,下次就有了 - - 这是个常见业务使用模式,`cffu`提供了相应的`mostResultsOfSuccess`方法 + - 这是个常见业务使用模式,`cffu`提供了相应的`mostSuccessResultsOf`方法 > 📔 关于多个`CF`的并发执行策略,可以看看`JavaScript`规范[`Promise Concurrency`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise#promise_concurrency);在`JavaScript`中,`Promise`即对应`CompletableFuture`。 > > `JavaScript Promise`提供了4个并发执行方法: > -> - [`Promise.all()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/all):等待所有`Promise`运行成功,只要有一个失败就立即返回失败(对应`cffu`的`allOfFastFail`方法) +> - [`Promise.all()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/all):等待所有`Promise`运行成功,只要有一个失败就立即返回失败(对应`cffu`的`allFastFailOf`方法) > - [`Promise.allSettled()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/allSettled):等待所有`Promise`运行完成,不管成功失败(对应`cffu`的`allOf`方法) -> - [`Promise.any()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/any):赛马模式,立即返回首个成功的`Promise`(对应`cffu`的`anyOfSuccess`方法) +> - [`Promise.any()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/any):赛马模式,立即返回首个成功的`Promise`(对应`cffu`的`anySuccessOf`方法) > - [`Promise.race()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/race):赛马模式,立即返回首个完成的`Promise`(对应`cffu`的`anyOf`方法) > > PS:`JavaScript Promise`的方法命名真考究~ 👍 @@ -452,8 +452,8 @@ public class ConcurrencyStrategyDemo { public static void main(String[] args) throws Exception { //////////////////////////////////////////////////////////////////////// - // CffuFactory#allResultsOfFastFail - // CffuFactory#anyOfSuccess + // CffuFactory#allResultsFastFailOf + // CffuFactory#anySuccessOf //////////////////////////////////////////////////////////////////////// final Cffu successAfterLongTime = cffuFactory.supplyAsync(() -> { sleep(3000); // sleep LONG time @@ -462,18 +462,18 @@ public class ConcurrencyStrategyDemo { final Cffu failed = cffuFactory.failedFuture(new RuntimeException("Bang!")); // Result type is Void! - Cffu cffuAll = cffuFactory.allOfFastFail(successAfterLongTime, failed); + Cffu cffuAll = cffuFactory.allFastFailOf(successAfterLongTime, failed); - Cffu> fastFailed = cffuFactory.allResultsOfFastFail(successAfterLongTime, failed); + Cffu> fastFailed = cffuFactory.allResultsFastFailOf(successAfterLongTime, failed); // fast failed without waiting successAfterLongTime System.out.println(fastFailed.exceptionNow()); - Cffu anyOfSuccess = cffuFactory.anyOfSuccess(successAfterLongTime, failed); - System.out.println(anyOfSuccess.get()); + Cffu anySuccessOf = cffuFactory.anySuccessOf(successAfterLongTime, failed); + System.out.println(anySuccessOf.get()); //////////////////////////////////////////////////////////////////////// - // or CompletableFutureUtils#allOfFastFail / allResultsOfFastFail - // CompletableFutureUtils#anyOfSuccess + // or CompletableFutureUtils#allFastFailOf / allResultsFastFailOf + // CompletableFutureUtils#anySuccessOf //////////////////////////////////////////////////////////////////////// final CompletableFuture successAfterLongTimeCf = CompletableFuture.supplyAsync(() -> { sleep(3000); // sleep LONG time @@ -482,13 +482,13 @@ public class ConcurrencyStrategyDemo { final CompletableFuture failedCf = CompletableFutureUtils.failedFuture(new RuntimeException("Bang!")); // Result type is Void! - CompletableFuture cfAll = CompletableFutureUtils.allOfFastFail(successAfterLongTimeCf, failedCf); + CompletableFuture cfAll = CompletableFutureUtils.allFastFailOf(successAfterLongTimeCf, failedCf); - CompletableFuture> fastFailedCf = CompletableFutureUtils.allResultsOfFastFail(successAfterLongTimeCf, failedCf); + CompletableFuture> fastFailedCf = CompletableFutureUtils.allResultsFastFailOf(successAfterLongTimeCf, failedCf); // fast failed without waiting successAfterLongTime System.out.println(CompletableFutureUtils.exceptionNow(fastFailedCf)); - CompletableFuture cfSuccess = CompletableFutureUtils.anyOfSuccess(successAfterLongTimeCf, failedCf); + CompletableFuture cfSuccess = CompletableFutureUtils.anySuccessOf(successAfterLongTimeCf, failedCf); System.out.println(cfSuccess.get()); } } @@ -570,18 +570,18 @@ public class ConcurrencyStrategyDemo { io.foldright cffu - 1.0.0-Alpha11 + 1.0.0-Alpha12 ``` - For `Gradle` projects: ```groovy // Gradle Kotlin DSL - implementation("io.foldright:cffu:1.0.0-Alpha11") + implementation("io.foldright:cffu:1.0.0-Alpha12") ``` ```groovy // Gradle Groovy DSL - implementation 'io.foldright:cffu:1.0.0-Alpha11' + implementation 'io.foldright:cffu:1.0.0-Alpha12' ``` - `cffu Kotlin`支持库: - For `Maven` projects: @@ -590,18 +590,18 @@ public class ConcurrencyStrategyDemo { io.foldright cffu-kotlin - 1.0.0-Alpha11 + 1.0.0-Alpha12 ``` - For `Gradle` projects: ```groovy // Gradle Kotlin DSL - implementation("io.foldright:cffu-kotlin:1.0.0-Alpha11") + implementation("io.foldright:cffu-kotlin:1.0.0-Alpha12") ``` ```groovy // Gradle Groovy DSL - implementation 'io.foldright:cffu-kotlin:1.0.0-Alpha11' + implementation 'io.foldright:cffu-kotlin:1.0.0-Alpha12' ``` - `cffu bom`: - For `Maven` projects: @@ -610,7 +610,7 @@ public class ConcurrencyStrategyDemo { io.foldright cffu-bom - 1.0.0-Alpha11 + 1.0.0-Alpha12 pom import @@ -619,11 +619,11 @@ public class ConcurrencyStrategyDemo { ```groovy // Gradle Kotlin DSL - implementation(platform("io.foldright:cffu-bom:1.0.0-Alpha11")) + implementation(platform("io.foldright:cffu-bom:1.0.0-Alpha12")) ``` ```groovy // Gradle Groovy DSL - implementation platform('io.foldright:cffu-bom:1.0.0-Alpha11') + implementation platform('io.foldright:cffu-bom:1.0.0-Alpha12') ``` - [📌 `TransmittableThreadLocal(TTL)`](https://github.com/alibaba/transmittable-thread-local)的[`cffu executor wrapper SPI`实现](cffu-ttl-executor-wrapper): - For `Maven` projects: @@ -632,7 +632,7 @@ public class ConcurrencyStrategyDemo { io.foldright cffu-ttl-executor-wrapper - 1.0.0-Alpha11 + 1.0.0-Alpha12 runtime ``` @@ -640,11 +640,11 @@ public class ConcurrencyStrategyDemo { ```groovy // Gradle Kotlin DSL - runtimeOnly("io.foldright:cffu-ttl-executor-wrapper:1.0.0-Alpha11") + runtimeOnly("io.foldright:cffu-ttl-executor-wrapper:1.0.0-Alpha12") ``` ```groovy // Gradle Groovy DSL - runtimeOnly 'io.foldright:cffu-ttl-executor-wrapper:1.0.0-Alpha11' + runtimeOnly 'io.foldright:cffu-ttl-executor-wrapper:1.0.0-Alpha12' ``` # 📚 更多资料 diff --git a/cffu-core/pom.xml b/cffu-core/pom.xml index 7a7e0ecd..80cfc32f 100644 --- a/cffu-core/pom.xml +++ b/cffu-core/pom.xml @@ -11,7 +11,8 @@ cffu CompletableFuture-Fu(cffu) - 🦝 A tiny sidekick library for CompletableFuture to improve user experience and reduce misuse. + 🦝 A tiny sidekick library to make CompletableFuture usage + more convenient, more efficient and safer in your application. 😋🚀🦺 https://github.com/foldright/cffu 2023 diff --git a/cffu-core/src/main/java/io/foldright/cffu/Cffu.java b/cffu-core/src/main/java/io/foldright/cffu/Cffu.java index a2e824eb..27a0e81d 100644 --- a/cffu-core/src/main/java/io/foldright/cffu/Cffu.java +++ b/cffu-core/src/main/java/io/foldright/cffu/Cffu.java @@ -217,18 +217,14 @@ public Cffu thenRunAsync(Runnable action, Executor 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. - *

- * This method is the same as {@link #thenMApplyAsync(CompletionStage, Function[])} - * except for the fast-fail behavior. * * @param fns the functions to use to compute the values of the returned Cffu * @param the functions' return type * @return the new Cffu */ @SafeVarargs - public final Cffu> thenMApplyFastFailAsync( - CompletionStage cf, Function... fns) { - return thenMApplyFastFailAsync(cf, fac.defaultExecutor(), fns); + public final Cffu> thenMApplyFastFailAsync(Function... fns) { + return thenMApplyFastFailAsync(fac.defaultExecutor(), fns); } /** @@ -236,18 +232,14 @@ public final Cffu> thenMApplyFastFailAsync( * 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. - *

- * This method is the same as {@link #thenMApplyAsync(CompletionStage, Executor, Function[])} - * except for the fast-fail behavior. * + * @param executor the executor to use for asynchronous execution * @param fns the functions to use to compute the values of the returned Cffu - * @param executor executor * @param the functions' return type * @return the new Cffu */ @SafeVarargs - public final Cffu> thenMApplyFastFailAsync( - CompletionStage cf, Executor executor, Function... fns) { + public final Cffu> thenMApplyFastFailAsync(Executor executor, Function... fns) { return reset0(CompletableFutureUtils.thenMApplyFastFailAsync(cf, executor, fns)); } @@ -271,9 +263,8 @@ public final Cffu> thenMApplyFastFailAsync( */ @SafeVarargs public final Cffu> thenMApplyMostSuccessAsync( - CompletionStage cf, @Nullable U valueIfNotSuccess, - long timeout, TimeUnit unit, Function... fns) { - return thenMApplyMostSuccessAsync(cf, valueIfNotSuccess, fac.defaultExecutor(), timeout, unit, fns); + @Nullable U valueIfNotSuccess, long timeout, TimeUnit unit, Function... fns) { + return thenMApplyMostSuccessAsync(valueIfNotSuccess, fac.defaultExecutor(), timeout, unit, fns); } /** @@ -296,8 +287,8 @@ public final Cffu> thenMApplyMostSuccessAsync( */ @SafeVarargs public final Cffu> thenMApplyMostSuccessAsync( - CompletionStage cf, @Nullable U valueIfNotSuccess, - Executor executor, long timeout, TimeUnit unit, Function... fns) { + @Nullable U valueIfNotSuccess, Executor executor, long timeout, TimeUnit unit, + Function... fns) { return reset0(CompletableFutureUtils.thenMApplyMostSuccessAsync(cf, valueIfNotSuccess, executor, timeout, unit, fns)); } @@ -313,9 +304,8 @@ public final Cffu> thenMApplyMostSuccessAsync( * @return the new Cffu */ @SafeVarargs - public final Cffu> thenMApplyAsync( - CompletionStage cf, Function... fns) { - return thenMApplyAsync(cf, fac.defaultExecutor(), fns); + public final Cffu> thenMApplyAsync(Function... fns) { + return thenMApplyAsync(fac.defaultExecutor(), fns); } /** @@ -324,13 +314,13 @@ public final Cffu> thenMApplyAsync( * (with the given stage's result as the argument to the given functions) * in the same order of the given Functions arguments. * - * @param fns the functions to use to compute the values of the returned Cffu - * @param the functions' return type + * @param executor the executor to use for asynchronous execution + * @param fns the functions to use to compute the values of the returned Cffu + * @param the functions' return type * @return the new Cffu */ @SafeVarargs - public final Cffu> thenMApplyAsync( - CompletionStage cf, Executor executor, Function... fns) { + public final Cffu> thenMApplyAsync(Executor executor, Function... fns) { return reset0(CompletableFutureUtils.thenMApplyAsync(cf, executor, fns)); } @@ -343,21 +333,20 @@ public final Cffu> thenMApplyAsync( * @return the new Cffu */ @SafeVarargs - public final Cffu thenMAcceptAsync( - CompletionStage cf, Consumer... actions) { - return thenMAcceptAsync(cf, fac.defaultExecutor(), actions); + public final Cffu thenMAcceptAsync(Consumer... actions) { + return thenMAcceptAsync(fac.defaultExecutor(), actions); } /** * Returns a new Cffu 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. * - * @param actions the actions to perform before completing the returned Cffu + * @param executor the executor to use for asynchronous execution + * @param actions the actions to perform before completing the returned Cffu * @return the new Cffu */ @SafeVarargs - public final Cffu thenMAcceptAsync( - CompletionStage cf, Executor executor, Consumer... actions) { + public final Cffu thenMAcceptAsync(Executor executor, Consumer... actions) { return reset0(CompletableFutureUtils.thenMAcceptAsync(cf, executor, actions)); } @@ -365,32 +354,25 @@ public final Cffu thenMAcceptAsync( * Returns a new Cffu that, when the given stage completes normally, * is executed using {@link #defaultExecutor()}, * with the given stage's result as the argument to the given actions. - *

- * This method is the same as {@link #thenMAcceptAsync(CompletionStage, Consumer[])} - * except for the fast-fail behavior. * * @param actions the actions to perform before completing the returned Cffu * @return the new Cffu */ @SafeVarargs - public final Cffu thenMAcceptFastFailAsync( - CompletionStage cf, Consumer... actions) { - return thenMAcceptFastFailAsync(cf, fac.defaultExecutor(), actions); + public final Cffu thenMAcceptFastFailAsync(Consumer... actions) { + return thenMAcceptFastFailAsync(fac.defaultExecutor(), actions); } /** * Returns a new Cffu 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. - *

- * This method is the same as {@link #thenMAcceptAsync(CompletionStage, Executor, Consumer[])} - * except for the fast-fail behavior. * - * @param actions the actions to perform before completing the returned Cffu + * @param executor the executor to use for asynchronous execution + * @param actions the actions to perform before completing the returned Cffu * @return the new Cffu */ @SafeVarargs - public final Cffu thenMAcceptFastFailAsync( - CompletionStage cf, Executor executor, Consumer... actions) { + public final Cffu thenMAcceptFastFailAsync(Executor executor, Consumer... actions) { return reset0(CompletableFutureUtils.thenMAcceptFastFailAsync(cf, executor, actions)); } @@ -398,31 +380,25 @@ public final Cffu thenMAcceptFastFailAsync( /** * Returns a new Cffu that, when the given stage completes normally, * executes using {@link #defaultExecutor()}, - *

- * This method is the same as {@link #thenMRunAsync(CompletionStage, Runnable...)} - * except for the fast-fail behavior. * * @param actions the actions to perform before completing the returned Cffu * @return the new Cffu * @see CompletableFuture#thenRunAsync(Runnable) */ - public Cffu thenMRunFastFailAsync(CompletionStage cf, Runnable... actions) { - return thenMRunFastFailAsync(cf, fac.defaultExecutor(), actions); + public Cffu thenMRunFastFailAsync(Runnable... actions) { + return thenMRunFastFailAsync(fac.defaultExecutor(), actions); } /** * Returns a new Cffu that, when the given stage completes normally, * executes the given actions using the given Executor. - *

- * This method is the same as {@link #thenMRunAsync(CompletionStage, Executor, Runnable...)} - * except for the fast-fail behavior. * - * @param actions the actions to perform before completing the returned Cffu + * @param executor the executor to use for asynchronous execution + * @param actions the actions to perform before completing the returned Cffu * @return the new Cffu * @see CompletableFuture#thenRunAsync(Runnable, Executor) */ - public Cffu thenMRunFastFailAsync( - CompletionStage cf, Executor executor, Runnable... actions) { + public Cffu thenMRunFastFailAsync(Executor executor, Runnable... actions) { return reset0(CompletableFutureUtils.thenMRunFastFailAsync(cf, executor, actions)); } @@ -434,19 +410,20 @@ public Cffu thenMRunFastFailAsync( * @return the new Cffu * @see CompletableFuture#thenRunAsync(Runnable) */ - public Cffu thenMRunAsync(CompletionStage cf, Runnable... actions) { - return thenMRunAsync(cf, fac.defaultExecutor(), actions); + public Cffu thenMRunAsync(Runnable... actions) { + return thenMRunAsync(fac.defaultExecutor(), actions); } /** * Returns a new Cffu that, when the given stage completes normally, * executes the given actions using the given Executor. * - * @param actions the actions to perform before completing the returned Cffu + * @param executor the executor to use for asynchronous execution + * @param actions the actions to perform before completing the returned Cffu * @return the new Cffu * @see CompletableFuture#thenRunAsync(Runnable, Executor) */ - public Cffu thenMRunAsync(CompletionStage cf, Executor executor, Runnable... actions) { + public Cffu thenMRunAsync(Executor executor, Runnable... actions) { return reset0(CompletableFutureUtils.thenMRunAsync(cf, executor, actions)); } @@ -460,9 +437,6 @@ public Cffu thenMRunAsync(CompletionStage cf, Executor executor, Runnab * with the values obtained by calling the given Functions * (with this Cffu's result as the argument to the given functions) * in the same order of the given Functions arguments. - *

- * This method is the same as {@link #thenTupleMApplyAsync(Function, Function)} - * except for the fast-fail behavior. * * @return the new Cffu */ @@ -476,10 +450,8 @@ public Cffu> thenTupleMApplyFastFailAsync( * with the values obtained by calling the given Functions * (with this Cffu's result as the argument to the given functions) * in the same order of the given Functions arguments. - *

- * This method is the same as {@link #thenTupleMApplyAsync(Executor, Function, Function)} - * except for the fast-fail behavior. * + * @param executor the executor to use for asynchronous execution * @return the new Cffu */ public Cffu> thenTupleMApplyFastFailAsync( @@ -492,9 +464,6 @@ public Cffu> thenTupleMApplyFastFailAsync( * with the values obtained by calling the given Functions * (with this Cffu's result as the argument to the given functions) * in the same order of the given Functions arguments. - *

- * This method is the same as {@link #thenTupleMApplyAsync(Function, Function, Function)} - * except for the fast-fail behavior. * * @return the new Cffu */ @@ -509,10 +478,8 @@ public Cffu> thenTupleMApplyFastFailAsync( * with the values obtained by calling the given Functions * (with this Cffu's result as the argument to the given functions) * in the same order of the given Functions arguments. - *

- * This method is the same as {@link #thenTupleMApplyAsync(Executor, Function, Function, Function)} - * except for the fast-fail behavior. * + * @param executor the executor to use for asynchronous execution * @return the new Cffu */ public Cffu> thenTupleMApplyFastFailAsync( @@ -526,9 +493,6 @@ public Cffu> thenTupleMApplyFastFailAsync( * with the values obtained by calling the given Functions * (with this Cffu's result as the argument to the given functions) * in the same order of the given Functions arguments. - *

- * This method is the same as {@link #thenTupleMApplyAsync(Function, Function, Function, Function)} - * except for the fast-fail behavior. * * @return the new Cffu */ @@ -543,10 +507,8 @@ public Cffu> thenTupleMApplyFastFailAsyn * with the values obtained by calling the given Functions * (with this Cffu's result as the argument to the given functions) * in the same order of the given Functions arguments. - *

- * This method is the same as {@link #thenTupleMApplyAsync(Executor, Function, Function, Function, Function)} - * except for the fast-fail behavior. * + * @param executor the executor to use for asynchronous execution * @return the new Cffu */ public Cffu> thenTupleMApplyFastFailAsync( @@ -560,9 +522,6 @@ public Cffu> thenTupleMApplyFastFailAsyn * with the values obtained by calling the given Functions * (with this Cffu's result as the argument to the given functions) * in the same order of the given Functions arguments. - *

- * This method is the same as {@link #thenTupleMApplyAsync(Function, Function, Function, Function, Function)} - * except for the fast-fail behavior. * * @return the new Cffu */ @@ -578,10 +537,8 @@ public Cffu> thenTupleMApplyFast * with the values obtained by calling the given Functions * (with this Cffu's result as the argument to the given functions) * in the same order of the given Functions arguments. - *

- * This method is the same as {@link #thenTupleMApplyAsync(Executor, Function, Function, Function, Function, Function)} - * except for the fast-fail behavior. * + * @param executor the executor to use for asynchronous execution * @return the new Cffu */ public Cffu> thenTupleMApplyFastFailAsync( @@ -596,9 +553,6 @@ public Cffu> thenTupleMApplyFast * with the values obtained by calling the given Functions * (with this Cffu's result as the argument to the given functions) * in the same order of the given Functions arguments. - *

- * This method is the same as {@link #thenTupleMApplyAsync(Function, Function)} - * except for the fast-fail behavior. * * @return the new Cffu */ @@ -612,10 +566,8 @@ public Cffu> thenTupleMApplyMostSuccessAsync( * with the values obtained by calling the given Functions * (with this Cffu's result as the argument to the given functions) * in the same order of the given Functions arguments. - *

- * This method is the same as {@link #thenTupleMApplyAsync(Executor, Function, Function)} - * except for the fast-fail behavior. * + * @param executor the executor to use for asynchronous execution * @return the new Cffu */ public Cffu> thenTupleMApplyMostSuccessAsync( @@ -629,9 +581,6 @@ public Cffu> thenTupleMApplyMostSuccessAsync( * with the values obtained by calling the given Functions * (with this Cffu's result as the argument to the given functions) * in the same order of the given Functions arguments. - *

- * This method is the same as {@link #thenTupleMApplyAsync(Function, Function, Function)} - * except for the fast-fail behavior. * * @return the new Cffu */ @@ -646,10 +595,8 @@ public Cffu> thenTupleMApplyMostSuccessAsync( * with the values obtained by calling the given Functions * (with this Cffu's result as the argument to the given functions) * in the same order of the given Functions arguments. - *

- * This method is the same as {@link #thenTupleMApplyAsync(Executor, Function, Function, Function)} - * except for the fast-fail behavior. * + * @param executor the executor to use for asynchronous execution * @return the new Cffu */ public Cffu> thenTupleMApplyMostSuccessAsync( @@ -663,9 +610,6 @@ public Cffu> thenTupleMApplyMostSuccessAsync( * with the values obtained by calling the given Functions * (with this Cffu's result as the argument to the given functions) * in the same order of the given Functions arguments. - *

- * This method is the same as {@link #thenTupleMApplyAsync(Function, Function, Function, Function)} - * except for the fast-fail behavior. * * @return the new Cffu */ @@ -681,10 +625,8 @@ public Cffu> thenTupleMApplyMostSuccessA * with the values obtained by calling the given Functions * (with this Cffu's result as the argument to the given functions) * in the same order of the given Functions arguments. - *

- * This method is the same as {@link #thenTupleMApplyAsync(Executor, Function, Function, Function, Function)} - * except for the fast-fail behavior. * + * @param executor the executor to use for asynchronous execution * @return the new Cffu */ public Cffu> thenTupleMApplyMostSuccessAsync( @@ -699,9 +641,6 @@ public Cffu> thenTupleMApplyMostSuccessA * with the values obtained by calling the given Functions * (with this Cffu's result as the argument to the given functions) * in the same order of the given Functions arguments. - *

- * This method is the same as {@link #thenTupleMApplyAsync(Function, Function, Function, Function, Function)} - * except for the fast-fail behavior. * * @return the new Cffu */ @@ -717,10 +656,8 @@ public Cffu> thenTupleMApplyMost * with the values obtained by calling the given Functions * (with this Cffu's result as the argument to the given functions) * in the same order of the given Functions arguments. - *

- * This method is the same as {@link #thenTupleMApplyAsync(Executor, Function, Function, Function, Function, Function)} - * except for the fast-fail behavior. * + * @param executor the executor to use for asynchronous execution * @return the new Cffu */ public Cffu> thenTupleMApplyMostSuccessAsync( @@ -749,6 +686,7 @@ public Cffu> thenTupleMApplyAsync( * (with this Cffu's result as the argument to the given functions) * in the same order of the given Functions arguments. * + * @param executor the executor to use for asynchronous execution * @return the new Cffu */ public Cffu> thenTupleMApplyAsync( @@ -776,6 +714,7 @@ public Cffu> thenTupleMApplyAsync( * (with this Cffu's result as the argument to the given functions) * in the same order of the given Functions arguments. * + * @param executor the executor to use for asynchronous execution * @return the new Cffu */ public Cffu> thenTupleMApplyAsync( @@ -804,6 +743,7 @@ public Cffu> thenTupleMApplyAsync( * (with this Cffu's result as the argument to the given functions) * in the same order of the given Functions arguments. * + * @param executor the executor to use for asynchronous execution * @return the new Cffu */ public Cffu> thenTupleMApplyAsync( @@ -833,6 +773,7 @@ public Cffu> thenTupleMApplyAsyn * (with this Cffu's result as the argument to the given functions) * in the same order of the given Functions arguments. * + * @param executor the executor to use for asynchronous execution * @return the new Cffu */ public Cffu> thenTupleMApplyAsync( @@ -857,9 +798,6 @@ public Cffu> thenTupleMApplyAsyn * if any of the given stage complete exceptionally, then the returned Cffu also does so * *without* waiting other incomplete given CompletionStage, * with a CompletionException holding this exception as its cause. - *

- * This method is the same as {@link #thenCombine(CompletionStage, BiFunction)} - * except for the fast-fail behavior. * * @param other the other CompletionStage * @param fn the function to use to compute the value of the returned Cffu @@ -870,7 +808,7 @@ public Cffu> thenTupleMApplyAsyn @CheckReturnValue(explanation = "should use the returned Cffu; otherwise, prefer method `thenAcceptBothFastFail`") public Cffu thenCombineFastFail( CompletionStage other, BiFunction fn) { - return reset0(CompletableFutureUtils.thenCombineFastFail(this, other, fn)); + return reset0(CompletableFutureUtils.thenCombineFastFail(cf, other, fn)); } /** @@ -879,9 +817,6 @@ public Cffu thenCombineFastFail( * if any of the given stage complete exceptionally, then the returned Cffu also does so * *without* waiting other incomplete given CompletionStage, * with a CompletionException holding this exception as its cause. - *

- * This method is the same as {@link #thenCombineAsync(CompletionStage, BiFunction)} - * except for the fast-fail behavior. * * @param other the other CompletionStage * @param fn the function to use to compute the value of the returned Cffu @@ -901,9 +836,6 @@ public Cffu thenCombineFastFailAsync( * if any of the given stage complete exceptionally, then the returned Cffu also does so * *without* waiting other incomplete given CompletionStage, * with a CompletionException holding this exception as its cause. - *

- * This method is the same as {@link #thenCombineAsync(CompletionStage, BiFunction, Executor)} - * except for the fast-fail behavior. * * @param other the other CompletionStage * @param fn the function to use to compute the value of the returned Cffu @@ -916,7 +848,7 @@ public Cffu thenCombineFastFailAsync( public Cffu thenCombineFastFailAsync(CompletionStage other, BiFunction fn, Executor executor) { - return reset0(CompletableFutureUtils.thenCombineFastFailAsync(this, other, fn, executor)); + return reset0(CompletableFutureUtils.thenCombineFastFailAsync(cf, other, fn, executor)); } /** @@ -925,9 +857,6 @@ public Cffu thenCombineFastFailAsync(CompletionStage othe * if any of the given stage complete exceptionally, then the returned Cffu also does so * *without* waiting other incomplete given CompletionStage, * with a CompletionException holding this exception as its cause. - *

- * This method is the same as {@link #thenAcceptBoth(CompletionStage, BiConsumer)} - * except for the fast-fail behavior. * * @param other the other CompletionStage * @param action the action to perform before completing the returned Cffu @@ -936,7 +865,7 @@ public Cffu thenCombineFastFailAsync(CompletionStage othe */ public Cffu thenAcceptBothFastFail( CompletionStage other, BiConsumer action) { - return reset0(CompletableFutureUtils.thenAcceptBothFastFail(this, other, action)); + return reset0(CompletableFutureUtils.thenAcceptBothFastFail(cf, other, action)); } /** @@ -945,9 +874,6 @@ public Cffu thenAcceptBothFastFail( * if any of the given stage complete exceptionally, then the returned Cffu also does so * *without* waiting other incomplete given CompletionStage, * with a CompletionException holding this exception as its cause. - *

- * This method is the same as {@link #thenAcceptBothAsync(CompletionStage, BiConsumer)} - * except for the fast-fail behavior. * * @param other the other CompletionStage * @param action the action to perform before completing the returned Cffu @@ -965,9 +891,6 @@ public Cffu thenAcceptBothFastFailAsync( * if any of the given stage complete exceptionally, then the returned Cffu also does so * *without* waiting other incomplete given CompletionStage, * with a CompletionException holding this exception as its cause. - *

- * This method is the same as {@link #thenAcceptBothAsync(CompletionStage, BiConsumer, Executor)} - * except for the fast-fail behavior. * * @param other the other CompletionStage * @param action the action to perform before completing the returned Cffu @@ -978,7 +901,7 @@ public Cffu thenAcceptBothFastFailAsync( public Cffu thenAcceptBothFastFailAsync(CompletionStage other, BiConsumer action, Executor executor) { - return reset0(CompletableFutureUtils.thenAcceptBothFastFailAsync(this, other, action, executor)); + return reset0(CompletableFutureUtils.thenAcceptBothFastFailAsync(cf, other, action, executor)); } /** @@ -986,16 +909,13 @@ public Cffu thenAcceptBothFastFailAsync(CompletionStage o * if any of the given stage complete exceptionally, then the returned Cffu also does so * *without* waiting other incomplete given CompletionStage, * with a CompletionException holding this exception as its cause. - *

- * This method is the same as {@link #runAfterBoth(CompletionStage, Runnable)} - * except for the fast-fail behavior. * * @param other the other CompletionStage * @param action the action to perform before completing the returned Cffu * @return the new Cffu */ public Cffu runAfterBothFastFail(CompletionStage other, Runnable action) { - return reset0(CompletableFutureUtils.runAfterBothFastFail(this, other, action)); + return reset0(CompletableFutureUtils.runAfterBothFastFail(cf, other, action)); } /** @@ -1004,9 +924,6 @@ public Cffu runAfterBothFastFail(CompletionStage other, Runnable action * if any of the given stage complete exceptionally, then the returned Cffu also does so * *without* waiting other incomplete given CompletionStage, * with a CompletionException holding this exception as its cause. - *

- * This method is the same as {@link #runAfterBothAsync(CompletionStage, Runnable)} - * except for the fast-fail behavior. * * @param other the other CompletionStage * @param action the action to perform before completing the returned Cffu @@ -1022,9 +939,6 @@ public Cffu runAfterBothFastFailAsync(CompletionStage other, Runnable a * if any of the given stage complete exceptionally, then the returned Cffu also does so * *without* waiting other incomplete given CompletionStage, * with a CompletionException holding this exception as its cause. - *

- * This method is the same as {@link #runAfterBothAsync(CompletionStage, Runnable, Executor)} - * except for the fast-fail behavior. * * @param other the other CompletionStage * @param action the action to perform before completing the returned Cffu @@ -1032,7 +946,7 @@ public Cffu runAfterBothFastFailAsync(CompletionStage other, Runnable a * @return the new Cffu */ public Cffu runAfterBothFastFailAsync(CompletionStage other, Runnable action, Executor executor) { - return reset0(CompletableFutureUtils.runAfterBothFastFailAsync(this, other, action, executor)); + return reset0(CompletableFutureUtils.runAfterBothFastFailAsync(cf, other, action, executor)); } /** @@ -1206,9 +1120,6 @@ public Cffu runAfterBothAsync(CompletionStage other, Runnable action, E /** * Returns a new Cffu that, when either this or the other given stage complete normally, * is executed with the corresponding result as argument to the supplied function. - *

- * This method is the same as {@link #applyToEither(CompletionStage, Function)} - * except for the either-success behavior instead of either-complete. * * @param other the other CompletionStage * @param fn the function to use to compute the value of the returned Cffu @@ -1218,16 +1129,13 @@ public Cffu runAfterBothAsync(CompletionStage other, Runnable action, E @CheckReturnValue(explanation = "should use the returned Cffu; otherwise, prefer method `acceptEitherSuccess`") public Cffu applyToEitherSuccess( CompletionStage other, Function fn) { - return reset0(CompletableFutureUtils.applyToEitherSuccess(this, other, fn)); + return reset0(CompletableFutureUtils.applyToEitherSuccess(cf, other, fn)); } /** * Returns a new Cffu that, when either this or the other given stage complete normally, * is executed using {@link #defaultExecutor()}, * with the corresponding result as argument to the supplied function. - *

- * This method is the same as {@link #applyToEitherAsync(CompletionStage, Function)} - * except for the either-success behavior instead of either-complete. * * @param other the other CompletionStage * @param fn the function to use to compute the value of the returned Cffu @@ -1243,9 +1151,6 @@ public Cffu applyToEitherSuccessAsync( /** * Returns a new Cffu that, when either this or the other given stage complete normally, * is executed using the supplied executor, with the corresponding result as argument to the supplied function. - *

- * This method is the same as {@link #applyToEitherAsync(CompletionStage, Function, Executor)} - * except for the either-success behavior instead of either-complete. * * @param other the other CompletionStage * @param fn the function to use to compute the value of the returned Cffu @@ -1257,15 +1162,12 @@ public Cffu applyToEitherSuccessAsync( public Cffu applyToEitherSuccessAsync(CompletionStage other, Function fn, Executor executor) { - return reset0(CompletableFutureUtils.applyToEitherSuccessAsync(this, other, fn, executor)); + return reset0(CompletableFutureUtils.applyToEitherSuccessAsync(cf, other, fn, executor)); } /** * Returns a new Cffu that, when either this or the other given stage complete normally, * is executed with the corresponding result as argument to the supplied action. - *

- * This method is the same as {@link #acceptEither(CompletionStage, Consumer)} - * except for the either-success behavior instead of either-complete. * * @param other the other CompletionStage * @param action the action to perform before completing the returned Cffu @@ -1273,16 +1175,13 @@ public Cffu applyToEitherSuccessAsync(CompletionStage other, */ public Cffu acceptEitherSuccess( CompletionStage other, Consumer action) { - return reset0(CompletableFutureUtils.acceptEitherSuccess(this, other, action)); + return reset0(CompletableFutureUtils.acceptEitherSuccess(cf, other, action)); } /** * Returns a new Cffu that, when either this or the other given stage complete normally, * is executed using {@link #defaultExecutor()}, * with the corresponding result as argument to the supplied action. - *

- * This method is the same as {@link #acceptEitherAsync(CompletionStage, Consumer)} - * except for the either-success behavior instead of either-complete. * * @param other the other CompletionStage * @param action the action to perform before completing the returned Cffu @@ -1296,9 +1195,6 @@ public Cffu acceptEitherSuccessAsync( /** * Returns a new Cffu that, when either this or the other given stage complete normally, * is executed using the supplied executor, with the corresponding result as argument to the supplied action. - *

- * This method is the same as {@link #acceptEitherAsync(CompletionStage, Consumer, Executor)} - * except for the either-success behavior instead of either-complete. * * @param other the other CompletionStage * @param action the action to perform before completing the returned Cffu @@ -1308,23 +1204,20 @@ public Cffu acceptEitherSuccessAsync( public Cffu acceptEitherSuccessAsync(CompletionStage other, Consumer action, Executor executor) { - return reset0(CompletableFutureUtils.acceptEitherSuccessAsync(this, other, action, executor)); + return reset0(CompletableFutureUtils.acceptEitherSuccessAsync(cf, other, action, executor)); } /** * Returns a new Cffu that, when either this or the other given stage complete normally, executes the given action. * Otherwise, all two complete exceptionally, the returned Cffu also does so, * with a CompletionException holding an exception from any of as its cause. - *

- * This method is the same as {@link #runAfterEither(CompletionStage, Runnable)} - * except for the either-success behavior instead of either-complete. * * @param other the other CompletionStage * @param action the action to perform before completing the returned Cffu * @return the new Cffu */ public Cffu runAfterEitherSuccess(CompletionStage other, Runnable action) { - return reset0(CompletableFutureUtils.runAfterEitherSuccess(this, other, action)); + return reset0(CompletableFutureUtils.runAfterEitherSuccess(cf, other, action)); } /** @@ -1332,9 +1225,6 @@ public Cffu runAfterEitherSuccess(CompletionStage other, Runnable actio * executes the given action using {@link #defaultExecutor()}. * Otherwise, all two complete exceptionally, the returned Cffu also does so, * with a CompletionException holding an exception from any of as its cause. - *

- * This method is the same as {@link #runAfterEitherAsync(CompletionStage, Runnable)} - * except for the either-success behavior instead of either-complete. * * @param other the other CompletionStage * @param action the action to perform before completing the returned Cffu @@ -1349,9 +1239,6 @@ public Cffu runAfterEitherSuccessAsync(CompletionStage other, Runnable * executes the given action using the supplied executor. * Otherwise, all two complete exceptionally, the returned Cffu also does so, * with a CompletionException holding an exception from any of as its cause. - *

- * This method is the same as {@link #runAfterEitherAsync(CompletionStage, Runnable, Executor)} - * except for the either-success behavior instead of either-complete. * * @param other the other CompletionStage * @param action the action to perform before completing the returned Cffu @@ -1360,7 +1247,7 @@ public Cffu runAfterEitherSuccessAsync(CompletionStage other, Runnable */ public Cffu runAfterEitherSuccessAsync( CompletionStage other, Runnable action, Executor executor) { - return reset0(CompletableFutureUtils.runAfterEitherSuccessAsync(this, other, action, executor)); + return reset0(CompletableFutureUtils.runAfterEitherSuccessAsync(cf, other, action, executor)); } /** diff --git a/cffu-core/src/main/java/io/foldright/cffu/CffuFactory.java b/cffu-core/src/main/java/io/foldright/cffu/CffuFactory.java index ee687960..667e52dd 100644 --- a/cffu-core/src/main/java/io/foldright/cffu/CffuFactory.java +++ b/cffu-core/src/main/java/io/foldright/cffu/CffuFactory.java @@ -157,13 +157,11 @@ public Cffu runAsync(Runnable action, Executor executor) { * by tasks running in the Cffu's default asynchronous execution facility * with the values obtained by calling the given Suppliers * in the same order of the given Suppliers arguments. - *

- * This method is the same as {@link #mSupplyAsync(Supplier[])} except for the fast-fail behavior. * * @param suppliers the suppliers returning the value to be used to complete the returned Cffu * @param the suppliers' return type * @return the new Cffu - * @see #allResultsOfFastFail(CompletionStage[]) + * @see #allResultsFastFailOf(CompletionStage[]) */ @SafeVarargs public final Cffu> mSupplyFastFailAsync(Supplier... suppliers) { @@ -174,13 +172,12 @@ public final Cffu> mSupplyFastFailAsync(Supplier... sup * Returns a new Cffu 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. - *

- * This method is the same as {@link #mSupplyAsync(Supplier[])} except for the fast-fail behavior. * + * @param executor the executor to use for asynchronous execution * @param suppliers the suppliers returning the value to be used to complete the returned Cffu * @param the suppliers' return type * @return the new Cffu - * @see #allResultsOfFastFail(CompletionStage[]) + * @see #allResultsFastFailOf(CompletionStage[]) */ @SafeVarargs public final Cffu> mSupplyFastFailAsync(Executor executor, Supplier... suppliers) { @@ -203,7 +200,7 @@ public final Cffu> mSupplyFastFailAsync(Executor executor, Supplier< * @param suppliers the suppliers returning the value to be used to complete the returned Cffu * @param the suppliers' return type * @return the new Cffu - * @see #mostResultsOfSuccess(Object, long, TimeUnit, CompletionStage[]) + * @see #mostSuccessResultsOf(Object, long, TimeUnit, CompletionStage[]) */ @SafeVarargs public final Cffu> mSupplyMostSuccessAsync( @@ -221,12 +218,13 @@ public final Cffu> mSupplyMostSuccessAsync( * Otherwise the given valueIfNotSuccess. * * @param valueIfNotSuccess the value to return if not completed successfully + * @param executor the executor to use for asynchronous execution * @param timeout how long to wait in units of {@code unit} * @param unit a {@code TimeUnit} determining how to interpret the {@code timeout} parameter * @param suppliers the suppliers returning the value to be used to complete the returned Cffu * @param the suppliers' return type * @return the new Cffu - * @see #mostResultsOfSuccess(Object, long, TimeUnit, CompletionStage[]) + * @see #mostSuccessResultsOf(Object, long, TimeUnit, CompletionStage[]) */ @SafeVarargs public final Cffu> mSupplyMostSuccessAsync( @@ -256,6 +254,7 @@ public final Cffu> mSupplyAsync(Supplier... suppliers) * with the values obtained by calling the given Suppliers * in the same order of the given Suppliers arguments. * + * @param executor the executor to use for asynchronous execution * @param suppliers the suppliers returning the value to be used to complete the returned Cffu * @param the suppliers' return type * @return the new Cffu @@ -271,12 +270,10 @@ public final Cffu> mSupplyAsync( * Returns a new Cffu that is asynchronously completed * by tasks running in the Cffu's default asynchronous execution facility * after runs the given actions. - *

- * This method is the same as {@link #mRunAsync(Runnable...)} except for the fast-fail behavior. * * @param actions the actions to run before completing the returned Cffu * @return the new Cffu - * @see #allOfFastFail(CompletionStage[]) + * @see #allFastFailOf(CompletionStage[]) */ public Cffu mRunFastFailAsync(Runnable... actions) { return mRunFastFailAsync(defaultExecutor, actions); @@ -285,12 +282,11 @@ public Cffu mRunFastFailAsync(Runnable... actions) { /** * Returns a new Cffu that is asynchronously completed by tasks running in the given Executor * after runs the given actions. - *

- * This method is the same as {@link #mRunAsync(Runnable...)} except for the fast-fail behavior. * - * @param actions the actions to run before completing the returned Cffu + * @param executor the executor to use for asynchronous execution + * @param actions the actions to run before completing the returned Cffu * @return the new Cffu - * @see #allOfFastFail(CompletionStage[]) + * @see #allFastFailOf(CompletionStage[]) */ public Cffu mRunFastFailAsync(Executor executor, Runnable... actions) { return create(CompletableFutureUtils.mRunFastFailAsync(executor, actions)); @@ -313,7 +309,8 @@ public Cffu mRunAsync(Runnable... actions) { * Returns a new Cffu that is asynchronously completed by tasks running in the given Executor * after runs the given actions. * - * @param actions the actions to run before completing the returned Cffu + * @param executor the executor to use for asynchronous execution + * @param actions the actions to run before completing the returned Cffu * @return the new Cffu * @see #allOf(CompletionStage[]) */ @@ -330,11 +327,9 @@ public Cffu mRunAsync(Executor executor, Runnable... actions) { * Returns a new Cffu that is asynchronously completed * by tasks running in the {@link #defaultExecutor()} with the values obtained by calling the given Suppliers * in the same order of the given Suppliers arguments. - *

- * This method is the same as {@link #tupleMSupplyAsync(Supplier, Supplier)} except for the fast-fail behavior. * * @return the new Cffu - * @see #allResultsOfFastFail(CompletionStage[]) + * @see #allResultsFastFailOf(CompletionStage[]) */ public Cffu> tupleMSupplyFastFailAsync( Supplier supplier1, Supplier supplier2) { @@ -345,11 +340,10 @@ public Cffu> tupleMSupplyFastFailAsync( * Returns a new Cffu that is asynchronously completed * by tasks running in the {@link #defaultExecutor()} with the values obtained by calling the given Suppliers * in the same order of the given Suppliers arguments. - *

- * This method is the same as {@link #tupleMSupplyAsync(Supplier, Supplier)} except for the fast-fail behavior. * + * @param executor the executor to use for asynchronous execution * @return the new Cffu - * @see #allResultsOfFastFail(CompletionStage[]) + * @see #allResultsFastFailOf(CompletionStage[]) */ public Cffu> tupleMSupplyFastFailAsync( Executor executor, Supplier supplier1, Supplier supplier2) { @@ -360,11 +354,9 @@ public Cffu> tupleMSupplyFastFailAsync( * Returns a new Cffu 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. - *

- * This method is the same as {@link #tupleMSupplyAsync(Supplier, Supplier, Supplier)} except for the fast-fail behavior. * * @return the new Cffu - * @see #allResultsOfFastFail(CompletionStage[]) + * @see #allResultsFastFailOf(CompletionStage[]) */ public Cffu> tupleMSupplyFastFailAsync( Supplier supplier1, Supplier supplier2, Supplier supplier3) { @@ -375,11 +367,10 @@ public Cffu> tupleMSupplyFastFailAsync( * Returns a new Cffu 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. - *

- * This method is the same as {@link #tupleMSupplyAsync(Supplier, Supplier, Supplier)} except for the fast-fail behavior. * + * @param executor the executor to use for asynchronous execution * @return the new Cffu - * @see #allResultsOfFastFail(CompletionStage[]) + * @see #allResultsFastFailOf(CompletionStage[]) */ public Cffu> tupleMSupplyFastFailAsync( Executor executor, Supplier supplier1, Supplier supplier2, Supplier supplier3) { @@ -390,11 +381,9 @@ public Cffu> tupleMSupplyFastFailAsync( * Returns a new Cffu that is asynchronously completed * by tasks running in the {@link #defaultExecutor()} with the values obtained by calling the given Suppliers * in the same order of the given Suppliers arguments. - *

- * This method is the same as {@link #tupleMSupplyAsync(Supplier, Supplier, Supplier, Supplier)} except for the fast-fail behavior. * * @return the new Cffu - * @see #allResultsOfFastFail(CompletionStage[]) + * @see #allResultsFastFailOf(CompletionStage[]) */ public Cffu> tupleMSupplyFastFailAsync( Supplier supplier1, Supplier supplier2, @@ -406,11 +395,10 @@ public Cffu> tupleMSupplyFastFailAsync( * Returns a new Cffu 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. - *

- * This method is the same as {@link #tupleMSupplyAsync(Supplier, Supplier, Supplier, Supplier)} except for the fast-fail behavior. * + * @param executor the executor to use for asynchronous execution * @return the new Cffu - * @see #allResultsOfFastFail(CompletionStage[]) + * @see #allResultsFastFailOf(CompletionStage[]) */ public Cffu> tupleMSupplyFastFailAsync( Executor executor, Supplier supplier1, Supplier supplier2, @@ -422,11 +410,9 @@ public Cffu> tupleMSupplyFastFailAsync( * Returns a new Cffu that is asynchronously completed * by tasks running in the {@link #defaultExecutor()} with the values obtained by calling the given Suppliers * in the same order of the given Suppliers arguments. - *

- * This method is the same as {@link #tupleMSupplyAsync(Supplier, Supplier, Supplier, Supplier, Supplier)} except for the fast-fail behavior. * * @return the new Cffu - * @see #allResultsOfFastFail(CompletionStage[]) + * @see #allResultsFastFailOf(CompletionStage[]) */ public Cffu> tupleMSupplyFastFailAsync( Supplier supplier1, Supplier supplier2, @@ -438,11 +424,10 @@ public Cffu> tupleMSupplyFastFai * Returns a new Cffu 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. - *

- * This method is the same as {@link #tupleMSupplyAsync(Supplier, Supplier, Supplier, Supplier, Supplier)} except for the fast-fail behavior. * + * @param executor the executor to use for asynchronous execution * @return the new Cffu - * @see #allResultsOfFastFail(CompletionStage[]) + * @see #allResultsFastFailOf(CompletionStage[]) */ public Cffu> tupleMSupplyFastFailAsync( Executor executor, Supplier supplier1, Supplier supplier2, @@ -454,8 +439,6 @@ public Cffu> tupleMSupplyFastFai * Returns a new Cffu that is asynchronously completed * by tasks running in the {@link #defaultExecutor()} with the values obtained by calling the given Suppliers * in the same order of the given Suppliers arguments. - *

- * This method is the same as {@link #tupleMSupplyAsync(Supplier, Supplier)} except for the most-success behavior. * * @return the new Cffu */ @@ -468,9 +451,8 @@ public Cffu> tupleMSupplyMostSuccessAsync( * Returns a new Cffu 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. - *

- * This method is the same as {@link #tupleMSupplyAsync(Supplier, Supplier)} except for the most-success behavior. * + * @param executor the executor to use for asynchronous execution * @return the new Cffu */ public Cffu> tupleMSupplyMostSuccessAsync( @@ -483,8 +465,6 @@ public Cffu> tupleMSupplyMostSuccessAsync( * Returns a new Cffu that is asynchronously completed * by tasks running in the {@link #defaultExecutor()} with the values obtained by calling the given Suppliers * in the same order of the given Suppliers arguments. - *

- * This method is the same as {@link #tupleMSupplyAsync(Supplier, Supplier)} except for the most-success behavior. * * @return the new Cffu */ @@ -498,9 +478,8 @@ public Cffu> tupleMSupplyMostSuccessAsync( * Returns a new Cffu 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. - *

- * This method is the same as {@link #tupleMSupplyAsync(Supplier, Supplier)} except for the most-success behavior. * + * @param executor the executor to use for asynchronous execution * @return the new Cffu */ public Cffu> tupleMSupplyMostSuccessAsync( @@ -514,8 +493,6 @@ public Cffu> tupleMSupplyMostSuccessAsync( * Returns a new Cffu that is asynchronously completed * by tasks running in the {@link #defaultExecutor()} with the values obtained by calling the given Suppliers * in the same order of the given Suppliers arguments. - *

- * This method is the same as {@link #tupleMSupplyAsync(Supplier, Supplier)} except for the most-success behavior. * * @return the new Cffu */ @@ -529,9 +506,8 @@ public Cffu> tupleMSupplyMostSuccessAsyn * Returns a new Cffu 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. - *

- * This method is the same as {@link #tupleMSupplyAsync(Supplier, Supplier)} except for the most-success behavior. * + * @param executor the executor to use for asynchronous execution * @return the new Cffu */ public Cffu> tupleMSupplyMostSuccessAsync( @@ -545,8 +521,6 @@ public Cffu> tupleMSupplyMostSuccessAsyn * Returns a new Cffu that is asynchronously completed * by tasks running in the {@link #defaultExecutor()} with the values obtained by calling the given Suppliers * in the same order of the given Suppliers arguments. - *

- * This method is the same as {@link #tupleMSupplyAsync(Supplier, Supplier)} except for the most-success behavior. * * @return the new Cffu */ @@ -560,9 +534,8 @@ public Cffu> tupleMSupplyMostSuc * Returns a new Cffu 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. - *

- * This method is the same as {@link #tupleMSupplyAsync(Supplier, Supplier)} except for the most-success behavior. * + * @param executor the executor to use for asynchronous execution * @return the new Cffu */ public Cffu> tupleMSupplyMostSuccessAsync( @@ -591,6 +564,7 @@ public Cffu> tupleMSupplyAsync( * 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. * + * @param executor the executor to use for asynchronous execution * @return the new Cffu * @see #allResultsOf(CompletionStage[]) */ @@ -617,6 +591,7 @@ public Cffu> tupleMSupplyAsync( * 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. * + * @param executor the executor to use for asynchronous execution * @return the new Cffu * @see #allResultsOf(CompletionStage[]) */ @@ -645,6 +620,7 @@ public Cffu> tupleMSupplyAsync( * 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. * + * @param executor the executor to use for asynchronous execution * @return the new Cffu * @see #allResultsOf(CompletionStage[]) */ @@ -673,6 +649,7 @@ public Cffu> tupleMSupplyAsync( * 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. * + * @param executor the executor to use for asynchronous execution * @return the new Cffu * @see #allResultsOf(CompletionStage[]) */ @@ -684,7 +661,7 @@ public Cffu> tupleMSupplyAsync( // endregion //////////////////////////////////////////////////////////////////////////////// - // region## allOf* Methods(including mostResultsOfSuccess) + // region## allOf* Methods(including mostSuccessResultsOf) //////////////////////////////////////////////////////////////////////////////// /** @@ -695,9 +672,6 @@ public Cffu> tupleMSupplyAsync( * If no stages are provided, returns a Cffu completed with the value empty list. *

* This method is the same as {@link #allResultsOf(CompletionStage[])} except for the fast-fail behavior. - *

- * This method is the same as {@link #allOfFastFail(CompletionStage[])}, - * except that the returned Cffu contains the results of the given stages. * * @param cfs the stages * @return a new Cffu that is successful when all the given stages success @@ -705,8 +679,8 @@ public Cffu> tupleMSupplyAsync( */ @Contract(pure = true) @SafeVarargs - public final Cffu> allResultsOfFastFail(CompletionStage... cfs) { - return create(CompletableFutureUtils.allResultsOfFastFail(cfs)); + public final Cffu> allResultsFastFailOf(CompletionStage... cfs) { + return create(CompletableFutureUtils.allResultsFastFailOf(cfs)); } /** @@ -723,9 +697,9 @@ public final Cffu> allResultsOfFastFail(CompletionStage */ @Contract(pure = true) @SafeVarargs - public final Cffu> mostResultsOfSuccess( + public final Cffu> mostSuccessResultsOf( @Nullable T valueIfNotSuccess, long timeout, TimeUnit unit, CompletionStage... cfs) { - return create(CompletableFutureUtils.mostResultsOfSuccess( + return create(CompletableFutureUtils.mostSuccessResultsOf( valueIfNotSuccess, defaultExecutor, timeout, unit, cfs)); } @@ -761,17 +735,17 @@ public final Cffu> allResultsOf(CompletionStage... cfs) *

* If you need the results of given stages, prefer below methods: *

    - *
  • {@link #allResultsOfFastFail(CompletionStage[])} - *
  • {@link #allTupleOfFastFail(CompletionStage, CompletionStage)} / - * {@link #allTupleOfFastFail(CompletionStage, CompletionStage, CompletionStage, CompletionStage, CompletionStage)} + *
  • {@link #allResultsFastFailOf(CompletionStage[])} + *
  • {@link #allTupleFastFailOf(CompletionStage, CompletionStage)} / + * {@link #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: *

    - *
  • {@link #mostResultsOfSuccess(Object, long, TimeUnit, CompletionStage[])} - *
  • {@link #mostTupleOfSuccess(long, TimeUnit, CompletionStage, CompletionStage)} / - * {@link #mostTupleOfSuccess(long, TimeUnit, CompletionStage, CompletionStage, CompletionStage, CompletionStage, CompletionStage)} + *
  • {@link #mostSuccessResultsOf(Object, long, TimeUnit, CompletionStage[])} + *
  • {@link #mostSuccessTupleOf(long, TimeUnit, CompletionStage, CompletionStage)} / + * {@link #mostSuccessTupleOf(long, TimeUnit, CompletionStage, CompletionStage, CompletionStage, CompletionStage, CompletionStage)} *
* * @param cfs the stages @@ -779,8 +753,8 @@ public final Cffu> allResultsOf(CompletionStage... cfs) * @throws NullPointerException if the array or any of its elements are {@code null} */ @Contract(pure = true) - public Cffu allOfFastFail(CompletionStage... cfs) { - return create(CompletableFutureUtils.allOfFastFail(cfs)); + public Cffu allFastFailOf(CompletionStage... cfs) { + return create(CompletableFutureUtils.allFastFailOf(cfs)); } /** @@ -803,9 +777,9 @@ public Cffu allOfFastFail(CompletionStage... cfs) { *

* If you need the successful results of given stages in the given time, prefer below methods: *

    - *
  • {@link #mostResultsOfSuccess(Object, long, TimeUnit, CompletionStage[])} - *
  • {@link #mostTupleOfSuccess(long, TimeUnit, CompletionStage, CompletionStage)} / - * {@link #mostTupleOfSuccess(long, TimeUnit, CompletionStage, CompletionStage, CompletionStage, CompletionStage, CompletionStage)} + *
  • {@link #mostSuccessResultsOf(Object, long, TimeUnit, CompletionStage[])} + *
  • {@link #mostSuccessTupleOf(long, TimeUnit, CompletionStage, CompletionStage)} / + * {@link #mostSuccessTupleOf(long, TimeUnit, CompletionStage, CompletionStage, CompletionStage, CompletionStage, CompletionStage)} *
* * @param cfs the stages @@ -838,8 +812,8 @@ public Cffu allOf(CompletionStage... cfs) { * @throws NullPointerException if the array or any of its elements are {@code null} */ @SafeVarargs - public final Cffu anyOfSuccess(CompletionStage... cfs) { - return create(CompletableFutureUtils.anyOfSuccess(cfs)); + public final Cffu anySuccessOf(CompletionStage... cfs) { + return create(CompletableFutureUtils.anySuccessOf(cfs)); } /** @@ -865,81 +839,69 @@ public final Cffu anyOf(CompletionStage... cfs) { // endregion //////////////////////////////////////////////////////////////////////////////// - // region## allTupleOf*/mostTupleOfSuccess Methods + // region## allTupleOf*/mostSuccessTupleOf Methods //////////////////////////////////////////////////////////////////////////////// /** * Returns a new Cffu that is successful when the given two stages success. * If any of the given stages complete exceptionally, then the returned Cffu also does so * *without* waiting other incomplete given stages, with a CompletionException holding this exception as its cause. - *

- * This method is the same as {@link #allTupleOf(CompletionStage, CompletionStage)} - * except for the fast-fail behavior. * * @return a new Cffu that is successful when the given two stages success * @throws NullPointerException if any of the given stages are {@code null} - * @see #allResultsOfFastFail(CompletionStage[]) + * @see #allResultsFastFailOf(CompletionStage[]) */ @Contract(pure = true) - public Cffu> allTupleOfFastFail( + public Cffu> allTupleFastFailOf( CompletionStage cf1, CompletionStage cf2) { - return create(CompletableFutureUtils.allTupleOfFastFail(cf1, cf2)); + return create(CompletableFutureUtils.allTupleFastFailOf(cf1, cf2)); } /** * Returns a new Cffu that is successful when the given three stages success. * If any of the given stages complete exceptionally, then the returned Cffu also does so * *without* waiting other incomplete given stages, with a CompletionException holding this exception as its cause. - *

- * This method is the same as {@link #allTupleOf(CompletionStage, CompletionStage, CompletionStage)} - * except for the fast-fail behavior. * * @return a new Cffu that is successful when the given three stages success * @throws NullPointerException if any of the given stages are {@code null} - * @see #allResultsOfFastFail(CompletionStage[]) + * @see #allResultsFastFailOf(CompletionStage[]) */ @Contract(pure = true) - public Cffu> allTupleOfFastFail( + public Cffu> allTupleFastFailOf( CompletionStage cf1, CompletionStage cf2, CompletionStage cf3) { - return create(CompletableFutureUtils.allTupleOfFastFail(cf1, cf2, cf3)); + return create(CompletableFutureUtils.allTupleFastFailOf(cf1, cf2, cf3)); } /** * Returns a new Cffu that is successful when the given four stages success. * If any of the given stages complete exceptionally, then the returned Cffu also does so * *without* waiting other incomplete given stages, with a CompletionException holding this exception as its cause. - *

- * This method is the same as {@link #allTupleOf(CompletionStage, CompletionStage, CompletionStage, CompletionStage)} - * except for the fast-fail behavior. * * @return a new Cffu that is successful when the given four stages success * @throws NullPointerException if any of the given stages are {@code null} - * @see #allResultsOfFastFail(CompletionStage[]) + * @see #allResultsFastFailOf(CompletionStage[]) */ @Contract(pure = true) - public Cffu> allTupleOfFastFail( + public Cffu> allTupleFastFailOf( CompletionStage cf1, CompletionStage cf2, CompletionStage cf3, CompletionStage cf4) { - return create(CompletableFutureUtils.allTupleOfFastFail(cf1, cf2, cf3, cf4)); + return create(CompletableFutureUtils.allTupleFastFailOf(cf1, cf2, cf3, cf4)); } /** * Returns a new Cffu that is successful when the given five stages success. * If any of the given stages complete exceptionally, then the returned Cffu also does so * *without* waiting other incomplete given stages, with a CompletionException holding this exception as its cause. - *

- * This method is the same as {@link #allTupleOf(CompletionStage, CompletionStage, CompletionStage, CompletionStage, CompletionStage)} - * except for the fast-fail behavior. * * @return a new Cffu that is successful when the given five stages success * @throws NullPointerException if any of the given stages are {@code null} - * @see #allResultsOfFastFail(CompletionStage[]) + * @see #allResultsFastFailOf(CompletionStage[]) */ @Contract(pure = true) - public Cffu> allTupleOfFastFail( + public Cffu> allTupleFastFailOf( CompletionStage cf1, CompletionStage cf2, CompletionStage cf3, CompletionStage cf4, CompletionStage cf5) { - return create(CompletableFutureUtils.allTupleOfFastFail(cf1, cf2, cf3, cf4, cf5)); + return create(CompletableFutureUtils.allTupleFastFailOf(cf1, cf2, cf3, cf4, cf5)); } /** @@ -951,13 +913,13 @@ public Cffu> allTupleOfFastFail( * @param timeout how long to wait in units of {@code unit} * @param unit a {@code TimeUnit} determining how to interpret the {@code timeout} parameter * @return a new Cffu that is completed when the given two stages complete - * @see #mostResultsOfSuccess(Object, long, TimeUnit, CompletionStage[]) + * @see #mostSuccessResultsOf(Object, long, TimeUnit, CompletionStage[]) * @see Cffu#getSuccessNow(Object) */ @Contract(pure = true) - public Cffu> mostTupleOfSuccess( + public Cffu> mostSuccessTupleOf( long timeout, TimeUnit unit, CompletionStage cf1, CompletionStage cf2) { - return create(CompletableFutureUtils.mostTupleOfSuccess(defaultExecutor, timeout, unit, cf1, cf2)); + return create(CompletableFutureUtils.mostSuccessTupleOf(defaultExecutor, timeout, unit, cf1, cf2)); } /** @@ -969,14 +931,14 @@ public Cffu> mostTupleOfSuccess( * @param timeout how long to wait in units of {@code unit} * @param unit a {@code TimeUnit} determining how to interpret the {@code timeout} parameter * @return a new Cffu that is completed when the given three stages complete - * @see #mostResultsOfSuccess(Object, long, TimeUnit, CompletionStage[]) + * @see #mostSuccessResultsOf(Object, long, TimeUnit, CompletionStage[]) * @see Cffu#getSuccessNow(Object) */ @Contract(pure = true) - public Cffu> mostTupleOfSuccess( + public Cffu> mostSuccessTupleOf( long timeout, TimeUnit unit, CompletionStage cf1, CompletionStage cf2, CompletionStage cf3) { - return create(CompletableFutureUtils.mostTupleOfSuccess(defaultExecutor, timeout, unit, cf1, cf2, cf3)); + return create(CompletableFutureUtils.mostSuccessTupleOf(defaultExecutor, timeout, unit, cf1, cf2, cf3)); } /** @@ -988,15 +950,15 @@ public Cffu> mostTupleOfSuccess( * @param timeout how long to wait in units of {@code unit} * @param unit a {@code TimeUnit} determining how to interpret the {@code timeout} parameter * @return a new Cffu that is completed when the given four stages complete - * @see #mostResultsOfSuccess(Object, long, TimeUnit, CompletionStage[]) + * @see #mostSuccessResultsOf(Object, long, TimeUnit, CompletionStage[]) * @see Cffu#getSuccessNow(Object) */ @Contract(pure = true) - public Cffu> mostTupleOfSuccess( + public Cffu> mostSuccessTupleOf( long timeout, TimeUnit unit, CompletionStage cf1, CompletionStage cf2, CompletionStage cf3, CompletionStage cf4) { - return create(CompletableFutureUtils.mostTupleOfSuccess(defaultExecutor, timeout, unit, cf1, cf2, cf3, cf4)); + return create(CompletableFutureUtils.mostSuccessTupleOf(defaultExecutor, timeout, unit, cf1, cf2, cf3, cf4)); } /** @@ -1008,15 +970,15 @@ public Cffu> mostTupleOfSuccess( * @param timeout how long to wait in units of {@code unit} * @param unit a {@code TimeUnit} determining how to interpret the {@code timeout} parameter * @return a new Cffu that is completed when the given five stages complete - * @see #mostResultsOfSuccess(Object, long, TimeUnit, CompletionStage[]) + * @see #mostSuccessResultsOf(Object, long, TimeUnit, CompletionStage[]) * @see Cffu#getSuccessNow(Object) */ @Contract(pure = true) - public Cffu> mostTupleOfSuccess( + public Cffu> mostSuccessTupleOf( long timeout, TimeUnit unit, CompletionStage cf1, CompletionStage cf2, CompletionStage cf3, CompletionStage cf4, CompletionStage cf5) { - return create(CompletableFutureUtils.mostTupleOfSuccess(defaultExecutor, timeout, unit, cf1, cf2, cf3, cf4, cf5)); + return create(CompletableFutureUtils.mostSuccessTupleOf(defaultExecutor, timeout, unit, cf1, cf2, cf3, cf4, cf5)); } /** diff --git a/cffu-core/src/main/java/io/foldright/cffu/CompletableFutureUtils.java b/cffu-core/src/main/java/io/foldright/cffu/CompletableFutureUtils.java index 72874cb8..b854cc95 100644 --- a/cffu-core/src/main/java/io/foldright/cffu/CompletableFutureUtils.java +++ b/cffu-core/src/main/java/io/foldright/cffu/CompletableFutureUtils.java @@ -41,13 +41,11 @@ public final class CompletableFutureUtils { * 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. - *

- * This method is the same as {@link #mSupplyAsync(Supplier[])} except for the fast-fail behavior. * * @param suppliers the suppliers returning the value to be used to complete the returned CompletableFuture * @param the suppliers' return type * @return the new CompletableFuture - * @see #allResultsOfFastFail(CompletionStage[]) + * @see #allResultsFastFailOf(CompletionStage[]) * @see CompletableFuture#supplyAsync(Supplier) */ @SafeVarargs @@ -59,14 +57,12 @@ public static CompletableFuture> mSupplyFastFailAsync(Suppliersame order of the given Suppliers arguments. - *

- * This method is the same as {@link #mSupplyAsync(Executor, Supplier[])} except for the fast-fail behavior. * * @param executor the executor to use for asynchronous execution * @param suppliers the suppliers returning the value to be used to complete the returned CompletableFuture * @param the suppliers' return type * @return the new CompletableFuture - * @see #allResultsOfFastFail(CompletionStage[]) + * @see #allResultsFastFailOf(CompletionStage[]) * @see CompletableFuture#supplyAsync(Supplier, Executor) */ @SafeVarargs @@ -75,7 +71,7 @@ public static CompletableFuture> mSupplyFastFailAsync( requireNonNull(executor, "executor is null"); requireArrayAndEleNonNull("supplier", suppliers); - return allResultsOfFastFail(wrapSuppliers(executor, suppliers)); + return allResultsFastFailOf(wrapSuppliers(executor, suppliers)); } /** @@ -94,7 +90,7 @@ public static CompletableFuture> mSupplyFastFailAsync( * @param suppliers the suppliers returning the value to be used to complete the returned CompletableFuture * @param the suppliers' return type * @return the new CompletableFuture - * @see #mostResultsOfSuccess(Object, long, TimeUnit, CompletionStage[]) + * @see #mostSuccessResultsOf(Object, long, TimeUnit, CompletionStage[]) * @see CompletableFuture#supplyAsync(Supplier) */ @SafeVarargs @@ -119,7 +115,7 @@ public static CompletableFuture> mSupplyMostSuccessAsync( * @param suppliers the suppliers returning the value to be used to complete the returned CompletableFuture * @param the suppliers' return type * @return the new CompletableFuture - * @see #mostResultsOfSuccess(Object, Executor, long, TimeUnit, CompletionStage[]) + * @see #mostSuccessResultsOf(Object, Executor, long, TimeUnit, CompletionStage[]) * @see CompletableFuture#supplyAsync(Supplier, Executor) */ @SafeVarargs @@ -130,7 +126,7 @@ public static CompletableFuture> mSupplyMostSuccessAsync( requireNonNull(unit, "unit is null"); requireArrayAndEleNonNull("supplier", suppliers); - return mostResultsOfSuccess(valueIfNotSuccess, executor, timeout, unit, wrapSuppliers(executor, suppliers)); + return mostSuccessResultsOf(valueIfNotSuccess, executor, timeout, unit, wrapSuppliers(executor, suppliers)); } /** @@ -193,12 +189,10 @@ private static CompletableFuture[] wrapSuppliers( * Returns a new CompletableFuture that is asynchronously completed * by tasks running in the CompletableFuture's default asynchronous execution facility * after runs the given actions. - *

- * This method is the same as {@link #mRunAsync(Runnable...)} except for the fast-fail behavior. * * @param actions the actions to run before completing the returned CompletableFuture * @return the new CompletableFuture - * @see #allOfFastFail(CompletionStage[]) + * @see #allFastFailOf(CompletionStage[]) * @see CompletableFuture#runAsync(Runnable) */ public static CompletableFuture mRunFastFailAsync(Runnable... actions) { @@ -208,20 +202,18 @@ public static CompletableFuture mRunFastFailAsync(Runnable... actions) { /** * Returns a new CompletableFuture that is asynchronously completed * by tasks running in the given Executor after runs the given actions. - *

- * This method is the same as {@link #mRunAsync(Executor, Runnable...)} except for the fast-fail behavior. * * @param executor the executor to use for asynchronous execution * @param actions the actions to run before completing the returned CompletableFuture * @return the new CompletableFuture - * @see #allOfFastFail(CompletionStage[]) + * @see #allFastFailOf(CompletionStage[]) * @see CompletableFuture#runAsync(Runnable, Executor) */ public static CompletableFuture mRunFastFailAsync(Executor executor, Runnable... actions) { requireNonNull(executor, "executor is null"); requireArrayAndEleNonNull("action", actions); - return allOfFastFail(wrapRunnables(executor, actions)); + return allFastFailOf(wrapRunnables(executor, actions)); } /** @@ -274,11 +266,9 @@ private static CompletableFuture[] wrapRunnables(Executor executor, Runnab * 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. - *

- * This method is the same as {@link #tupleMSupplyAsync(Supplier, Supplier)} except for the fast-fail behavior. * * @return the new CompletableFuture - * @see #allResultsOfFastFail(CompletionStage[]) + * @see #allResultsFastFailOf(CompletionStage[]) * @see CompletableFuture#supplyAsync(Supplier) */ public static CompletableFuture> tupleMSupplyFastFailAsync( @@ -290,12 +280,10 @@ public static CompletableFuture> tupleMSupplyFastFailAsy * 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. - *

- * This method is the same as {@link #tupleMSupplyAsync(Executor, Supplier, Supplier)} except for the fast-fail behavior. * * @param executor the executor to use for asynchronous execution * @return the new CompletableFuture - * @see #allResultsOfFastFail(CompletionStage[]) + * @see #allResultsFastFailOf(CompletionStage[]) * @see CompletableFuture#supplyAsync(Supplier, Executor) */ public static CompletableFuture> tupleMSupplyFastFailAsync( @@ -311,12 +299,9 @@ public static CompletableFuture> tupleMSupplyFastFailAsy * 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. - *

- * This method is the same as {@link #tupleMSupplyAsync(Supplier, Supplier, Supplier)} - * except for the fast-fail behavior. * * @return the new CompletableFuture - * @see #allResultsOfFastFail(CompletionStage[]) + * @see #allResultsFastFailOf(CompletionStage[]) * @see CompletableFuture#supplyAsync(Supplier) */ public static CompletableFuture> tupleMSupplyFastFailAsync( @@ -328,13 +313,10 @@ public static CompletableFuture> tupleMSupplyFas * 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. - *

- * This method is the same as {@link #tupleMSupplyAsync(Executor, Supplier, Supplier, Supplier)} - * except for the fast-fail behavior. * * @param executor the executor to use for asynchronous execution * @return the new CompletableFuture - * @see #allResultsOfFastFail(CompletionStage[]) + * @see #allResultsFastFailOf(CompletionStage[]) * @see CompletableFuture#supplyAsync(Supplier, Executor) */ public static CompletableFuture> tupleMSupplyFastFailAsync( @@ -351,12 +333,9 @@ public static CompletableFuture> tupleMSupplyFas * 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. - *

- * This method is the same as {@link #tupleMSupplyAsync(Supplier, Supplier, Supplier, Supplier)} - * except for the fast-fail behavior. * * @return the new CompletableFuture - * @see #allResultsOfFastFail(CompletionStage[]) + * @see #allResultsFastFailOf(CompletionStage[]) * @see CompletableFuture#supplyAsync(Supplier) */ public static CompletableFuture> tupleMSupplyFastFailAsync( @@ -369,13 +348,10 @@ public static CompletableFuture> tupleMS * 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. - *

- * This method is the same as {@link #tupleMSupplyAsync(Executor, Supplier, Supplier, Supplier, Supplier)} - * except for the fast-fail behavior. * * @param executor the executor to use for asynchronous execution * @return the new CompletableFuture - * @see #allResultsOfFastFail(CompletionStage[]) + * @see #allResultsFastFailOf(CompletionStage[]) * @see CompletableFuture#supplyAsync(Supplier, Executor) */ public static CompletableFuture> tupleMSupplyFastFailAsync( @@ -392,12 +368,9 @@ public static CompletableFuture> tupleMS * 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. - *

- * This method is the same as {@link #tupleMSupplyAsync(Supplier, Supplier, Supplier, Supplier, Supplier)} - * except for the fast-fail behavior. * * @return the new CompletableFuture - * @see #allResultsOfFastFail(CompletionStage[]) + * @see #allResultsFastFailOf(CompletionStage[]) * @see CompletableFuture#supplyAsync(Supplier) */ public static CompletableFuture> tupleMSupplyFastFailAsync( @@ -410,13 +383,10 @@ public static CompletableFuture> * 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. - *

- * This method is the same as {@link #tupleMSupplyAsync(Supplier, Supplier, Supplier, Supplier, Supplier)} - * except for the fast-fail behavior. * * @param executor the executor to use for asynchronous execution * @return the new CompletableFuture - * @see #allResultsOfFastFail(CompletionStage[]) + * @see #allResultsFastFailOf(CompletionStage[]) * @see CompletableFuture#supplyAsync(Supplier, Executor) */ public static CompletableFuture> tupleMSupplyFastFailAsync( @@ -433,7 +403,7 @@ private static CompletableFuture allTupleOf0(boolean fastFail, Completion final CompletableFuture[] resultSetterCfs = createResultSetterCfs(css, result); final CompletableFuture resultSetter; - if (fastFail) resultSetter = allOfFastFail(resultSetterCfs); + if (fastFail) resultSetter = allFastFailOf(resultSetterCfs); else resultSetter = CompletableFuture.allOf(resultSetterCfs); return resultSetter.thenApply(unused -> tupleOf0(result)); @@ -479,8 +449,9 @@ public static CompletableFuture> tupleMSupplyMostSuccess * If the given supplier is successful in the given time, the return result is the completed value; * Otherwise the given valueIfNotSuccess. * - * @param timeout how long to wait in units of {@code unit} - * @param unit a {@code TimeUnit} determining how to interpret the {@code timeout} parameter + * @param executor the executor to use for asynchronous execution + * @param timeout how long to wait in units of {@code unit} + * @param unit a {@code TimeUnit} determining how to interpret the {@code timeout} parameter * @return the new CompletableFuture */ public static CompletableFuture> tupleMSupplyMostSuccessAsync( @@ -490,7 +461,7 @@ public static CompletableFuture> tupleMSupplyMostSuccess requireNonNull(unit, "unit is null"); Supplier[] suppliers = requireArrayAndEleNonNull("supplier", supplier1, supplier2); - return mostTupleOfSuccess0(executor, timeout, unit, wrapSuppliers(executor, suppliers)); + return mostSuccessTupleOf0(executor, timeout, unit, wrapSuppliers(executor, suppliers)); } /** @@ -522,8 +493,9 @@ public static CompletableFuture> tupleMSupplyMos * If the given supplier is successful in the given time, the return result is the completed value; * Otherwise the given valueIfNotSuccess. * - * @param timeout how long to wait in units of {@code unit} - * @param unit a {@code TimeUnit} determining how to interpret the {@code timeout} parameter + * @param executor the executor to use for asynchronous execution + * @param timeout how long to wait in units of {@code unit} + * @param unit a {@code TimeUnit} determining how to interpret the {@code timeout} parameter * @return the new CompletableFuture */ public static CompletableFuture> tupleMSupplyMostSuccessAsync( @@ -533,7 +505,7 @@ public static CompletableFuture> tupleMSupplyMos requireNonNull(unit, "unit is null"); Supplier[] suppliers = requireArrayAndEleNonNull("supplier", supplier1, supplier2, supplier3); - return mostTupleOfSuccess0(executor, timeout, unit, wrapSuppliers(executor, suppliers)); + return mostSuccessTupleOf0(executor, timeout, unit, wrapSuppliers(executor, suppliers)); } /** @@ -565,8 +537,9 @@ public static CompletableFuture> tupleMS * If the given supplier is successful in the given time, the return result is the completed value; * Otherwise the given valueIfNotSuccess. * - * @param timeout how long to wait in units of {@code unit} - * @param unit a {@code TimeUnit} determining how to interpret the {@code timeout} parameter + * @param executor the executor to use for asynchronous execution + * @param timeout how long to wait in units of {@code unit} + * @param unit a {@code TimeUnit} determining how to interpret the {@code timeout} parameter * @return the new CompletableFuture */ public static CompletableFuture> tupleMSupplyMostSuccessAsync( @@ -576,7 +549,7 @@ public static CompletableFuture> tupleMS requireNonNull(unit, "unit is null"); Supplier[] suppliers = requireArrayAndEleNonNull("supplier", supplier1, supplier2, supplier3, supplier4); - return mostTupleOfSuccess0(executor, timeout, unit, wrapSuppliers(executor, suppliers)); + return mostSuccessTupleOf0(executor, timeout, unit, wrapSuppliers(executor, suppliers)); } /** @@ -609,8 +582,9 @@ public static CompletableFuture> * If the given supplier is successful in the given time, the return result is the completed value; * Otherwise the given valueIfNotSuccess. * - * @param timeout how long to wait in units of {@code unit} - * @param unit a {@code TimeUnit} determining how to interpret the {@code timeout} parameter + * @param executor the executor to use for asynchronous execution + * @param timeout how long to wait in units of {@code unit} + * @param unit a {@code TimeUnit} determining how to interpret the {@code timeout} parameter * @return the new CompletableFuture */ public static CompletableFuture> tupleMSupplyMostSuccessAsync( @@ -621,10 +595,10 @@ public static CompletableFuture> requireNonNull(unit, "unit is null"); Supplier[] suppliers = requireArrayAndEleNonNull("supplier", supplier1, supplier2, supplier3, supplier4, supplier5); - return mostTupleOfSuccess0(executor, timeout, unit, wrapSuppliers(executor, suppliers)); + return mostSuccessTupleOf0(executor, timeout, unit, wrapSuppliers(executor, suppliers)); } - private static CompletableFuture mostTupleOfSuccess0( + private static CompletableFuture mostSuccessTupleOf0( Executor executorWhenTimeout, long timeout, TimeUnit unit, CompletionStage... css) { requireNonNull(executorWhenTimeout, "executorWhenTimeout is null"); requireNonNull(unit, "unit is null"); @@ -671,6 +645,7 @@ public static CompletableFuture> tupleMSupplyAsync( * 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. * + * @param executor the executor to use for asynchronous execution * @return the new CompletableFuture * @see #allResultsOf(CompletionStage[]) * @see CompletableFuture#supplyAsync(Supplier) @@ -703,6 +678,7 @@ public static CompletableFuture> tupleMSupplyAsy * 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. * + * @param executor the executor to use for asynchronous execution * @return the new CompletableFuture * @see #allResultsOf(CompletionStage[]) * @see CompletableFuture#supplyAsync(Supplier) @@ -737,6 +713,7 @@ public static CompletableFuture> tupleMS * 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. * + * @param executor the executor to use for asynchronous execution * @return the new CompletableFuture * @see #allResultsOf(CompletionStage[]) * @see CompletableFuture#supplyAsync(Supplier) @@ -771,6 +748,7 @@ public static CompletableFuture> * 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. * + * @param executor the executor to use for asynchronous execution * @return the new CompletableFuture * @see #allResultsOf(CompletionStage[]) * @see CompletableFuture#supplyAsync(Supplier) @@ -786,7 +764,7 @@ public static CompletableFuture> // endregion //////////////////////////////////////////////////////////// - // region## allOf* Methods(including mostResultsOfSuccess) + // region## allOf* Methods(including mostSuccessResultsOf) //////////////////////////////////////////////////////////// /** @@ -804,7 +782,7 @@ public static CompletableFuture> */ @Contract(pure = true) @SafeVarargs - public static CompletableFuture> allResultsOfFastFail(CompletionStage... cfs) { + public static CompletableFuture> allResultsFastFailOf(CompletionStage... cfs) { requireCfsAndEleNonNull(cfs); final int len = cfs.length; if (len == 0) return completedFuture(arrayList()); @@ -839,9 +817,9 @@ public static CompletableFuture> allResultsOfFastFail(CompletionStag */ @Contract(pure = true) @SafeVarargs - public static CompletableFuture> mostResultsOfSuccess( + public static CompletableFuture> mostSuccessResultsOf( @Nullable T valueIfNotSuccess, long timeout, TimeUnit unit, CompletionStage... cfs) { - return mostResultsOfSuccess(valueIfNotSuccess, AsyncPoolHolder.ASYNC_POOL, timeout, unit, cfs); + return mostSuccessResultsOf(valueIfNotSuccess, AsyncPoolHolder.ASYNC_POOL, timeout, unit, cfs); } /** @@ -859,7 +837,7 @@ public static CompletableFuture> mostResultsOfSuccess( */ @Contract(pure = true) @SafeVarargs - public static CompletableFuture> mostResultsOfSuccess( + public static CompletableFuture> mostSuccessResultsOf( @Nullable T valueIfNotSuccess, Executor executorWhenTimeout, long timeout, TimeUnit unit, CompletionStage... cfs) { requireNonNull(executorWhenTimeout, "executorWhenTimeout is null"); @@ -928,17 +906,17 @@ public static CompletableFuture> allResultsOf(CompletionStage * If you need the results of given stages, prefer below methods: *

    - *
  • {@link #allResultsOfFastFail(CompletionStage[])} - *
  • {@link #allTupleOfFastFail(CompletionStage, CompletionStage)} / - * {@link #allTupleOfFastFail(CompletionStage, CompletionStage, CompletionStage, CompletionStage, CompletionStage)} + *
  • {@link #allResultsFastFailOf(CompletionStage[])} + *
  • {@link #allTupleFastFailOf(CompletionStage, CompletionStage)} / + * {@link #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: *

    - *
  • {@link #mostResultsOfSuccess(Object, long, TimeUnit, CompletionStage[])} - *
  • {@link #mostTupleOfSuccess(long, TimeUnit, CompletionStage, CompletionStage)} / - * {@link #mostTupleOfSuccess(long, TimeUnit, CompletionStage, CompletionStage, CompletionStage, CompletionStage, CompletionStage)} + *
  • {@link #mostSuccessResultsOf(Object, long, TimeUnit, CompletionStage[])} + *
  • {@link #mostSuccessTupleOf(long, TimeUnit, CompletionStage, CompletionStage)} / + * {@link #mostSuccessTupleOf(long, TimeUnit, CompletionStage, CompletionStage, CompletionStage, CompletionStage, CompletionStage)} *
* * @param cfs the stages @@ -946,7 +924,7 @@ public static CompletableFuture> allResultsOf(CompletionStage allOfFastFail(CompletionStage... cfs) { + public static CompletableFuture allFastFailOf(CompletionStage... cfs) { requireCfsAndEleNonNull(cfs); final int len = cfs.length; if (len == 0) return completedFuture(null); @@ -987,9 +965,9 @@ public static CompletableFuture allOfFastFail(CompletionStage... cfs) { *

* If you need the successful results of given stages in the given time, prefer below methods: *

    - *
  • {@link #mostResultsOfSuccess(Object, long, TimeUnit, CompletionStage[])} - *
  • {@link #mostTupleOfSuccess(long, TimeUnit, CompletionStage, CompletionStage)} / - * {@link #mostTupleOfSuccess(long, TimeUnit, CompletionStage, CompletionStage, CompletionStage, CompletionStage, CompletionStage)} + *
  • {@link #mostSuccessResultsOf(Object, long, TimeUnit, CompletionStage[])} + *
  • {@link #mostSuccessTupleOf(long, TimeUnit, CompletionStage, CompletionStage)} / + * {@link #mostSuccessTupleOf(long, TimeUnit, CompletionStage, CompletionStage, CompletionStage, CompletionStage, CompletionStage)} *
* * @param cfs the stages @@ -1147,7 +1125,7 @@ private static boolean isMinStageCf(CompletableFuture cf) { */ @Contract(pure = true) @SafeVarargs - public static CompletableFuture anyOfSuccess(CompletionStage... cfs) { + public static CompletableFuture anySuccessOf(CompletionStage... cfs) { requireCfsAndEleNonNull(cfs); final int len = cfs.length; if (len == 0) return failedFuture(new NoCfsProvidedException()); @@ -1183,7 +1161,7 @@ public static CompletableFuture anyOfSuccess(CompletionStage * @return 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 are {@code null} - * @see #anyOfSuccess(CompletionStage[]) + * @see #anySuccessOf(CompletionStage[]) */ @Contract(pure = true) @SafeVarargs @@ -1200,23 +1178,20 @@ public static CompletableFuture anyOf(CompletionStage... cfs // endregion //////////////////////////////////////////////////////////// - // region## allTupleOf*/mostTupleOfSuccess Methods + // region## allTupleOf*/mostSuccessTupleOf Methods //////////////////////////////////////////////////////////// /** * Returns a new CompletableFuture that is successful when the given two 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. - *

- * This method is the same as {@link #allTupleOf(CompletionStage, CompletionStage)} - * except for the fast-fail behavior. * * @return a new CompletableFuture that is successful when the given two stages success * @throws NullPointerException if any of the given stages are {@code null} - * @see #allResultsOfFastFail(CompletionStage[]) + * @see #allResultsFastFailOf(CompletionStage[]) */ @Contract(pure = true) - public static CompletableFuture> allTupleOfFastFail( + public static CompletableFuture> allTupleFastFailOf( CompletionStage cf1, CompletionStage cf2) { return allTupleOf0(true, requireCfsAndEleNonNull(cf1, cf2)); } @@ -1225,16 +1200,13 @@ public static CompletableFuture> allTupleOfFastFail( * Returns a new CompletableFuture that is successful when the given three 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. - *

- * This method is the same as {@link #allTupleOf(CompletionStage, CompletionStage, CompletionStage)} - * except for the fast-fail behavior. * * @return a new CompletableFuture that is successful when the given three stages success * @throws NullPointerException if any of the given stages are {@code null} - * @see #allResultsOfFastFail(CompletionStage[]) + * @see #allResultsFastFailOf(CompletionStage[]) */ @Contract(pure = true) - public static CompletableFuture> allTupleOfFastFail( + public static CompletableFuture> allTupleFastFailOf( CompletionStage cf1, CompletionStage cf2, CompletionStage cf3) { return allTupleOf0(true, requireCfsAndEleNonNull(cf1, cf2, cf3)); } @@ -1243,16 +1215,13 @@ public static CompletableFuture> allTupleOfFastF * Returns a new CompletableFuture that is successful when the given four 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. - *

- * This method is the same as {@link #allTupleOf(CompletionStage, CompletionStage, CompletionStage, CompletionStage)} - * except for the fast-fail behavior. * * @return a new CompletableFuture that is successful when the given four stages success * @throws NullPointerException if any of the given stages are {@code null} - * @see #allResultsOfFastFail(CompletionStage[]) + * @see #allResultsFastFailOf(CompletionStage[]) */ @Contract(pure = true) - public static CompletableFuture> allTupleOfFastFail( + public static CompletableFuture> allTupleFastFailOf( CompletionStage cf1, CompletionStage cf2, CompletionStage cf3, CompletionStage cf4) { return allTupleOf0(true, requireCfsAndEleNonNull(cf1, cf2, cf3, cf4)); @@ -1262,16 +1231,13 @@ public static CompletableFuture> allTupl * Returns a new CompletableFuture that is successful when the given five 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. - *

- * This method is the same as {@link #allTupleOf(CompletionStage, CompletionStage, CompletionStage, CompletionStage, CompletionStage)} - * except for the fast-fail behavior. * * @return a new CompletableFuture that is successful when the given five stages success * @throws NullPointerException if any of the given stages are {@code null} - * @see #allResultsOfFastFail(CompletionStage[]) + * @see #allResultsFastFailOf(CompletionStage[]) */ @Contract(pure = true) - public static CompletableFuture> allTupleOfFastFail( + public static CompletableFuture> allTupleFastFailOf( CompletionStage cf1, CompletionStage cf2, CompletionStage cf3, CompletionStage cf4, CompletionStage cf5) { return allTupleOf0(true, requireCfsAndEleNonNull(cf1, cf2, cf3, cf4, cf5)); @@ -1286,13 +1252,13 @@ public static CompletableFuture> * @param timeout how long to wait in units of {@code unit} * @param unit a {@code TimeUnit} determining how to interpret the {@code timeout} parameter * @return a new CompletableFuture that is completed when the given two stages complete - * @see #mostResultsOfSuccess(Object, long, TimeUnit, CompletionStage[]) + * @see #mostSuccessResultsOf(Object, long, TimeUnit, CompletionStage[]) * @see #getSuccessNow(CompletableFuture, Object) */ @Contract(pure = true) - public static CompletableFuture> mostTupleOfSuccess( + public static CompletableFuture> mostSuccessTupleOf( long timeout, TimeUnit unit, CompletionStage cf1, CompletionStage cf2) { - return mostTupleOfSuccess(AsyncPoolHolder.ASYNC_POOL, timeout, unit, cf1, cf2); + return mostSuccessTupleOf(AsyncPoolHolder.ASYNC_POOL, timeout, unit, cf1, cf2); } /** @@ -1305,14 +1271,14 @@ public static CompletableFuture> mostTupleOfSuccess( * @param timeout how long to wait in units of {@code unit} * @param unit a {@code TimeUnit} determining how to interpret the {@code timeout} parameter * @return a new CompletableFuture that is completed when the given two stages complete - * @see #mostResultsOfSuccess(Object, long, TimeUnit, CompletionStage[]) + * @see #mostSuccessResultsOf(Object, long, TimeUnit, CompletionStage[]) * @see #getSuccessNow(CompletableFuture, Object) */ @Contract(pure = true) - public static CompletableFuture> mostTupleOfSuccess( + public static CompletableFuture> mostSuccessTupleOf( Executor executorWhenTimeout, long timeout, TimeUnit unit, CompletionStage cf1, CompletionStage cf2) { - return mostTupleOfSuccess0(executorWhenTimeout, timeout, unit, cf1, cf2); + return mostSuccessTupleOf0(executorWhenTimeout, timeout, unit, cf1, cf2); } /** @@ -1324,14 +1290,14 @@ public static CompletableFuture> mostTupleOfSuccess( * @param timeout how long to wait in units of {@code unit} * @param unit a {@code TimeUnit} determining how to interpret the {@code timeout} parameter * @return a new CompletableFuture that is completed when the given three stages complete - * @see #mostResultsOfSuccess(Object, long, TimeUnit, CompletionStage[]) + * @see #mostSuccessResultsOf(Object, long, TimeUnit, CompletionStage[]) * @see #getSuccessNow(CompletableFuture, Object) */ @Contract(pure = true) - public static CompletableFuture> mostTupleOfSuccess( + public static CompletableFuture> mostSuccessTupleOf( long timeout, TimeUnit unit, CompletionStage cf1, CompletionStage cf2, CompletionStage cf3) { - return mostTupleOfSuccess(AsyncPoolHolder.ASYNC_POOL, timeout, unit, cf1, cf2, cf3); + return mostSuccessTupleOf(AsyncPoolHolder.ASYNC_POOL, timeout, unit, cf1, cf2, cf3); } /** @@ -1344,14 +1310,14 @@ public static CompletableFuture> mostTupleOfSucc * @param timeout how long to wait in units of {@code unit} * @param unit a {@code TimeUnit} determining how to interpret the {@code timeout} parameter * @return a new CompletableFuture that is completed when the given three stages complete - * @see #mostResultsOfSuccess(Object, long, TimeUnit, CompletionStage[]) + * @see #mostSuccessResultsOf(Object, long, TimeUnit, CompletionStage[]) * @see #getSuccessNow(CompletableFuture, Object) */ @Contract(pure = true) - public static CompletableFuture> mostTupleOfSuccess( + public static CompletableFuture> mostSuccessTupleOf( Executor executorWhenTimeout, long timeout, TimeUnit unit, CompletionStage cf1, CompletionStage cf2, CompletionStage cf3) { - return mostTupleOfSuccess0(executorWhenTimeout, timeout, unit, cf1, cf2, cf3); + return mostSuccessTupleOf0(executorWhenTimeout, timeout, unit, cf1, cf2, cf3); } /** @@ -1363,15 +1329,15 @@ public static CompletableFuture> mostTupleOfSucc * @param timeout how long to wait in units of {@code unit} * @param unit a {@code TimeUnit} determining how to interpret the {@code timeout} parameter * @return a new CompletableFuture that is completed when the given four stages complete - * @see #mostResultsOfSuccess(Object, long, TimeUnit, CompletionStage[]) + * @see #mostSuccessResultsOf(Object, long, TimeUnit, CompletionStage[]) * @see #getSuccessNow(CompletableFuture, Object) */ @Contract(pure = true) - public static CompletableFuture> mostTupleOfSuccess( + public static CompletableFuture> mostSuccessTupleOf( long timeout, TimeUnit unit, CompletionStage cf1, CompletionStage cf2, CompletionStage cf3, CompletionStage cf4) { - return mostTupleOfSuccess(AsyncPoolHolder.ASYNC_POOL, timeout, unit, cf1, cf2, cf3, cf4); + return mostSuccessTupleOf(AsyncPoolHolder.ASYNC_POOL, timeout, unit, cf1, cf2, cf3, cf4); } /** @@ -1384,15 +1350,15 @@ public static CompletableFuture> mostTup * @param timeout how long to wait in units of {@code unit} * @param unit a {@code TimeUnit} determining how to interpret the {@code timeout} parameter * @return a new CompletableFuture that is completed when the given four stages complete - * @see #mostResultsOfSuccess(Object, long, TimeUnit, CompletionStage[]) + * @see #mostSuccessResultsOf(Object, long, TimeUnit, CompletionStage[]) * @see #getSuccessNow(CompletableFuture, Object) */ @Contract(pure = true) - public static CompletableFuture> mostTupleOfSuccess( + public static CompletableFuture> mostSuccessTupleOf( Executor executorWhenTimeout, long timeout, TimeUnit unit, CompletionStage cf1, CompletionStage cf2, CompletionStage cf3, CompletionStage cf4) { - return mostTupleOfSuccess0(executorWhenTimeout, timeout, unit, cf1, cf2, cf3, cf4); + return mostSuccessTupleOf0(executorWhenTimeout, timeout, unit, cf1, cf2, cf3, cf4); } /** @@ -1404,15 +1370,15 @@ public static CompletableFuture> mostTup * @param timeout how long to wait in units of {@code unit} * @param unit a {@code TimeUnit} determining how to interpret the {@code timeout} parameter * @return a new CompletableFuture that is completed when the given five stages complete - * @see #mostResultsOfSuccess(Object, long, TimeUnit, CompletionStage[]) + * @see #mostSuccessResultsOf(Object, long, TimeUnit, CompletionStage[]) * @see #getSuccessNow(CompletableFuture, Object) */ @Contract(pure = true) - public static CompletableFuture> mostTupleOfSuccess( + public static CompletableFuture> mostSuccessTupleOf( long timeout, TimeUnit unit, CompletionStage cf1, CompletionStage cf2, CompletionStage cf3, CompletionStage cf4, CompletionStage cf5) { - return mostTupleOfSuccess(AsyncPoolHolder.ASYNC_POOL, timeout, unit, cf1, cf2, cf3, cf4, cf5); + return mostSuccessTupleOf(AsyncPoolHolder.ASYNC_POOL, timeout, unit, cf1, cf2, cf3, cf4, cf5); } /** @@ -1425,15 +1391,15 @@ public static CompletableFuture> * @param timeout how long to wait in units of {@code unit} * @param unit a {@code TimeUnit} determining how to interpret the {@code timeout} parameter * @return a new CompletableFuture that is completed when the given five stages complete - * @see #mostResultsOfSuccess(Object, long, TimeUnit, CompletionStage[]) + * @see #mostSuccessResultsOf(Object, long, TimeUnit, CompletionStage[]) * @see #getSuccessNow(CompletableFuture, Object) */ @Contract(pure = true) - public static CompletableFuture> mostTupleOfSuccess( + public static CompletableFuture> mostSuccessTupleOf( Executor executorWhenTimeout, long timeout, TimeUnit unit, CompletionStage cf1, CompletionStage cf2, CompletionStage cf3, CompletionStage cf4, CompletionStage cf5) { - return mostTupleOfSuccess0(executorWhenTimeout, timeout, unit, cf1, cf2, cf3, cf4, cf5); + return mostSuccessTupleOf0(executorWhenTimeout, timeout, unit, cf1, cf2, cf3, cf4, cf5); } /** @@ -1644,9 +1610,6 @@ public static Throwable unwrapCfException(Throwable throwable) { * 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. - *

- * This method is the same as {@link #thenMApplyAsync(CompletionStage, Function[])} - * except for the fast-fail behavior. * * @param fns the functions to use to compute the values of the returned CompletableFuture * @param the functions' return type @@ -1654,8 +1617,8 @@ public static Throwable unwrapCfException(Throwable throwable) { */ @SafeVarargs public static CompletableFuture> thenMApplyFastFailAsync( - CompletionStage cf, Function... fns) { - return thenMApplyFastFailAsync(cf, AsyncPoolHolder.ASYNC_POOL, fns); + CompletableFuture cfThis, Function... fns) { + return thenMApplyFastFailAsync(cfThis, AsyncPoolHolder.ASYNC_POOL, fns); } /** @@ -1663,23 +1626,20 @@ public static CompletableFuture> thenMApplyFastFailAsync( * 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. - *

- * This method is the same as {@link #thenMApplyAsync(CompletionStage, Executor, Function[])} - * except for the fast-fail behavior. * - * @param fns the functions to use to compute the values of the returned CompletableFuture * @param executor the executor to use for asynchronous execution + * @param fns the functions to use to compute the values of the returned CompletableFuture * @param the functions' return type * @return the new CompletableFuture */ @SafeVarargs public static CompletableFuture> thenMApplyFastFailAsync( - CompletionStage cf, Executor executor, Function... fns) { - requireNonNull(cf, "cf is null"); + CompletableFuture cfThis, Executor executor, Function... fns) { + requireNonNull(cfThis, "cfThis is null"); requireNonNull(executor, "executor is null"); requireArrayAndEleNonNull("fn", fns); - return f_toCf(cf).thenCompose(v -> allResultsOfFastFail(wrapFunctions(executor, v, fns))); + return cfThis.thenCompose(v -> allResultsFastFailOf(wrapFunctions(executor, v, fns))); } /** @@ -1702,9 +1662,9 @@ public static CompletableFuture> thenMApplyFastFailAsync( */ @SafeVarargs public static CompletableFuture> thenMApplyMostSuccessAsync( - CompletionStage cf, @Nullable U valueIfNotSuccess, + CompletableFuture cfThis, @Nullable U valueIfNotSuccess, long timeout, TimeUnit unit, Function... fns) { - return thenMApplyMostSuccessAsync(cf, valueIfNotSuccess, AsyncPoolHolder.ASYNC_POOL, timeout, unit, fns); + return thenMApplyMostSuccessAsync(cfThis, valueIfNotSuccess, AsyncPoolHolder.ASYNC_POOL, timeout, unit, fns); } /** @@ -1727,13 +1687,14 @@ public static CompletableFuture> thenMApplyMostSuccessAsync( */ @SafeVarargs public static CompletableFuture> thenMApplyMostSuccessAsync( - CompletionStage cf, @Nullable U valueIfNotSuccess, + CompletableFuture cfThis, @Nullable U valueIfNotSuccess, Executor executor, long timeout, TimeUnit unit, Function... fns) { + requireNonNull(cfThis, "cfThis is null"); requireNonNull(executor, "executor is null"); requireNonNull(unit, "unit is null"); requireArrayAndEleNonNull("fn", fns); - return f_toCf(cf).thenCompose(v -> mostResultsOfSuccess( + return cfThis.thenCompose(v -> mostSuccessResultsOf( valueIfNotSuccess, executor, timeout, unit, wrapFunctions(executor, v, fns) )); } @@ -1751,8 +1712,8 @@ valueIfNotSuccess, executor, timeout, unit, wrapFunctions(executor, v, fns) */ @SafeVarargs public static CompletableFuture> thenMApplyAsync( - CompletionStage cf, Function... fns) { - return thenMApplyAsync(cf, AsyncPoolHolder.ASYNC_POOL, fns); + CompletableFuture cfThis, Function... fns) { + return thenMApplyAsync(cfThis, AsyncPoolHolder.ASYNC_POOL, fns); } /** @@ -1768,12 +1729,12 @@ public static CompletableFuture> thenMApplyAsync( */ @SafeVarargs public static CompletableFuture> thenMApplyAsync( - CompletionStage cf, Executor executor, Function... fns) { - requireNonNull(cf, "cf is null"); + CompletableFuture cfThis, Executor executor, Function... fns) { + requireNonNull(cfThis, "cfThis is null"); requireNonNull(executor, "executor is null"); requireArrayAndEleNonNull("fn", fns); - return f_toCf(cf).thenCompose(v -> allResultsOf(wrapFunctions(executor, v, fns))); + return cfThis.thenCompose(v -> allResultsOf(wrapFunctions(executor, v, fns))); } private static CompletableFuture[] wrapFunctions( @@ -1797,8 +1758,8 @@ private static CompletableFuture[] wrapFunctions( */ @SafeVarargs public static CompletableFuture thenMAcceptAsync( - CompletionStage cf, Consumer... actions) { - return thenMAcceptAsync(cf, AsyncPoolHolder.ASYNC_POOL, actions); + CompletableFuture cfThis, Consumer... actions) { + return thenMAcceptAsync(cfThis, AsyncPoolHolder.ASYNC_POOL, actions); } /** @@ -1811,37 +1772,31 @@ public static CompletableFuture thenMAcceptAsync( */ @SafeVarargs public static CompletableFuture thenMAcceptAsync( - CompletionStage cf, Executor executor, Consumer... actions) { - requireNonNull(cf, "cf is null"); + CompletableFuture cfThis, Executor executor, Consumer... actions) { + requireNonNull(cfThis, "cfThis is null"); requireNonNull(executor, "executor is null"); requireArrayAndEleNonNull("action", actions); - return f_toCf(cf).thenCompose(v -> CompletableFuture.allOf(wrapConsumers(executor, v, actions))); + return cfThis.thenCompose(v -> CompletableFuture.allOf(wrapConsumers(executor, v, 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. - *

- * This method is the same as {@link #thenMAcceptAsync(CompletionStage, Consumer[])} - * except for the fast-fail behavior. * * @param actions the actions to perform before completing the returned CompletableFuture * @return the new CompletableFuture */ @SafeVarargs public static CompletableFuture thenMAcceptFastFailAsync( - CompletionStage cf, Consumer... actions) { - return thenMAcceptFastFailAsync(cf, AsyncPoolHolder.ASYNC_POOL, actions); + CompletableFuture cfThis, Consumer... actions) { + return thenMAcceptFastFailAsync(cfThis, AsyncPoolHolder.ASYNC_POOL, 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. - *

- * This method is the same as {@link #thenMAcceptAsync(CompletionStage, Executor, Consumer[])} - * except for the fast-fail behavior. * * @param executor the executor to use for asynchronous execution * @param actions the actions to perform before completing the returned CompletableFuture @@ -1849,12 +1804,12 @@ public static CompletableFuture thenMAcceptFastFailAsync( */ @SafeVarargs public static CompletableFuture thenMAcceptFastFailAsync( - CompletionStage cf, Executor executor, Consumer... actions) { - requireNonNull(cf, "cf is null"); + CompletableFuture cfThis, Executor executor, Consumer... actions) { + requireNonNull(cfThis, "cfThis is null"); requireNonNull(executor, "executor is null"); requireArrayAndEleNonNull("action", actions); - return f_toCf(cf).thenCompose(v -> allOfFastFail(wrapConsumers(executor, v, actions))); + return cfThis.thenCompose(v -> allFastFailOf(wrapConsumers(executor, v, actions))); } private static CompletableFuture[] wrapConsumers(Executor executor, T v, Consumer[] actions) { @@ -1870,39 +1825,33 @@ private static CompletableFuture[] wrapConsumers(Executor executor, T /** * Returns a new CompletableFuture that, when the given stage completes normally, * executes the given actions using the CompletableFuture's default asynchronous execution facility. - *

- * This method is the same as {@link #thenMRunAsync(CompletionStage, Runnable...)} - * except for the fast-fail behavior. * * @param actions the actions to perform before completing the returned CompletableFuture * @return the new CompletableFuture * @see CompletableFuture#thenRunAsync(Runnable) - * @see #allOfFastFail(CompletionStage[]) + * @see #allFastFailOf(CompletionStage[]) */ - public static CompletableFuture thenMRunFastFailAsync(CompletionStage cf, Runnable... actions) { - return thenMRunFastFailAsync(cf, AsyncPoolHolder.ASYNC_POOL, actions); + public static CompletableFuture thenMRunFastFailAsync(CompletableFuture cfThis, Runnable... actions) { + return thenMRunFastFailAsync(cfThis, AsyncPoolHolder.ASYNC_POOL, actions); } /** * Returns a new CompletableFuture that, when the given stage completes normally, * executes the given actions using the given Executor. - *

- * This method is the same as {@link #thenMRunAsync(CompletionStage, Executor, Runnable...)} - * except for the fast-fail behavior. * * @param executor the executor to use for asynchronous execution * @param actions the actions to perform before completing the returned CompletableFuture * @return the new CompletableFuture * @see CompletableFuture#thenRunAsync(Runnable, Executor) - * @see #allOfFastFail(CompletionStage[]) + * @see #allFastFailOf(CompletionStage[]) */ public static CompletableFuture thenMRunFastFailAsync( - CompletionStage cf, Executor executor, Runnable... actions) { - requireNonNull(cf, "cf is null"); + CompletableFuture cfThis, Executor executor, Runnable... actions) { + requireNonNull(cfThis, "cfThis is null"); requireNonNull(executor, "executor is null"); requireArrayAndEleNonNull("action", actions); - return f_toCf(cf).thenCompose(unused -> allOfFastFail(wrapRunnables(executor, actions))); + return cfThis.thenCompose(unused -> allFastFailOf(wrapRunnables(executor, actions))); } /** @@ -1914,8 +1863,8 @@ public static CompletableFuture thenMRunFastFailAsync( * @see CompletableFuture#thenRunAsync(Runnable) * @see #allOf(CompletionStage[]) */ - public static CompletableFuture thenMRunAsync(CompletionStage cf, Runnable... actions) { - return thenMRunAsync(cf, AsyncPoolHolder.ASYNC_POOL, actions); + public static CompletableFuture thenMRunAsync(CompletableFuture cfThis, Runnable... actions) { + return thenMRunAsync(cfThis, AsyncPoolHolder.ASYNC_POOL, actions); } /** @@ -1928,12 +1877,13 @@ public static CompletableFuture thenMRunAsync(CompletionStage cf, Runna * @see CompletableFuture#thenRunAsync(Runnable, Executor) * @see #allOf(CompletionStage[]) */ - public static CompletableFuture thenMRunAsync(CompletionStage cf, Executor executor, Runnable... actions) { - requireNonNull(cf, "cf is null"); + public static CompletableFuture thenMRunAsync( + CompletableFuture cfThis, Executor executor, Runnable... actions) { + requireNonNull(cfThis, "cfThis is null"); requireNonNull(executor, "executor is null"); requireArrayAndEleNonNull("action", actions); - return f_toCf(cf).thenCompose(unused -> CompletableFuture.allOf(wrapRunnables(executor, actions))); + return cfThis.thenCompose(unused -> CompletableFuture.allOf(wrapRunnables(executor, actions))); } // endregion @@ -1947,16 +1897,13 @@ public static CompletableFuture thenMRunAsync(CompletionStage cf, Execu * 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. - *

- * This method is the same as {@link #thenTupleMApplyAsync(CompletionStage, Function, Function)} - * except for the fast-fail behavior. * * @return the new CompletableFuture */ public static CompletableFuture> thenTupleMApplyFastFailAsync( - CompletionStage cf, + CompletableFuture cfThis, Function fn1, Function fn2) { - return thenTupleMApplyFastFailAsync(cf, AsyncPoolHolder.ASYNC_POOL, fn1, fn2); + return thenTupleMApplyFastFailAsync(cfThis, AsyncPoolHolder.ASYNC_POOL, fn1, fn2); } /** @@ -1964,20 +1911,18 @@ public static CompletableFuture> thenTupleMApplyFastF * 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. - *

- * This method is the same as {@link #thenTupleMApplyAsync(CompletionStage, Executor, Function, Function)} - * except for the fast-fail behavior. * + * @param executor the executor to use for asynchronous execution * @return the new CompletableFuture */ public static CompletableFuture> thenTupleMApplyFastFailAsync( - CompletionStage cf, Executor executor, + CompletableFuture cfThis, Executor executor, Function fn1, Function fn2) { - requireNonNull(cf, "cf is null"); + requireNonNull(cfThis, "cfThis is null"); requireNonNull(executor, "executor is null"); Function[] fns = requireArrayAndEleNonNull("fn", fn1, fn2); - return f_toCf(cf).thenCompose(v -> allTupleOf0(true, wrapFunctions(executor, v, fns))); + return cfThis.thenCompose(v -> allTupleOf0(true, wrapFunctions(executor, v, fns))); } /** @@ -1986,16 +1931,13 @@ public static CompletableFuture> thenTupleMApplyFastF * 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. - *

- * This method is the same as {@link #thenTupleMApplyAsync(CompletionStage, Function, Function, Function)} - * except for the fast-fail behavior. * * @return the new CompletableFuture */ public static CompletableFuture> thenTupleMApplyFastFailAsync( - CompletionStage cf, Function fn1, + CompletableFuture cfThis, Function fn1, Function fn2, Function fn3) { - return thenTupleMApplyFastFailAsync(cf, AsyncPoolHolder.ASYNC_POOL, fn1, fn2, fn3); + return thenTupleMApplyFastFailAsync(cfThis, AsyncPoolHolder.ASYNC_POOL, fn1, fn2, fn3); } /** @@ -2003,20 +1945,18 @@ public static CompletableFuture> thenTupleMAp * 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. - *

- * This method is the same as {@link #thenTupleMApplyAsync(CompletionStage, Executor, Function, Function, Function)} - * except for the fast-fail behavior. * + * @param executor the executor to use for asynchronous execution * @return the new CompletableFuture */ public static CompletableFuture> thenTupleMApplyFastFailAsync( - CompletionStage cf, Executor executor, Function fn1, + CompletableFuture cfThis, Executor executor, Function fn1, Function fn2, Function fn3) { - requireNonNull(cf, "cf is null"); + requireNonNull(cfThis, "cfThis is null"); requireNonNull(executor, "executor is null"); Function[] fns = requireArrayAndEleNonNull("fn", fn1, fn2, fn3); - return f_toCf(cf).thenCompose(v -> allTupleOf0(true, wrapFunctions(executor, v, fns))); + return cfThis.thenCompose(v -> allTupleOf0(true, wrapFunctions(executor, v, fns))); } /** @@ -2025,17 +1965,14 @@ public static CompletableFuture> thenTupleMAp * 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. - *

- * This method is the same as {@link #thenTupleMApplyAsync(CompletionStage, Function, Function, Function, Function)} - * except for the fast-fail behavior. * * @return the new CompletableFuture */ public static CompletableFuture> thenTupleMApplyFastFailAsync( - CompletionStage cf, Function fn1, + CompletableFuture cfThis, Function fn1, Function fn2, Function fn3, Function fn4) { - return thenTupleMApplyFastFailAsync(cf, AsyncPoolHolder.ASYNC_POOL, fn1, fn2, fn3, fn4); + return thenTupleMApplyFastFailAsync(cfThis, AsyncPoolHolder.ASYNC_POOL, fn1, fn2, fn3, fn4); } /** @@ -2043,21 +1980,19 @@ public static CompletableFuture> then * 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. - *

- * This method is the same as {@link #thenTupleMApplyAsync(CompletionStage, Executor, Function, Function, Function, Function)} - * except for the fast-fail behavior. * + * @param executor the executor to use for asynchronous execution * @return the new CompletableFuture */ public static CompletableFuture> thenTupleMApplyFastFailAsync( - CompletionStage cf, Executor executor, Function fn1, + CompletableFuture cfThis, Executor executor, Function fn1, Function fn2, Function fn3, Function fn4) { - requireNonNull(cf, "cf is null"); + requireNonNull(cfThis, "cfThis is null"); requireNonNull(executor, "executor is null"); Function[] fns = requireArrayAndEleNonNull("fn", fn1, fn2, fn3, fn4); - return f_toCf(cf).thenCompose(v -> allTupleOf0(true, wrapFunctions(executor, v, fns))); + return cfThis.thenCompose(v -> allTupleOf0(true, wrapFunctions(executor, v, fns))); } /** @@ -2066,17 +2001,14 @@ public static CompletableFuture> then * 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. - *

- * This method is the same as {@link #thenTupleMApplyAsync(CompletionStage, Function, Function, Function, Function, Function)} - * except for the fast-fail behavior. * * @return the new CompletableFuture */ public static CompletableFuture> thenTupleMApplyFastFailAsync( - CompletionStage cf, Function fn1, + CompletableFuture cfThis, Function fn1, Function fn2, Function fn3, Function fn4, Function fn5) { - return thenTupleMApplyFastFailAsync(cf, AsyncPoolHolder.ASYNC_POOL, fn1, fn2, fn3, fn4, fn5); + return thenTupleMApplyFastFailAsync(cfThis, AsyncPoolHolder.ASYNC_POOL, fn1, fn2, fn3, fn4, fn5); } /** @@ -2084,21 +2016,19 @@ public static CompletableFuturesame order of the given Functions arguments. - *

- * This method is the same as {@link #thenTupleMApplyAsync(CompletionStage, Executor, Function, Function, Function, Function, Function)} - * except for the fast-fail behavior. * + * @param executor the executor to use for asynchronous execution * @return the new CompletableFuture */ public static CompletableFuture> thenTupleMApplyFastFailAsync( - CompletionStage cf, Executor executor, Function fn1, + CompletableFuture cfThis, Executor executor, Function fn1, Function fn2, Function fn3, Function fn4, Function fn5) { - requireNonNull(cf, "cf is null"); + requireNonNull(cfThis, "cfThis is null"); requireNonNull(executor, "executor is null"); Function[] fns = requireArrayAndEleNonNull("fn", fn1, fn2, fn3, fn4, fn5); - return f_toCf(cf).thenCompose(v -> allTupleOf0(true, wrapFunctions(executor, v, fns))); + return cfThis.thenCompose(v -> allTupleOf0(true, wrapFunctions(executor, v, fns))); } /** @@ -2117,9 +2047,9 @@ public static CompletableFuture CompletableFuture> thenTupleMApplyMostSuccessAsync( - CompletionStage cf, long timeout, TimeUnit unit, + CompletableFuture cfThis, long timeout, TimeUnit unit, Function fn1, Function fn2) { - return thenTupleMApplyMostSuccessAsync(cf, AsyncPoolHolder.ASYNC_POOL, timeout, unit, fn1, fn2); + return thenTupleMApplyMostSuccessAsync(cfThis, AsyncPoolHolder.ASYNC_POOL, timeout, unit, fn1, fn2); } /** @@ -2139,13 +2069,14 @@ public static CompletableFuture> thenTupleMApplyMostS * @return the new CompletableFuture */ public static CompletableFuture> thenTupleMApplyMostSuccessAsync( - CompletionStage cf, Executor executor, long timeout, TimeUnit unit, + CompletableFuture cfThis, Executor executor, long timeout, TimeUnit unit, Function fn1, Function fn2) { + requireNonNull(cfThis, "cfThis is null"); requireNonNull(executor, "executor is null"); requireNonNull(unit, "unit is null"); Function[] fns = requireArrayAndEleNonNull("fn", fn1, fn2); - return f_toCf(cf).thenCompose(v -> mostTupleOfSuccess0(executor, timeout, unit, wrapFunctions(executor, v, fns))); + return cfThis.thenCompose(v -> mostSuccessTupleOf0(executor, timeout, unit, wrapFunctions(executor, v, fns))); } /** @@ -2164,9 +2095,9 @@ public static CompletableFuture> thenTupleMApplyMostS * @return the new CompletableFuture */ public static CompletableFuture> thenTupleMApplyMostSuccessAsync( - CompletionStage cf, long timeout, TimeUnit unit, Function fn1, + CompletableFuture cfThis, long timeout, TimeUnit unit, Function fn1, Function fn2, Function fn3) { - return thenTupleMApplyMostSuccessAsync(cf, AsyncPoolHolder.ASYNC_POOL, timeout, unit, fn1, fn2, fn3); + return thenTupleMApplyMostSuccessAsync(cfThis, AsyncPoolHolder.ASYNC_POOL, timeout, unit, fn1, fn2, fn3); } /** @@ -2186,14 +2117,15 @@ public static CompletableFuture> thenTupleMAp * @return the new CompletableFuture */ public static CompletableFuture> thenTupleMApplyMostSuccessAsync( - CompletionStage cf, Executor executor, long timeout, TimeUnit unit, + CompletableFuture cfThis, Executor executor, long timeout, TimeUnit unit, Function fn1, Function fn2, Function fn3) { + requireNonNull(cfThis, "cfThis is null"); requireNonNull(executor, "executor is null"); requireNonNull(unit, "unit is null"); Function[] fns = requireArrayAndEleNonNull("fn", fn1, fn2, fn3); - return f_toCf(cf).thenCompose(v -> mostTupleOfSuccess0(executor, timeout, unit, wrapFunctions(executor, v, fns))); + return cfThis.thenCompose(v -> mostSuccessTupleOf0(executor, timeout, unit, wrapFunctions(executor, v, fns))); } /** @@ -2212,10 +2144,10 @@ public static CompletableFuture> thenTupleMAp * @return the new CompletableFuture */ public static CompletableFuture> thenTupleMApplyMostSuccessAsync( - CompletionStage cf, long timeout, TimeUnit unit, + CompletableFuture cfThis, long timeout, TimeUnit unit, Function fn1, Function fn2, Function fn3, Function fn4) { - return thenTupleMApplyMostSuccessAsync(cf, AsyncPoolHolder.ASYNC_POOL, timeout, unit, fn1, fn2, fn3, fn4); + return thenTupleMApplyMostSuccessAsync(cfThis, AsyncPoolHolder.ASYNC_POOL, timeout, unit, fn1, fn2, fn3, fn4); } /** @@ -2235,14 +2167,15 @@ public static CompletableFuture> then * @return the new CompletableFuture */ public static CompletableFuture> thenTupleMApplyMostSuccessAsync( - CompletionStage cf, Executor executor, long timeout, TimeUnit unit, + CompletableFuture cfThis, Executor executor, long timeout, TimeUnit unit, Function fn1, Function fn2, Function fn3, Function fn4) { + requireNonNull(cfThis, "cfThis is null"); requireNonNull(executor, "executor is null"); requireNonNull(unit, "unit is null"); Function[] fns = requireArrayAndEleNonNull("fn", fn1, fn2, fn3, fn4); - return f_toCf(cf).thenCompose(v -> mostTupleOfSuccess0(executor, timeout, unit, wrapFunctions(executor, v, fns))); + return cfThis.thenCompose(v -> mostSuccessTupleOf0(executor, timeout, unit, wrapFunctions(executor, v, fns))); } /** @@ -2261,10 +2194,10 @@ public static CompletableFuture> then * @return the new CompletableFuture */ public static CompletableFuture> thenTupleMApplyMostSuccessAsync( - CompletionStage cf, long timeout, TimeUnit unit, Function fn1, + CompletableFuture cfThis, long timeout, TimeUnit unit, Function fn1, Function fn2, Function fn3, Function fn4, Function fn5) { - return thenTupleMApplyMostSuccessAsync(cf, AsyncPoolHolder.ASYNC_POOL, timeout, unit, fn1, fn2, fn3, fn4, fn5); + return thenTupleMApplyMostSuccessAsync(cfThis, AsyncPoolHolder.ASYNC_POOL, timeout, unit, fn1, fn2, fn3, fn4, fn5); } /** @@ -2284,15 +2217,16 @@ public static CompletableFuture CompletableFuture> thenTupleMApplyMostSuccessAsync( - CompletionStage cf, Executor executor, long timeout, TimeUnit unit, + CompletableFuture cfThis, Executor executor, long timeout, TimeUnit unit, Function fn1, Function fn2, Function fn3, Function fn4, Function fn5) { + requireNonNull(cfThis, "cfThis is null"); requireNonNull(executor, "executor is null"); requireNonNull(unit, "unit is null"); Function[] fns = requireArrayAndEleNonNull("fn", fn1, fn2, fn3, fn4, fn5); - return f_toCf(cf).thenCompose(v -> mostTupleOfSuccess0(executor, timeout, unit, wrapFunctions(executor, v, fns))); + return cfThis.thenCompose(v -> mostSuccessTupleOf0(executor, timeout, unit, wrapFunctions(executor, v, fns))); } /** @@ -2305,9 +2239,9 @@ public static CompletableFuture CompletableFuture> thenTupleMApplyAsync( - CompletionStage cf, + CompletableFuture cfThis, Function fn1, Function fn2) { - return thenTupleMApplyAsync(cf, AsyncPoolHolder.ASYNC_POOL, fn1, fn2); + return thenTupleMApplyAsync(cfThis, AsyncPoolHolder.ASYNC_POOL, fn1, fn2); } /** @@ -2316,16 +2250,17 @@ public static CompletableFuture> thenTupleMApplyAsync * (with the given stage's result as the argument to the given functions) * in the same order of the given Functions arguments. * + * @param executor the executor to use for asynchronous execution * @return the new CompletableFuture */ public static CompletableFuture> thenTupleMApplyAsync( - CompletionStage cf, Executor executor, + CompletableFuture cfThis, Executor executor, Function fn1, Function fn2) { - requireNonNull(cf, "cf is null"); + requireNonNull(cfThis, "cfThis is null"); requireNonNull(executor, "executor is null"); Function[] fns = requireArrayAndEleNonNull("fn", fn1, fn2); - return f_toCf(cf).thenCompose(v -> allTupleOf0(false, wrapFunctions(executor, v, fns))); + return cfThis.thenCompose(v -> allTupleOf0(false, wrapFunctions(executor, v, fns))); } /** @@ -2338,9 +2273,9 @@ public static CompletableFuture> thenTupleMApplyAsync * @return the new CompletableFuture */ public static CompletableFuture> thenTupleMApplyAsync( - CompletionStage cf, Function fn1, + CompletableFuture cfThis, Function fn1, Function fn2, Function fn3) { - return thenTupleMApplyAsync(cf, AsyncPoolHolder.ASYNC_POOL, fn1, fn2, fn3); + return thenTupleMApplyAsync(cfThis, AsyncPoolHolder.ASYNC_POOL, fn1, fn2, fn3); } /** @@ -2349,16 +2284,17 @@ public static CompletableFuture> thenTupleMAp * (with the given stage's result as the argument to the given functions) * in the same order of the given Functions arguments. * + * @param executor the executor to use for asynchronous execution * @return the new CompletableFuture */ public static CompletableFuture> thenTupleMApplyAsync( - CompletionStage cf, Executor executor, Function fn1, + CompletableFuture cfThis, Executor executor, Function fn1, Function fn2, Function fn3) { - requireNonNull(cf, "cf is null"); + requireNonNull(cfThis, "cfThis is null"); requireNonNull(executor, "executor is null"); Function[] fns = requireArrayAndEleNonNull("fn", fn1, fn2, fn3); - return f_toCf(cf).thenCompose(v -> allTupleOf0(false, wrapFunctions(executor, v, fns))); + return cfThis.thenCompose(v -> allTupleOf0(false, wrapFunctions(executor, v, fns))); } /** @@ -2371,10 +2307,10 @@ public static CompletableFuture> thenTupleMAp * @return the new CompletableFuture */ public static CompletableFuture> thenTupleMApplyAsync( - CompletionStage cf, Function fn1, + CompletableFuture cfThis, Function fn1, Function fn2, Function fn3, Function fn4) { - return thenTupleMApplyAsync(cf, AsyncPoolHolder.ASYNC_POOL, fn1, fn2, fn3, fn4); + return thenTupleMApplyAsync(cfThis, AsyncPoolHolder.ASYNC_POOL, fn1, fn2, fn3, fn4); } /** @@ -2383,17 +2319,18 @@ public static CompletableFuture> then * (with the given stage's result as the argument to the given functions) * in the same order of the given Functions arguments. * + * @param executor the executor to use for asynchronous execution * @return the new CompletableFuture */ public static CompletableFuture> thenTupleMApplyAsync( - CompletionStage cf, Executor executor, Function fn1, + CompletableFuture cfThis, Executor executor, Function fn1, Function fn2, Function fn3, Function fn4) { - requireNonNull(cf, "cf is null"); + requireNonNull(cfThis, "cfThis is null"); requireNonNull(executor, "executor is null"); Function[] fns = requireArrayAndEleNonNull("fn", fn1, fn2, fn3, fn4); - return f_toCf(cf).thenCompose(v -> allTupleOf0(false, wrapFunctions(executor, v, fns))); + return cfThis.thenCompose(v -> allTupleOf0(false, wrapFunctions(executor, v, fns))); } /** @@ -2406,10 +2343,10 @@ public static CompletableFuture> then * @return the new CompletableFuture */ public static CompletableFuture> thenTupleMApplyAsync( - CompletionStage cf, Function fn1, + CompletableFuture cfThis, Function fn1, Function fn2, Function fn3, Function fn4, Function fn5) { - return thenTupleMApplyAsync(cf, AsyncPoolHolder.ASYNC_POOL, fn1, fn2, fn3, fn4, fn5); + return thenTupleMApplyAsync(cfThis, AsyncPoolHolder.ASYNC_POOL, fn1, fn2, fn3, fn4, fn5); } /** @@ -2418,17 +2355,18 @@ public static CompletableFuturesame order of the given Functions arguments. * + * @param executor the executor to use for asynchronous execution * @return the new CompletableFuture */ public static CompletableFuture> thenTupleMApplyAsync( - CompletionStage cf, Executor executor, Function fn1, + CompletableFuture cfThis, Executor executor, Function fn1, Function fn2, Function fn3, Function fn4, Function fn5) { - requireNonNull(cf, "cf is null"); + requireNonNull(cfThis, "cfThis is null"); requireNonNull(executor, "executor is null"); Function[] fns = requireArrayAndEleNonNull("fn", fn1, fn2, fn3, fn4, fn5); - return f_toCf(cf).thenCompose(v -> allTupleOf0(false, wrapFunctions(executor, v, fns))); + return cfThis.thenCompose(v -> allTupleOf0(false, wrapFunctions(executor, v, fns))); } // endregion @@ -2446,24 +2384,21 @@ public static CompletableFuture - * This method is the same as {@link CompletionStage#thenCombine(CompletionStage, BiFunction)} - * except for the fast-fail behavior. * * @param fn the function to use to compute the value of the returned CompletableFuture * @return the new CompletableFuture */ @SuppressWarnings("unchecked") public static CompletableFuture thenCombineFastFail( - CompletionStage cf1, CompletionStage cf2, + CompletableFuture cfThis, CompletionStage other, BiFunction fn) { - final CompletionStage[] css = requireCfsAndEleNonNull(cf1, cf2); + final CompletionStage[] css = requireCfsAndEleNonNull(cfThis, other); requireNonNull(fn, "fn is null"); final Object[] result = new Object[css.length]; final CompletableFuture[] resultSetterCfs = createResultSetterCfs(css, result); - return allOfFastFail(resultSetterCfs).thenApply(unused -> fn.apply((T) result[0], (U) result[1])); + return allFastFailOf(resultSetterCfs).thenApply(unused -> fn.apply((T) result[0], (U) result[1])); } /** @@ -2473,17 +2408,14 @@ public static CompletableFuture thenCombineFastFail( * 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. - *

- * This method is the same as {@link CompletionStage#thenCombineAsync(CompletionStage, BiFunction)} - * except for the fast-fail behavior. * * @param fn the function to use to compute the value of the returned CompletableFuture * @return the new CompletableFuture */ public static CompletableFuture thenCombineFastFailAsync( - CompletionStage cf1, CompletionStage cf2, + CompletableFuture cfThis, CompletionStage other, BiFunction fn) { - return thenCombineFastFailAsync(cf1, cf2, fn, AsyncPoolHolder.ASYNC_POOL); + return thenCombineFastFailAsync(cfThis, other, fn, AsyncPoolHolder.ASYNC_POOL); } /** @@ -2493,25 +2425,22 @@ public static CompletableFuture thenCombineFastFailAsync( * 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. - *

- * This method is the same as {@link CompletionStage#thenCombineAsync(CompletionStage, BiFunction, Executor)} - * except for the fast-fail behavior. * * @param fn the function to use to compute the value of the returned CompletableFuture * @return the new CompletableFuture */ @SuppressWarnings("unchecked") public static CompletableFuture thenCombineFastFailAsync( - CompletionStage cf1, CompletionStage cf2, + CompletableFuture cfThis, CompletionStage other, BiFunction fn, Executor executor) { - final CompletionStage[] css = requireCfsAndEleNonNull(cf1, cf2); + final CompletionStage[] css = requireCfsAndEleNonNull(cfThis, other); requireNonNull(fn, "fn is null"); requireNonNull(executor, "executor is null"); final Object[] result = new Object[css.length]; final CompletableFuture[] resultSetterCfs = createResultSetterCfs(css, result); - return allOfFastFail(resultSetterCfs) + return allFastFailOf(resultSetterCfs) .thenApplyAsync(unused -> fn.apply((T) result[0], (U) result[1]), executor); } @@ -2521,24 +2450,21 @@ public static CompletableFuture thenCombineFastFailAsync( * 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. - *

- * This method is the same as {@link CompletionStage#thenAcceptBoth(CompletionStage, BiConsumer)} - * except for the fast-fail behavior. * * @param action the action to perform before completing the returned CompletableFuture * @return the new CompletableFuture */ @SuppressWarnings("unchecked") public static CompletableFuture thenAcceptBothFastFail( - CompletionStage cf1, CompletionStage cf2, + CompletableFuture cfThis, CompletionStage other, BiConsumer action) { - final CompletionStage[] css = requireCfsAndEleNonNull(cf1, cf2); + final CompletionStage[] css = requireCfsAndEleNonNull(cfThis, other); requireNonNull(action, "action is null"); final Object[] result = new Object[css.length]; final CompletableFuture[] resultSetterCfs = createResultSetterCfs(css, result); - return allOfFastFail(resultSetterCfs).thenRun(() -> action.accept((T) result[0], (U) result[1])); + return allFastFailOf(resultSetterCfs).thenRun(() -> action.accept((T) result[0], (U) result[1])); } /** @@ -2548,17 +2474,14 @@ public static CompletableFuture thenAcceptBothFastFail( * 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. - *

- * This method is the same as {@link CompletionStage#thenAcceptBothAsync(CompletionStage, BiConsumer)} - * except for the fast-fail behavior. * * @param action the action to perform before completing the returned CompletableFuture * @return the new CompletableFuture */ public static CompletableFuture thenAcceptBothFastFailAsync( - CompletionStage cf1, CompletionStage cf2, + CompletableFuture cfThis, CompletionStage other, BiConsumer action) { - return thenAcceptBothFastFailAsync(cf1, cf2, action, AsyncPoolHolder.ASYNC_POOL); + return thenAcceptBothFastFailAsync(cfThis, other, action, AsyncPoolHolder.ASYNC_POOL); } /** @@ -2568,25 +2491,22 @@ public static CompletableFuture thenAcceptBothFastFailAsync( * 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. - *

- * This method is the same as {@link CompletionStage#thenAcceptBothAsync(CompletionStage, BiConsumer, Executor)} - * except for the fast-fail behavior. * * @param action the action to perform before completing the returned CompletableFuture * @return the new CompletableFuture */ @SuppressWarnings("unchecked") public static CompletableFuture thenAcceptBothFastFailAsync( - CompletionStage cf1, CompletionStage cf2, + CompletableFuture cfThis, CompletionStage other, BiConsumer action, Executor executor) { - final CompletionStage[] css = requireCfsAndEleNonNull(cf1, cf2); + final CompletionStage[] css = requireCfsAndEleNonNull(cfThis, other); requireNonNull(action, "action is null"); requireNonNull(executor, "executor is null"); final Object[] result = new Object[css.length]; final CompletableFuture[] resultSetterCfs = createResultSetterCfs(css, result); - return allOfFastFail(resultSetterCfs).thenRunAsync(() -> action.accept((T) result[0], (U) result[1]), executor); + return allFastFailOf(resultSetterCfs).thenRunAsync(() -> action.accept((T) result[0], (U) result[1]), executor); } /** @@ -2594,19 +2514,16 @@ public static CompletableFuture thenAcceptBothFastFailAsync( * 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. - *

- * This method is the same as {@link CompletionStage#runAfterBoth(CompletionStage, Runnable)} - * except for the fast-fail behavior. * * @param action the action to perform before completing the returned CompletableFuture * @return the new CompletableFuture */ public static CompletableFuture runAfterBothFastFail( - CompletionStage cf1, CompletionStage cf2, Runnable action) { - final CompletionStage[] css = requireCfsAndEleNonNull(cf1, cf2); + CompletableFuture cfThis, CompletionStage other, Runnable action) { + final CompletionStage[] css = requireCfsAndEleNonNull(cfThis, other); requireNonNull(action, "action is null"); - return allOfFastFail(css).thenRun(action); + return allFastFailOf(css).thenRun(action); } /** @@ -2615,16 +2532,13 @@ public static CompletableFuture runAfterBothFastFail( * 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. - *

- * This method is the same as {@link CompletionStage#runAfterBothAsync(CompletionStage, Runnable)} - * except for the fast-fail behavior. * * @param action the action to perform before completing the returned CompletableFuture * @return the new CompletableFuture */ public static CompletableFuture runAfterBothFastFailAsync( - CompletionStage cf1, CompletionStage cf2, Runnable action) { - return runAfterBothFastFailAsync(cf1, cf2, action, AsyncPoolHolder.ASYNC_POOL); + CompletableFuture cfThis, CompletionStage other, Runnable action) { + return runAfterBothFastFailAsync(cfThis, other, action, AsyncPoolHolder.ASYNC_POOL); } /** @@ -2633,20 +2547,17 @@ public static CompletableFuture runAfterBothFastFailAsync( * 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. - *

- * This method is the same as {@link CompletionStage#runAfterBothAsync(CompletionStage, Runnable, Executor)} - * except for the fast-fail behavior. * * @param action the action to perform before completing the returned CompletableFuture * @return the new CompletableFuture */ public static CompletableFuture runAfterBothFastFailAsync( - CompletionStage cf1, CompletionStage cf2, Runnable action, Executor executor) { - final CompletionStage[] css = requireCfsAndEleNonNull(cf1, cf2); + CompletableFuture cfThis, CompletionStage other, Runnable action, Executor executor) { + final CompletionStage[] css = requireCfsAndEleNonNull(cfThis, other); requireNonNull(action, "action is null"); requireNonNull(executor, "executor is null"); - return allOfFastFail(css).thenRunAsync(action, executor); + return allFastFailOf(css).thenRunAsync(action, executor); } // endregion @@ -2661,45 +2572,36 @@ public static CompletableFuture runAfterBothFastFailAsync( /** * Returns a new CompletableFuture that, when either given stage success, * is executed with the corresponding result as argument to the supplied function. - *

- * This method is the same as {@link CompletionStage#applyToEither(CompletionStage, Function)} - * except for the either-success behavior instead of either-complete. * * @param fn the function to use to compute the value of the returned CompletableFuture * @param the function's return type * @return the new CompletableFuture */ public static CompletableFuture applyToEitherSuccess( - CompletionStage cf1, CompletionStage cf2, Function fn) { - final CompletionStage[] css = requireCfsAndEleNonNull(cf1, cf2); + CompletableFuture cfThis, CompletionStage other, Function fn) { + final CompletionStage[] css = requireCfsAndEleNonNull(cfThis, other); requireNonNull(fn, "fn is null"); - return anyOfSuccess(css).thenApply(fn); + return anySuccessOf(css).thenApply(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. - *

- * This method is the same as {@link CompletionStage#applyToEitherAsync(CompletionStage, Function)} - * except for the either-success behavior instead of either-complete. * * @param fn the function to use to compute the value of the returned CompletableFuture * @param the function's return type * @return the new CompletableFuture */ public static CompletableFuture applyToEitherSuccessAsync( - CompletionStage cf1, CompletionStage cf2, Function fn) { - return applyToEitherSuccessAsync(cf1, cf2, fn, AsyncPoolHolder.ASYNC_POOL); + CompletableFuture cfThis, CompletionStage other, Function fn) { + return applyToEitherSuccessAsync(cfThis, other, fn, AsyncPoolHolder.ASYNC_POOL); } /** * 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. - *

- * This method is the same as {@link CompletionStage#applyToEitherAsync(CompletionStage, Function, Executor)} - * except for the either-success behavior instead of either-complete. * * @param fn the function to use to compute the value of the returned CompletableFuture * @param executor the executor to use for asynchronous execution @@ -2707,68 +2609,59 @@ public static CompletableFuture applyToEitherSuccessAsync( * @return the new CompletableFuture */ public static CompletableFuture applyToEitherSuccessAsync( - CompletionStage cf1, CompletionStage cf2, + CompletableFuture cfThis, CompletionStage other, Function fn, Executor executor) { - final CompletionStage[] css = requireCfsAndEleNonNull(cf1, cf2); + final CompletionStage[] css = requireCfsAndEleNonNull(cfThis, other); requireNonNull(fn, "fn is null"); requireNonNull(executor, "executor is null"); - return anyOfSuccess(css).thenApplyAsync(fn, executor); + return anySuccessOf(css).thenApplyAsync(fn, executor); } /** * Returns a new CompletableFuture that, when either given stage success, * is executed with the corresponding result as argument to the supplied action. - *

- * This method is the same as {@link CompletionStage#acceptEither(CompletionStage, Consumer)} - * except for the either-success behavior instead of either-complete. * * @param action the action to perform before completing the returned CompletableFuture * @return the new CompletableFuture */ public static CompletableFuture acceptEitherSuccess( - CompletionStage cf1, CompletionStage cf2, Consumer action) { - final CompletionStage[] css = requireCfsAndEleNonNull(cf1, cf2); + CompletableFuture cfThis, CompletionStage other, Consumer action) { + final CompletionStage[] css = requireCfsAndEleNonNull(cfThis, other); requireNonNull(action, "action is null"); - return anyOfSuccess(css).thenAccept(action); + return anySuccessOf(css).thenAccept(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. - *

- * This method is the same as {@link CompletionStage#acceptEitherAsync(CompletionStage, Consumer)} - * except for the either-success behavior instead of either-complete. * * @param action the action to perform before completing the returned CompletableFuture * @return the new CompletableFuture */ public static CompletableFuture acceptEitherSuccessAsync( - CompletionStage cf1, CompletionStage cf2, Consumer action) { - return acceptEitherSuccessAsync(cf1, cf2, action, AsyncPoolHolder.ASYNC_POOL); + CompletableFuture cfThis, CompletionStage other, Consumer action) { + return acceptEitherSuccessAsync(cfThis, other, action, AsyncPoolHolder.ASYNC_POOL); } /** * 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. - *

- * This method is the same as {@link CompletionStage#acceptEitherAsync(CompletionStage, Consumer, Executor)} - * except for the either-success behavior instead of either-complete. * * @param action the action to perform before completing the returned CompletableFuture * @param executor the executor to use for asynchronous execution * @return the new CompletableFuture */ public static CompletableFuture acceptEitherSuccessAsync( - CompletionStage cf1, CompletionStage cf2, + CompletableFuture cfThis, CompletionStage other, Consumer action, Executor executor) { - final CompletionStage[] css = requireCfsAndEleNonNull(cf1, cf2); + final CompletionStage[] css = requireCfsAndEleNonNull(cfThis, other); requireNonNull(action, "action is null"); requireNonNull(executor, "executor is null"); - return anyOfSuccess(css).thenAcceptAsync(action, executor); + return anySuccessOf(css).thenAcceptAsync(action, executor); } /** @@ -2776,19 +2669,16 @@ public static CompletableFuture acceptEitherSuccessAsync( * 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. - *

- * This method is the same as {@link CompletionStage#runAfterEither(CompletionStage, Runnable)} - * except for the either-success behavior instead of either-complete. * * @param action the action to perform before completing the returned CompletableFuture * @return the new CompletableFuture */ public static CompletableFuture runAfterEitherSuccess( - CompletionStage cf1, CompletionStage cf2, Runnable action) { - final CompletionStage[] css = requireCfsAndEleNonNull(cf1, cf2); + CompletableFuture cfThis, CompletionStage other, Runnable action) { + final CompletionStage[] css = requireCfsAndEleNonNull(cfThis, other); requireNonNull(action, "action is null"); - return anyOfSuccess(css).thenRun(action); + return anySuccessOf(css).thenRun(action); } /** @@ -2797,16 +2687,13 @@ public static CompletableFuture runAfterEitherSuccess( * 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. - *

- * This method is the same as {@link CompletionStage#runAfterEitherAsync(CompletionStage, Runnable)} - * except for the either-success behavior instead of either-complete. * * @param action the action to perform before completing the returned CompletableFuture * @return the new CompletableFuture */ public static CompletableFuture runAfterEitherSuccessAsync( - CompletionStage cf1, CompletionStage cf2, Runnable action) { - return runAfterEitherSuccessAsync(cf1, cf2, action, AsyncPoolHolder.ASYNC_POOL); + CompletableFuture cfThis, CompletionStage other, Runnable action) { + return runAfterEitherSuccessAsync(cfThis, other, action, AsyncPoolHolder.ASYNC_POOL); } /** @@ -2815,20 +2702,17 @@ public static CompletableFuture runAfterEitherSuccessAsync( * 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. - *

- * This method is the same as {@link CompletionStage#runAfterEitherAsync(CompletionStage, Runnable, Executor)} - * except for the either-success behavior instead of either-complete. * * @param action the action to perform before completing the returned CompletableFuture * @return the new CompletableFuture */ public static CompletableFuture runAfterEitherSuccessAsync( - CompletionStage cf1, CompletionStage cf2, Runnable action, Executor executor) { - final CompletionStage[] css = requireCfsAndEleNonNull(cf1, cf2); + CompletableFuture cfThis, CompletionStage other, Runnable action, Executor executor) { + final CompletionStage[] css = requireCfsAndEleNonNull(cfThis, other); requireNonNull(action, "action is null"); requireNonNull(executor, "executor is null"); - return anyOfSuccess(css).thenRunAsync(action, executor); + return anySuccessOf(css).thenRunAsync(action, executor); } // endregion @@ -3240,13 +3124,13 @@ C peekAsync(C cf, BiConsumer action, Executor exec */ @Blocking @Nullable - public static T join(CompletableFuture cf, long timeout, TimeUnit unit) { - requireNonNull(cf, "cf is null"); + public static T join(CompletableFuture cfThis, long timeout, TimeUnit unit) { + requireNonNull(cfThis, "cf is null"); requireNonNull(unit, "unit is null"); - if (cf.isDone()) return cf.join(); + if (cfThis.isDone()) return cfThis.join(); // defensive copy input cf to avoid writing it by `orTimeout` - return orTimeout(copy(cf), timeout, unit).join(); + return orTimeout(copy(cfThis), timeout, unit).join(); } /** @@ -3260,10 +3144,10 @@ public static T join(CompletableFuture cf, long timeout, TimeUnit unit) { */ @Contract(pure = true) @Nullable - public static T getSuccessNow(CompletableFuture cf, @Nullable T valueIfNotSuccess) { - requireNonNull(cf, "cf is null"); + public static T getSuccessNow(CompletableFuture cfThis, @Nullable T valueIfNotSuccess) { + requireNonNull(cfThis, "cf is null"); // NOTE: No need check minimal stage, since checked at cf.isDone() - return cf.isDone() && !cf.isCompletedExceptionally() ? cf.join() : valueIfNotSuccess; + return cfThis.isDone() && !cfThis.isCompletedExceptionally() ? cfThis.join() : valueIfNotSuccess; } /** @@ -3284,22 +3168,22 @@ public static T getSuccessNow(CompletableFuture cf, @Nullable T */ @Contract(pure = true) @Nullable - public static T resultNow(Future cf) { - requireNonNull(cf, "cf is null"); + public static T resultNow(Future cfThis) { + requireNonNull(cfThis, "cf is null"); if (IS_JAVA19_PLUS) { - return cf.resultNow(); + return cfThis.resultNow(); } // below code is copied from Future.resultNow - if (!cf.isDone()) throw new IllegalStateException("Task has not completed"); - if (cf.isCancelled()) throw new IllegalStateException("Task was cancelled"); + if (!cfThis.isDone()) throw new IllegalStateException("Task has not completed"); + if (cfThis.isCancelled()) throw new IllegalStateException("Task was cancelled"); // simple path for CompletableFuture/Cffu - if (cf instanceof CompletableFuture) { - if (((CompletableFuture) cf).isCompletedExceptionally()) + if (cfThis instanceof CompletableFuture) { + if (((CompletableFuture) cfThis).isCompletedExceptionally()) throw new IllegalStateException("Task completed with exception"); - } else if (cf instanceof Cffu) { - if (((Cffu) cf).isCompletedExceptionally()) + } else if (cfThis instanceof Cffu) { + if (((Cffu) cfThis).isCompletedExceptionally()) throw new IllegalStateException("Task completed with exception"); } @@ -3307,7 +3191,7 @@ public static T resultNow(Future cf) { try { while (true) { try { - return cf.get(); + return cfThis.get(); } catch (InterruptedException e) { interrupted = true; } catch (ExecutionException e) { @@ -3331,22 +3215,22 @@ public static T resultNow(Future cf) { * or the task was cancelled */ @Contract(pure = true) - public static Throwable exceptionNow(Future cf) { - requireNonNull(cf, "cf is null"); + public static Throwable exceptionNow(Future cfThis) { + requireNonNull(cfThis, "cf is null"); if (IS_JAVA19_PLUS) { - return cf.exceptionNow(); + return cfThis.exceptionNow(); } // below code is copied from Future.exceptionNow - if (!cf.isDone()) throw new IllegalStateException("Task has not completed"); - if (cf.isCancelled()) throw new IllegalStateException("Task was cancelled"); + if (!cfThis.isDone()) throw new IllegalStateException("Task has not completed"); + if (cfThis.isCancelled()) throw new IllegalStateException("Task was cancelled"); boolean interrupted = false; try { while (true) { try { - cf.get(); + cfThis.get(); throw new IllegalStateException("Task completed with a result"); } catch (InterruptedException e) { interrupted = true; @@ -3367,23 +3251,23 @@ public static Throwable exceptionNow(Future cf) { * @see Future#state() */ @Contract(pure = true) - public static CffuState state(Future cf) { - requireNonNull(cf, "cf is null"); + public static CffuState state(Future cfThis) { + requireNonNull(cfThis, "cf is null"); if (IS_JAVA19_PLUS) { - return CffuState.toCffuState(cf.state()); + return CffuState.toCffuState(cfThis.state()); } // below code is copied from Future#state() with small adoption - if (!cf.isDone()) return CffuState.RUNNING; - if (cf.isCancelled()) return CffuState.CANCELLED; + if (!cfThis.isDone()) return CffuState.RUNNING; + if (cfThis.isCancelled()) return CffuState.CANCELLED; // simple path for CompletableFuture/Cffu - if (cf instanceof CompletableFuture) { - if (((CompletableFuture) cf).isCompletedExceptionally()) + if (cfThis instanceof CompletableFuture) { + if (((CompletableFuture) cfThis).isCompletedExceptionally()) return CffuState.FAILED; else return CffuState.SUCCESS; - } else if (cf instanceof Cffu) { - if (((Cffu) cf).isCompletedExceptionally()) + } else if (cfThis instanceof Cffu) { + if (((Cffu) cfThis).isCompletedExceptionally()) return CffuState.FAILED; else return CffuState.SUCCESS; } @@ -3392,7 +3276,7 @@ public static CffuState state(Future cf) { try { while (true) { try { - cf.get(); // may throw InterruptedException when done + cfThis.get(); // may throw InterruptedException when done return CffuState.SUCCESS; } catch (InterruptedException e) { interrupted = true; @@ -3499,12 +3383,12 @@ C completeExceptionallyAsync(C cf, Supplier supplier, Execu * @see CompletableFuture#minimalCompletionStage() */ @Contract(pure = true) - public static CompletionStage minimalCompletionStage(CompletableFuture cf) { - requireNonNull(cf, "cf is null"); + public static CompletionStage minimalCompletionStage(CompletableFuture cfThis) { + requireNonNull(cfThis, "cf is null"); if (IS_JAVA9_PLUS) { - return cf.minimalCompletionStage(); + return cfThis.minimalCompletionStage(); } - return cf.thenApply(x -> x); + return cfThis.thenApply(x -> x); } /** @@ -3518,12 +3402,12 @@ public static CompletionStage minimalCompletionStage(CompletableFuture * @see CompletableFuture#copy() */ @Contract(pure = true) - public static CompletableFuture copy(CompletableFuture cf) { - requireNonNull(cf, "cf is null"); + public static CompletableFuture copy(CompletableFuture cfThis) { + requireNonNull(cfThis, "cf is null"); if (IS_JAVA9_PLUS) { - return cf.copy(); + return cfThis.copy(); } - return cf.thenApply(x -> x); + return cfThis.thenApply(x -> x); } /** @@ -3534,10 +3418,10 @@ public static CompletableFuture copy(CompletableFuture cf) { * @see CompletableFuture#newIncompleteFuture() */ @Contract(pure = true) - public static CompletableFuture newIncompleteFuture(CompletableFuture cf) { - requireNonNull(cf, "cf is null"); + public static CompletableFuture newIncompleteFuture(CompletableFuture cfThis) { + requireNonNull(cfThis, "cf is null"); if (IS_JAVA9_PLUS) { - return cf.newIncompleteFuture(); + return cfThis.newIncompleteFuture(); } return new CompletableFuture<>(); } diff --git a/cffu-core/src/main/java/io/foldright/cffu/NoCfsProvidedException.java b/cffu-core/src/main/java/io/foldright/cffu/NoCfsProvidedException.java index 975235ac..110cc24c 100644 --- a/cffu-core/src/main/java/io/foldright/cffu/NoCfsProvidedException.java +++ b/cffu-core/src/main/java/io/foldright/cffu/NoCfsProvidedException.java @@ -8,8 +8,8 @@ * Exception indicates that NO cfs({@link Cffu} / {@link CompletableFuture}) are provided * for methods require cf arguments. * - * @see CffuFactory#anyOfSuccess(CompletionStage[]) - * @see CompletableFutureUtils#anyOfSuccess(CompletionStage[]) + * @see CffuFactory#anySuccessOf(CompletionStage[]) + * @see CompletableFutureUtils#anySuccessOf(CompletionStage[]) */ @SuppressWarnings("serial") public class NoCfsProvidedException extends RuntimeException { diff --git a/cffu-core/src/test/java/io/foldright/cffu/CffuFactoryTest.java b/cffu-core/src/test/java/io/foldright/cffu/CffuFactoryTest.java index 0916f819..35fb0cc2 100644 --- a/cffu-core/src/test/java/io/foldright/cffu/CffuFactoryTest.java +++ b/cffu-core/src/test/java/io/foldright/cffu/CffuFactoryTest.java @@ -18,11 +18,6 @@ import java.util.function.Supplier; import static io.foldright.cffu.CompletableFutureUtils.failedFuture; -import static io.foldright.cffu.CompletableFutureUtils.mRunAsync; -import static io.foldright.cffu.CompletableFutureUtils.mRunFastFailAsync; -import static io.foldright.cffu.CompletableFutureUtils.mSupplyAsync; -import static io.foldright.cffu.CompletableFutureUtils.mSupplyFastFailAsync; -import static io.foldright.cffu.CompletableFutureUtils.mSupplyMostSuccessAsync; import static io.foldright.cffu.CompletableFutureUtils.toCompletableFutureArray; import static io.foldright.test_utils.TestUtils.*; import static java.util.concurrent.CompletableFuture.completedFuture; @@ -214,13 +209,13 @@ void test_allOf_CompletableFuture() throws Exception { //////////////////////////////////////// - cffuFactory.allOfFastFail(completedFuture(n), completedFuture(anotherN)).get(); - cffuFactory.allOfFastFail(completedFuture(anotherN)).get(); + cffuFactory.allFastFailOf(completedFuture(n), completedFuture(anotherN)).get(); + cffuFactory.allFastFailOf(completedFuture(anotherN)).get(); - assertNull(cffuFactory.allOfFastFail().get()); + assertNull(cffuFactory.allFastFailOf().get()); - cffuFactory.allOfFastFail(cffuFactory.completedFuture(n), cffuFactory.completedFuture(anotherN)).get(); - cffuFactory.allOfFastFail(cffuFactory.completedFuture(anotherN)).get(); + cffuFactory.allFastFailOf(cffuFactory.completedFuture(n), cffuFactory.completedFuture(anotherN)).get(); + cffuFactory.allFastFailOf(cffuFactory.completedFuture(anotherN)).get(); } @Test @@ -232,18 +227,18 @@ void test_anyOf_CompletableFuture() throws Exception { //////////////////////////////////////// - cffuFactory.anyOfSuccess(completedFuture(n), completedFuture(anotherN)).get(); - assertEquals(anotherN, cffuFactory.anyOfSuccess(completedFuture(anotherN)).get()); + cffuFactory.anySuccessOf(completedFuture(n), completedFuture(anotherN)).get(); + assertEquals(anotherN, cffuFactory.anySuccessOf(completedFuture(anotherN)).get()); assertInstanceOf(NoCfsProvidedException.class, assertThrowsExactly(ExecutionException.class, () -> - cffuFactory.anyOfSuccess().get() + cffuFactory.anySuccessOf().get() ).getCause()); - cffuFactory.anyOfSuccess( + cffuFactory.anySuccessOf( cffuFactory.completedFuture(n), cffuFactory.completedFuture(anotherN) ).get(); - assertEquals(anotherN, cffuFactory.anyOfSuccess( + assertEquals(anotherN, cffuFactory.anySuccessOf( cffuFactory.completedFuture(anotherN) ).get()); } @@ -286,21 +281,21 @@ void test_allResultsOf() throws Exception { //////////////////////////////////////// assertEquals(Arrays.asList(n, n + 1), - cffuFactory.allResultsOfFastFail(completedFuture(n), completedFuture(n + 1)).get() + cffuFactory.allResultsFastFailOf(completedFuture(n), completedFuture(n + 1)).get() ); assertEquals(Collections.singletonList(n), - cffuFactory.allResultsOfFastFail(completedFuture(n)).get() + cffuFactory.allResultsFastFailOf(completedFuture(n)).get() ); assertEquals(Collections.emptyList(), - cffuFactory.allResultsOfFastFail().get() + cffuFactory.allResultsFastFailOf().get() ); assertEquals(Arrays.asList(n, n + 1), - cffuFactory.allResultsOfFastFail(cffuFactory.completedFuture(n), cffuFactory.completedFuture(n + 1)).get() + cffuFactory.allResultsFastFailOf(cffuFactory.completedFuture(n), cffuFactory.completedFuture(n + 1)).get() ); assertEquals(Collections.singletonList(n), - cffuFactory.allResultsOfFastFail(cffuFactory.completedFuture(n)).get() + cffuFactory.allResultsFastFailOf(cffuFactory.completedFuture(n)).get() ); } @@ -315,7 +310,7 @@ void test_allResultsOf_exceptionally() throws Exception { ).getCause()); assertSame(rte, assertThrowsExactly(ExecutionException.class, () -> - cffuFactory.allResultsOfFastFail( + cffuFactory.allResultsFastFailOf( cffuFactory.completedFuture(n), cffuFactory.failedFuture(rte), cffuFactory.completedFuture(s) @@ -331,21 +326,21 @@ void test_mostOf() throws Exception { final Cffu cancelled = cffuFactory.toCffu(createCancelledFuture()); final Cffu incomplete = cffuFactory.toCffu(createIncompleteFuture()); - assertEquals(0, cffuFactory.mostResultsOfSuccess(null, 10, TimeUnit.MILLISECONDS).get().size()); + assertEquals(0, cffuFactory.mostSuccessResultsOf(null, 10, TimeUnit.MILLISECONDS).get().size()); - assertEquals(Arrays.asList(n, null, null, null), cffuFactory.mostResultsOfSuccess( + assertEquals(Arrays.asList(n, null, null, null), cffuFactory.mostSuccessResultsOf( null, 10, TimeUnit.MILLISECONDS, completed, failed, cancelled, incomplete ).get()); - assertEquals(Arrays.asList(n, anotherN, anotherN, anotherN), cffuFactory.mostResultsOfSuccess( + assertEquals(Arrays.asList(n, anotherN, anotherN, anotherN), cffuFactory.mostSuccessResultsOf( anotherN, 10, TimeUnit.MILLISECONDS, completedStage, failed, cancelled, incomplete ).get()); - assertEquals(Arrays.asList(anotherN, anotherN, anotherN), cffuFactory.mostResultsOfSuccess( + assertEquals(Arrays.asList(anotherN, anotherN, anotherN), cffuFactory.mostSuccessResultsOf( anotherN, 10, TimeUnit.MILLISECONDS, failed, cancelled, incomplete ).get()); // do not wait for failed and cancelled - assertEquals(Arrays.asList(anotherN, anotherN), cffuFactory.mostResultsOfSuccess( + assertEquals(Arrays.asList(anotherN, anotherN), cffuFactory.mostSuccessResultsOf( anotherN, 10, TimeUnit.DAYS, failed, cancelled ).get()); } @@ -372,16 +367,16 @@ void test_anyOf() throws Exception { //////////////////////////////////////// - assertEquals(n, cffuFactory.anyOfSuccess(createIncompleteFuture(), completedFuture(n)).get()); - assertEquals(n, cffuFactory.anyOfSuccess(completedFuture(n)).get()); + assertEquals(n, cffuFactory.anySuccessOf(createIncompleteFuture(), completedFuture(n)).get()); + assertEquals(n, cffuFactory.anySuccessOf(completedFuture(n)).get()); - assertSame(NoCfsProvidedException.class, cffuFactory.anyOfSuccess().exceptionNow().getClass()); + assertSame(NoCfsProvidedException.class, cffuFactory.anySuccessOf().exceptionNow().getClass()); - assertEquals(n, cffuFactory.anyOfSuccess( + assertEquals(n, cffuFactory.anySuccessOf( cffuFactory.completedFuture(n), cffuFactory.newIncompleteCffu() ).get()); - assertEquals(n, cffuFactory.anyOfSuccess(cffuFactory.completedFuture(n)).get()); + assertEquals(n, cffuFactory.anySuccessOf(cffuFactory.completedFuture(n)).get()); } @Test @@ -404,9 +399,9 @@ void test_anyOf_exceptionally() throws Exception { } @Test - void test_anyOfSuccess__trivial_case() throws Exception { + void test_anySuccessOf__trivial_case() throws Exception { // success then success - assertEquals(n, cffuFactory.anyOfSuccess( + assertEquals(n, cffuFactory.anySuccessOf( cffuFactory.newIncompleteCffu(), cffuFactory.newIncompleteCffu(), cffuFactory.supplyAsync(() -> { @@ -416,7 +411,7 @@ void test_anyOfSuccess__trivial_case() throws Exception { cffuFactory.completedFuture(n) ).get()); // success then failed - assertEquals(n, cffuFactory.anyOfSuccess( + assertEquals(n, cffuFactory.anySuccessOf( cffuFactory.newIncompleteCffu(), cffuFactory.newIncompleteCffu(), cffuFactory.supplyAsync(() -> { @@ -427,7 +422,7 @@ void test_anyOfSuccess__trivial_case() throws Exception { ).get()); // all success - assertEquals(n, cffuFactory.anyOfSuccess( + assertEquals(n, cffuFactory.anySuccessOf( cffuFactory.supplyAsync(() -> { sleep(300); return anotherN; @@ -442,7 +437,7 @@ void test_anyOfSuccess__trivial_case() throws Exception { ////////////////////////////////////////////////////////////////////////////// // success then success - assertEquals(n, cffuFactory.anyOfSuccess( + assertEquals(n, cffuFactory.anySuccessOf( createIncompleteFuture(), createIncompleteFuture(), CompletableFuture.supplyAsync(() -> { @@ -452,7 +447,7 @@ void test_anyOfSuccess__trivial_case() throws Exception { completedFuture(n) ).get()); // success then failed - assertEquals(n, cffuFactory.anyOfSuccess( + assertEquals(n, cffuFactory.anySuccessOf( createIncompleteFuture(), createIncompleteFuture(), CompletableFuture.supplyAsync(() -> { @@ -463,7 +458,7 @@ void test_anyOfSuccess__trivial_case() throws Exception { ).get()); // all success - assertEquals(n, cffuFactory.anyOfSuccess( + assertEquals(n, cffuFactory.anySuccessOf( CompletableFuture.supplyAsync(() -> { sleep(300); return anotherN; @@ -477,7 +472,7 @@ void test_anyOfSuccess__trivial_case() throws Exception { ////////////////////////////////////////////////////////////////////////////// - assertSame(NoCfsProvidedException.class, cffuFactory.anyOfSuccess().exceptionNow().getClass()); + assertSame(NoCfsProvidedException.class, cffuFactory.anySuccessOf().exceptionNow().getClass()); } //////////////////////////////////////////////////////////////////////////////// @@ -564,26 +559,26 @@ void test_allTupleOf_exceptionally() throws Exception { } @Test - void test_allTupleOfFastFail() throws Exception { - assertEquals(Tuple2.of(n, s), cffuFactory.allTupleOfFastFail( + void test_allTupleFastFailOf() throws Exception { + assertEquals(Tuple2.of(n, s), cffuFactory.allTupleFastFailOf( completedFuture(n), completedFuture(s) ).get()); - assertEquals(Tuple3.of(n, s, d), cffuFactory.allTupleOfFastFail( + assertEquals(Tuple3.of(n, s, d), cffuFactory.allTupleFastFailOf( completedFuture(n), completedFuture(s), completedFuture(d) ).get()); - assertEquals(Tuple4.of(n, s, d, anotherN), cffuFactory.allTupleOfFastFail( + assertEquals(Tuple4.of(n, s, d, anotherN), cffuFactory.allTupleFastFailOf( completedFuture(n), completedFuture(s), completedFuture(d), completedFuture(anotherN) ).get()); - assertEquals(Tuple5.of(n, s, d, anotherN, n + n), cffuFactory.allTupleOfFastFail( + assertEquals(Tuple5.of(n, s, d, anotherN, n + n), cffuFactory.allTupleFastFailOf( completedFuture(n), completedFuture(s), completedFuture(d), @@ -593,25 +588,25 @@ void test_allTupleOfFastFail() throws Exception { //////////////////////////////////////////////////////////////////////////////// - assertEquals(Tuple2.of(n, s), cffuFactory.allTupleOfFastFail( + assertEquals(Tuple2.of(n, s), cffuFactory.allTupleFastFailOf( cffuFactory.completedFuture(n), cffuFactory.completedFuture(s) ).get()); - assertEquals(Tuple3.of(n, s, d), cffuFactory.allTupleOfFastFail( + assertEquals(Tuple3.of(n, s, d), cffuFactory.allTupleFastFailOf( cffuFactory.completedFuture(n), cffuFactory.completedFuture(s), cffuFactory.completedFuture(d) ).get()); - assertEquals(Tuple4.of(n, s, d, anotherN), cffuFactory.allTupleOfFastFail( + assertEquals(Tuple4.of(n, s, d, anotherN), cffuFactory.allTupleFastFailOf( cffuFactory.completedFuture(n), cffuFactory.completedFuture(s), cffuFactory.completedFuture(d), cffuFactory.completedFuture(anotherN) ).get()); - assertEquals(Tuple5.of(n, s, d, anotherN, n + n), cffuFactory.allTupleOfFastFail( + assertEquals(Tuple5.of(n, s, d, anotherN, n + n), cffuFactory.allTupleFastFailOf( cffuFactory.completedFuture(n), cffuFactory.completedFuture(s), cffuFactory.completedFuture(d), @@ -621,17 +616,17 @@ void test_allTupleOfFastFail() throws Exception { } @Test - void test_allTupleOfFastFail_exceptionally() throws Exception { + void test_allTupleFastFail_Of_exceptionally() throws Exception { assertSame(rte, assertThrowsExactly(ExecutionException.class, () -> - cffuFactory.allTupleOfFastFail(completedFuture(n), failedFuture(rte)).get() + cffuFactory.allTupleFastFailOf(completedFuture(n), failedFuture(rte)).get() ).getCause()); assertSame(rte, assertThrowsExactly(ExecutionException.class, () -> - cffuFactory.allTupleOfFastFail(completedFuture(n), failedFuture(rte), completedFuture(s)).get() + cffuFactory.allTupleFastFailOf(completedFuture(n), failedFuture(rte), completedFuture(s)).get() ).getCause()); assertSame(rte, assertThrowsExactly(ExecutionException.class, () -> - cffuFactory.allTupleOfFastFail( + cffuFactory.allTupleFastFailOf( completedFuture(n), completedFuture(d), failedFuture(rte), @@ -642,35 +637,35 @@ void test_allTupleOfFastFail_exceptionally() throws Exception { } @Test - void test_mostTupleOfSuccess() throws Exception { + void test_mostSuccessTupleOf() throws Exception { final Cffu completed = cffuFactory.completedFuture(n); final CompletionStage anotherCompleted = cffuFactory.completedStage(s); final Cffu failed = cffuFactory.failedFuture(rte); final Cffu cancelled = cffuFactory.toCffu(createCancelledFuture()); final Cffu incomplete = cffuFactory.toCffu(createIncompleteFuture()); - assertEquals(Tuple2.of(n, s), cffuFactory.mostTupleOfSuccess( + assertEquals(Tuple2.of(n, s), cffuFactory.mostSuccessTupleOf( 10, TimeUnit.MILLISECONDS, completed, anotherCompleted ).get()); - assertEquals(Tuple2.of(n, null), cffuFactory.mostTupleOfSuccess( + assertEquals(Tuple2.of(n, null), cffuFactory.mostSuccessTupleOf( 10, TimeUnit.MILLISECONDS, completed, failed ).get()); - assertEquals(Tuple3.of(n, s, null), cffuFactory.mostTupleOfSuccess( + assertEquals(Tuple3.of(n, s, null), cffuFactory.mostSuccessTupleOf( 10, TimeUnit.MILLISECONDS, completed, anotherCompleted, cancelled ).get()); - assertEquals(Tuple3.of(null, null, s), cffuFactory.mostTupleOfSuccess( + assertEquals(Tuple3.of(null, null, s), cffuFactory.mostSuccessTupleOf( 10, TimeUnit.MILLISECONDS, incomplete, failed, anotherCompleted ).get()); - assertEquals(Tuple4.of(n, s, null, null), cffuFactory.mostTupleOfSuccess( + assertEquals(Tuple4.of(n, s, null, null), cffuFactory.mostSuccessTupleOf( 10, TimeUnit.MILLISECONDS, completed, anotherCompleted, cancelled, incomplete ).get()); - assertEquals(Tuple4.of(null, null, null, null), cffuFactory.mostTupleOfSuccess( + assertEquals(Tuple4.of(null, null, null, null), cffuFactory.mostSuccessTupleOf( 10, TimeUnit.MILLISECONDS, incomplete, failed, cancelled, incomplete ).get()); - assertEquals(Tuple5.of(null, n, s, null, null), cffuFactory.mostTupleOfSuccess( + assertEquals(Tuple5.of(null, n, s, null, null), cffuFactory.mostSuccessTupleOf( 10, TimeUnit.MILLISECONDS, cancelled, completed, anotherCompleted, incomplete, failed ).get()); } diff --git a/cffu-core/src/test/java/io/foldright/cffu/CffuTest.java b/cffu-core/src/test/java/io/foldright/cffu/CffuTest.java index f9229314..fb14faed 100644 --- a/cffu-core/src/test/java/io/foldright/cffu/CffuTest.java +++ b/cffu-core/src/test/java/io/foldright/cffu/CffuTest.java @@ -52,12 +52,12 @@ void test_thenMApply() throws Exception { final long tick = System.currentTimeMillis(); @SuppressWarnings("unchecked") Cffu[] cfs = new Cffu[]{ - completed.thenMApplyFastFailAsync(completed, function_n, function_n), - completed.thenMApplyFastFailAsync(completed, executorService, function_n, function_n), - completed.thenMApplyMostSuccessAsync(completed, 100, 500, TimeUnit.MILLISECONDS, function_n, function_n), - completed.thenMApplyMostSuccessAsync(completed, 100, executorService, 500, TimeUnit.MILLISECONDS, function_n, function_n), - completed.thenMApplyAsync(completed, function_n, function_n), - completed.thenMApplyAsync(completed, executorService, function_n, function_n) + completed.thenMApplyFastFailAsync(function_n, function_n), + completed.thenMApplyFastFailAsync(executorService, function_n, function_n), + completed.thenMApplyMostSuccessAsync(100, 500, TimeUnit.MILLISECONDS, function_n, function_n), + completed.thenMApplyMostSuccessAsync(100, executorService, 500, TimeUnit.MILLISECONDS, function_n, function_n), + completed.thenMApplyAsync(function_n, function_n), + completed.thenMApplyAsync(executorService, function_n, function_n) }; assertTrue(System.currentTimeMillis() - tick < 50); @@ -78,10 +78,10 @@ void test_thenMAccept() throws Exception { @SuppressWarnings("unchecked") Cffu>[] cfs = new Cffu[]{ - completed.thenMAcceptAsync(completed, consumer, consumer), - completed.thenMAcceptAsync(completed, executorService, consumer, consumer), - completed.thenMAcceptFastFailAsync(completed, consumer, consumer), - completed.thenMAcceptFastFailAsync(completed, executorService, consumer, consumer) + completed.thenMAcceptAsync(consumer, consumer), + completed.thenMAcceptAsync(executorService, consumer, consumer), + completed.thenMAcceptFastFailAsync(consumer, consumer), + completed.thenMAcceptFastFailAsync(executorService, consumer, consumer) }; assertTrue(System.currentTimeMillis() - tick < 50); @@ -101,10 +101,10 @@ void test_thenMRun() throws Exception { @SuppressWarnings("unchecked") Cffu>[] cfs = new Cffu[]{ - completed.thenMRunAsync(completed, runnable, runnable), - completed.thenMRunAsync(completed, executorService, runnable, runnable), - completed.thenMRunFastFailAsync(completed, runnable, runnable), - completed.thenMRunFastFailAsync(completed, executorService, runnable, runnable) + completed.thenMRunAsync(runnable, runnable), + completed.thenMRunAsync(executorService, runnable, runnable), + completed.thenMRunFastFailAsync(runnable, runnable), + completed.thenMRunFastFailAsync(executorService, runnable, runnable) }; assertTrue(System.currentTimeMillis() - tick < 50); diff --git a/cffu-core/src/test/java/io/foldright/cffu/CompletableFutureUtilsTest.java b/cffu-core/src/test/java/io/foldright/cffu/CompletableFutureUtilsTest.java index 70cd8112..186fc96d 100644 --- a/cffu-core/src/test/java/io/foldright/cffu/CompletableFutureUtilsTest.java +++ b/cffu-core/src/test/java/io/foldright/cffu/CompletableFutureUtilsTest.java @@ -104,21 +104,21 @@ void test_allOf_methods__success__trivial_case() throws Exception { //////////////////////////////////////////////////////////////////////////////// - assertEquals(Arrays.asList(n, n + 1, n + 2), allResultsOfFastFail( + assertEquals(Arrays.asList(n, n + 1, n + 2), allResultsFastFailOf( completedStage(n), completedStage(n + 1), completedFuture(n + 2) ).get()); - assertEquals(Arrays.asList(n, n + 1), allResultsOfFastFail( + assertEquals(Arrays.asList(n, n + 1), allResultsFastFailOf( completedFuture(n), completedStage(n + 1) ).get()); - assertEquals(Collections.singletonList(n), allResultsOfFastFail(completedFuture(n)).get()); - assertEquals(Collections.singletonList(n), allResultsOfFastFail(completedStage(n)).get()); + assertEquals(Collections.singletonList(n), allResultsFastFailOf(completedFuture(n)).get()); + assertEquals(Collections.singletonList(n), allResultsFastFailOf(completedStage(n)).get()); - assertEquals(Collections.emptyList(), allResultsOfFastFail().get()); + assertEquals(Collections.emptyList(), allResultsFastFailOf().get()); //////////////////////////////////////////////////////////////////////////////// @@ -129,11 +129,11 @@ void test_allOf_methods__success__trivial_case() throws Exception { allOf(completedStage(n)), allOf(), - allOfFastFail(completedFuture(n), completedStage(n + 1), completedFuture(n + 2)), - allOfFastFail(completedStage(n), completedFuture(n + 1)), - allOfFastFail(completedFuture(n)), - allOfFastFail(completedStage(n)), - allOfFastFail() + allFastFailOf(completedFuture(n), completedStage(n + 1), completedFuture(n + 2)), + allFastFailOf(completedStage(n), completedFuture(n + 1)), + allFastFailOf(completedFuture(n)), + allFastFailOf(completedStage(n)), + allFastFailOf() ).forEach(f -> assertNull(f.join())); } @@ -202,14 +202,14 @@ void test_allOf__exceptionally() throws Exception { ); //////////////////////////////////////////////////////////////////////////////// - // allResultsOfFastFail + // allResultsFastFailOf //////////////////////////////////////////////////////////////////////////////// // all failed assertSame(rte, assertThrowsExactly(ExecutionException.class, () -> - // allResultsOfFastFail: the ex of first given cf argument win. + // allResultsFastFailOf: the ex of first given cf argument win. // ❗dependent on the implementation behavior of `CF.allOf`️ - allResultsOfFastFail( + allResultsFastFailOf( failedFuture(rte), failedFuture(anotherRte), failedFuture(ex1), @@ -219,9 +219,9 @@ void test_allOf__exceptionally() throws Exception { // all failed - concurrent assertSame(anotherRte, assertThrowsExactly(ExecutionException.class, () -> - // allResultsOfFastFail: the ex of first given cf argument win, even subsequent cf failed early. + // allResultsFastFailOf: the ex of first given cf argument win, even subsequent cf failed early. // ❗dependent on the implementation behavior of `CF.allOf`️ - allResultsOfFastFail( + allResultsFastFailOf( CompletableFuture.supplyAsync(() -> { sleep(100); throw rte; @@ -234,7 +234,7 @@ void test_allOf__exceptionally() throws Exception { // success and failed assertSame(rte, assertThrowsExactly(ExecutionException.class, () -> - allResultsOfFastFail( + allResultsFastFailOf( completedFuture(n), failedFuture(rte), completedFuture(s), @@ -244,7 +244,7 @@ void test_allOf__exceptionally() throws Exception { // failed/incomplete/failed assertSame(rte, assertThrowsExactly(ExecutionException.class, () -> - allResultsOfFastFail( + allResultsFastFailOf( completedFuture(n), failedFuture(rte), createIncompleteFuture() @@ -253,7 +253,7 @@ void test_allOf__exceptionally() throws Exception { // incomplete fail incomplete assertSame(rte, assertThrowsExactly(ExecutionException.class, () -> - allResultsOfFastFail( + allResultsFastFailOf( createIncompleteFuture(), failedFuture(rte), createIncompleteFuture() @@ -261,14 +261,14 @@ void test_allOf__exceptionally() throws Exception { ).getCause()); //////////////////////////////////////////////////////////////////////////////// - // allOfFastFail + // allFastFailOf //////////////////////////////////////////////////////////////////////////////// // all failed assertSame(rte, assertThrowsExactly(ExecutionException.class, () -> - // allOfFastFail: the ex of first complete(in time) cf argument win. + // allFastFailOf: the ex of first complete(in time) cf argument win. // ❗dependent on the implementation behavior of `CF.allOf`️ - allOfFastFail( + allFastFailOf( failedFuture(rte), failedFuture(anotherRte), failedFuture(ex1), @@ -278,9 +278,9 @@ void test_allOf__exceptionally() throws Exception { // all failed - concurrent assertSame(anotherRte, assertThrowsExactly(ExecutionException.class, () -> - // allOfFastFail: the ex of first complete(in time) cf argument win, even subsequent cf failed early. + // allFastFailOf: the ex of first complete(in time) cf argument win, even subsequent cf failed early. // ❗dependent on the implementation behavior of `CF.allOf`️ - allOfFastFail( + allFastFailOf( CompletableFuture.supplyAsync(() -> { sleep(100); throw rte; @@ -293,7 +293,7 @@ void test_allOf__exceptionally() throws Exception { // success and failed assertSame(rte, assertThrowsExactly(ExecutionException.class, () -> - allOfFastFail( + allFastFailOf( completedFuture(n), failedFuture(rte), completedFuture(s), @@ -303,7 +303,7 @@ void test_allOf__exceptionally() throws Exception { // failed/incomplete/failed assertSame(rte, assertThrowsExactly(ExecutionException.class, () -> - allOfFastFail( + allFastFailOf( completedFuture(n), failedFuture(rte), createIncompleteFuture() @@ -312,7 +312,7 @@ void test_allOf__exceptionally() throws Exception { // incomplete fail incomplete assertSame(rte, assertThrowsExactly(ExecutionException.class, () -> - allOfFastFail( + allFastFailOf( createIncompleteFuture(), failedFuture(rte), createIncompleteFuture() @@ -388,35 +388,35 @@ void test_mostOf() throws Exception { final CompletableFuture incomplete = createIncompleteFuture(); // 0 input cf - assertEquals(0, mostResultsOfSuccess(null, 10, TimeUnit.MILLISECONDS).get().size()); + assertEquals(0, mostSuccessResultsOf(null, 10, TimeUnit.MILLISECONDS).get().size()); // 1 input cf - assertEquals(Collections.singletonList(n), mostResultsOfSuccess( + assertEquals(Collections.singletonList(n), mostSuccessResultsOf( null, 10, TimeUnit.MILLISECONDS, completed).get()); - assertEquals(Collections.singletonList(n), mostResultsOfSuccess( + assertEquals(Collections.singletonList(n), mostSuccessResultsOf( anotherN, 10, TimeUnit.MILLISECONDS, completedStage).get()); - assertEquals(Collections.singletonList(anotherN), mostResultsOfSuccess( + assertEquals(Collections.singletonList(anotherN), mostSuccessResultsOf( anotherN, 10, TimeUnit.MILLISECONDS, failed).get()); - assertEquals(Collections.singletonList(anotherN), mostResultsOfSuccess( + assertEquals(Collections.singletonList(anotherN), mostSuccessResultsOf( anotherN, 10, TimeUnit.MILLISECONDS, cancelled).get()); - assertEquals(Collections.singletonList(anotherN), mostResultsOfSuccess( + assertEquals(Collections.singletonList(anotherN), mostSuccessResultsOf( anotherN, 10, TimeUnit.MILLISECONDS, incomplete).get()); // more input cf - assertEquals(Arrays.asList(n, null, null, null), mostResultsOfSuccess( + assertEquals(Arrays.asList(n, null, null, null), mostSuccessResultsOf( null, 10, TimeUnit.MILLISECONDS, completed, failed, cancelled, incomplete ).get()); - assertEquals(Arrays.asList(n, anotherN, anotherN, anotherN), mostResultsOfSuccess( + assertEquals(Arrays.asList(n, anotherN, anotherN, anotherN), mostSuccessResultsOf( anotherN, 10, TimeUnit.MILLISECONDS, completedStage, failed, cancelled, incomplete ).get()); - assertEquals(Arrays.asList(anotherN, anotherN, anotherN), mostResultsOfSuccess( + assertEquals(Arrays.asList(anotherN, anotherN, anotherN), mostSuccessResultsOf( anotherN, 10, TimeUnit.MILLISECONDS, failed, cancelled, incomplete ).get()); // do not wait for failed and cancelled - assertEquals(Arrays.asList(anotherN, anotherN), mostResultsOfSuccess( + assertEquals(Arrays.asList(anotherN, anotherN), mostSuccessResultsOf( anotherN, 10, TimeUnit.DAYS, failed, cancelled ).get()); } @@ -426,10 +426,10 @@ void test_mostOf_wontModifyInputCf() throws Exception { final CompletableFuture incomplete = createIncompleteFuture(); final CompletableFuture incomplete2 = createIncompleteFuture(); - assertEquals(Collections.singletonList(null), mostResultsOfSuccess( + assertEquals(Collections.singletonList(null), mostSuccessResultsOf( null, 10, TimeUnit.MILLISECONDS, incomplete ).get()); - assertEquals(Arrays.asList(null, null), mostResultsOfSuccess( + assertEquals(Arrays.asList(null, null), mostSuccessResultsOf( null, 10, TimeUnit.MILLISECONDS, incomplete, incomplete2 ).get()); @@ -442,7 +442,7 @@ void test_mostOf_wontModifyInputCf() throws Exception { //////////////////////////////////////////////////////////////////////////////// @Test - void test_anyOf__success__trivial_case() throws Exception { + void test_anySuccessOf__trivial_case() throws Exception { assertEquals(n, anyOf( completedFuture(n), completedStage(n + 1), @@ -473,30 +473,30 @@ void test_anyOf__success__trivial_case() throws Exception { //////////////////////////////////////// - assertEquals(n, anyOfSuccess( + assertEquals(n, anySuccessOf( completedFuture(n), completedStage(n + 1), completedFuture(n + 2) ).get()); - assertEquals(n, anyOfSuccess( + assertEquals(n, anySuccessOf( completedStage(n), completedFuture(n + 1) ).get()); - assertEquals(n, anyOfSuccess(completedFuture(n)).get()); - assertEquals(n, anyOfSuccess(completedStage(n)).get()); + assertEquals(n, anySuccessOf(completedFuture(n)).get()); + assertEquals(n, anySuccessOf(completedStage(n)).get()); assertInstanceOf(NoCfsProvidedException.class, assertThrowsExactly(ExecutionException.class, () -> - anyOfSuccess().get() + anySuccessOf().get() ).getCause()); // success with incomplete CF - assertEquals(n, anyOfSuccess( + assertEquals(n, anySuccessOf( createIncompleteFuture(), createIncompleteFuture(), completedFuture(n) ).get()); - assertEquals(n, anyOfSuccess( + assertEquals(n, anySuccessOf( createIncompleteFuture(), createIncompleteFuture(), completedStage(n) @@ -537,14 +537,14 @@ void test_anyOf__exceptionally() throws Exception { ).getCause()); //////////////////////////////////////////////////////////////////////////////// - // anyOfSuccess + // anySuccessOf //////////////////////////////////////////////////////////////////////////////// // all failed assertSame(rte, assertThrowsExactly(ExecutionException.class, () -> - // anyOfSuccess: the ex of first failed cf argument win, even subsequent cf failed early. + // anySuccessOf: the ex of first failed cf argument win, even subsequent cf failed early. // ❗dependent on the implementation behavior of `CF.allOf`️ - anyOfSuccess( + anySuccessOf( CompletableFuture.supplyAsync(() -> { sleep(100); throw rte; @@ -557,7 +557,7 @@ void test_anyOf__exceptionally() throws Exception { // incomplete fail incomplete assertThrowsExactly(TimeoutException.class, () -> - anyOfSuccess( + anySuccessOf( createIncompleteFuture(), failedFuture(rte), createIncompleteFuture() @@ -617,7 +617,7 @@ void test_anyOf__concurrent() throws Exception { //////////////////////////////////////// // incomplete/wait-success then success - assertEquals(n, anyOfSuccess( + assertEquals(n, anySuccessOf( createIncompleteFuture(), createIncompleteFuture(), CompletableFuture.supplyAsync(() -> { @@ -628,7 +628,7 @@ void test_anyOf__concurrent() throws Exception { ).get()); // wait/success then success - assertEquals(n, anyOfSuccess( + assertEquals(n, anySuccessOf( CompletableFuture.supplyAsync(() -> { sleep(300); return anotherN; @@ -641,7 +641,7 @@ void test_anyOf__concurrent() throws Exception { ).get()); // success then failed - assertEquals(n, anyOfSuccess( + assertEquals(n, anySuccessOf( createIncompleteFuture(), createIncompleteFuture(), CompletableFuture.supplyAsync(() -> { @@ -652,7 +652,7 @@ void test_anyOf__concurrent() throws Exception { ).get()); // failed then success - assertEquals(n, anyOfSuccess( + assertEquals(n, anySuccessOf( CompletableFuture.supplyAsync(() -> { sleep(100); return n; @@ -675,16 +675,16 @@ void test_allTupleOf() throws Exception { final CompletableFuture cf_nn = completedFuture(n + n); assertEquals(Tuple2.of(n, s), allTupleOf(cf_n, cf_s).get()); - assertEquals(Tuple2.of(n, s), allTupleOfFastFail(cf_n, cf_s).get()); + assertEquals(Tuple2.of(n, s), allTupleFastFailOf(cf_n, cf_s).get()); assertEquals(Tuple3.of(n, s, d), allTupleOf(cf_n, cf_s, cf_d).get()); - assertEquals(Tuple3.of(n, s, d), allTupleOfFastFail(cf_n, cf_s, cf_d).get()); + assertEquals(Tuple3.of(n, s, d), allTupleFastFailOf(cf_n, cf_s, cf_d).get()); assertEquals(Tuple4.of(n, s, d, anotherN), allTupleOf(cf_n, cf_s, cf_d, cf_an).get()); - assertEquals(Tuple4.of(n, s, d, anotherN), allTupleOfFastFail(cf_n, cf_s, cf_d, cf_an).get()); + assertEquals(Tuple4.of(n, s, d, anotherN), allTupleFastFailOf(cf_n, cf_s, cf_d, cf_an).get()); assertEquals(Tuple5.of(n, s, d, anotherN, n + n), allTupleOf(cf_n, cf_s, cf_d, cf_an, cf_nn).get()); - assertEquals(Tuple5.of(n, s, d, anotherN, n + n), allTupleOfFastFail(cf_n, cf_s, cf_d, cf_an, cf_nn).get()); + assertEquals(Tuple5.of(n, s, d, anotherN, n + n), allTupleFastFailOf(cf_n, cf_s, cf_d, cf_an, cf_nn).get()); } @Test @@ -701,28 +701,28 @@ void test_allTupleOf_exceptionally() throws Exception { allTupleOf(cf_n, fail).get() ).getCause()); assertSame(rte, assertThrowsExactly(ExecutionException.class, () -> - allTupleOfFastFail(incomplete, fail).get() + allTupleFastFailOf(incomplete, fail).get() ).getCause()); assertSame(rte, assertThrowsExactly(ExecutionException.class, () -> allTupleOf(cf_n, fail, cf_s).get() ).getCause()); assertSame(rte, assertThrowsExactly(ExecutionException.class, () -> - allTupleOfFastFail(incomplete, fail, cf_s).get() + allTupleFastFailOf(incomplete, fail, cf_s).get() ).getCause()); assertSame(rte, assertThrowsExactly(ExecutionException.class, () -> allTupleOf(cf_n, fail, cf_d, cf_s).get() ).getCause()); assertSame(rte, assertThrowsExactly(ExecutionException.class, () -> - allTupleOfFastFail(incomplete, fail, cf_d, cf_s).get() + allTupleFastFailOf(incomplete, fail, cf_d, cf_s).get() ).getCause()); assertSame(rte, assertThrowsExactly(ExecutionException.class, () -> allTupleOf(cf_n, cf_d, fail, cf_s, cf_an).get() ).getCause()); assertSame(rte, assertThrowsExactly(ExecutionException.class, () -> - allTupleOfFastFail(incomplete, cf_d, fail, cf_s, cf_an).get() + allTupleFastFailOf(incomplete, cf_d, fail, cf_s, cf_an).get() ).getCause()); } @@ -900,62 +900,62 @@ void test_thenTupleMApplyAsync() throws Exception { } @Test - void test_mostTupleOfSuccess() throws Exception { + void test_mostSuccessTupleOf() throws Exception { final CompletableFuture completed = completedFuture(n); final CompletionStage anotherCompleted = completedStage(s); final CompletableFuture failed = failedFuture(rte); final CompletableFuture cancelled = createCancelledFuture(); final CompletableFuture incomplete = createIncompleteFuture(); - assertEquals(Tuple2.of(n, s), mostTupleOfSuccess( + assertEquals(Tuple2.of(n, s), mostSuccessTupleOf( 10, TimeUnit.MILLISECONDS, completed, anotherCompleted ).get()); - assertEquals(Tuple2.of(n, null), mostTupleOfSuccess( + assertEquals(Tuple2.of(n, null), mostSuccessTupleOf( 10, TimeUnit.MILLISECONDS, completed, failed ).get()); - assertEquals(Tuple3.of(n, s, null), mostTupleOfSuccess( + assertEquals(Tuple3.of(n, s, null), mostSuccessTupleOf( 10, TimeUnit.MILLISECONDS, completed, anotherCompleted, cancelled ).get()); - assertEquals(Tuple3.of(null, null, s), mostTupleOfSuccess( + assertEquals(Tuple3.of(null, null, s), mostSuccessTupleOf( 10, TimeUnit.MILLISECONDS, incomplete, failed, anotherCompleted ).get()); - assertEquals(Tuple4.of(n, s, null, null), mostTupleOfSuccess( + assertEquals(Tuple4.of(n, s, null, null), mostSuccessTupleOf( 10, TimeUnit.MILLISECONDS, completed, anotherCompleted, cancelled, incomplete ).get()); - assertEquals(Tuple4.of(null, null, null, null), mostTupleOfSuccess( + assertEquals(Tuple4.of(null, null, null, null), mostSuccessTupleOf( 10, TimeUnit.MILLISECONDS, incomplete, failed, cancelled, incomplete ).get()); - assertEquals(Tuple5.of(null, n, s, null, null), mostTupleOfSuccess( + assertEquals(Tuple5.of(null, n, s, null, null), mostSuccessTupleOf( 10, TimeUnit.MILLISECONDS, cancelled, completed, anotherCompleted, incomplete, failed ).get()); // with `executorWhenTimeout` - assertEquals(Tuple2.of(n, s), mostTupleOfSuccess( + assertEquals(Tuple2.of(n, s), mostSuccessTupleOf( executorService, 10, TimeUnit.MILLISECONDS, completed, anotherCompleted ).get()); - assertEquals(Tuple2.of(n, null), mostTupleOfSuccess( + assertEquals(Tuple2.of(n, null), mostSuccessTupleOf( executorService, 10, TimeUnit.MILLISECONDS, completed, failed ).get()); - assertEquals(Tuple3.of(n, s, null), mostTupleOfSuccess( + assertEquals(Tuple3.of(n, s, null), mostSuccessTupleOf( executorService, 10, TimeUnit.MILLISECONDS, completed, anotherCompleted, cancelled ).get()); - assertEquals(Tuple3.of(null, null, s), mostTupleOfSuccess( + assertEquals(Tuple3.of(null, null, s), mostSuccessTupleOf( executorService, 10, TimeUnit.MILLISECONDS, incomplete, failed, anotherCompleted ).get()); - assertEquals(Tuple4.of(n, s, null, null), mostTupleOfSuccess( + assertEquals(Tuple4.of(n, s, null, null), mostSuccessTupleOf( executorService, 10, TimeUnit.MILLISECONDS, completed, anotherCompleted, cancelled, incomplete ).get()); - assertEquals(Tuple4.of(null, null, null, null), mostTupleOfSuccess( + assertEquals(Tuple4.of(null, null, null, null), mostSuccessTupleOf( executorService, 10, TimeUnit.MILLISECONDS, incomplete, failed, cancelled, incomplete ).get()); - assertEquals(Tuple5.of(null, n, s, null, null), mostTupleOfSuccess( + assertEquals(Tuple5.of(null, n, s, null, null), mostSuccessTupleOf( executorService, 10, TimeUnit.MILLISECONDS, cancelled, completed, anotherCompleted, incomplete, failed ).get()); } diff --git a/cffu-core/src/test/java/io/foldright/demo/ConcurrencyStrategyDemo.java b/cffu-core/src/test/java/io/foldright/demo/ConcurrencyStrategyDemo.java index 859de757..e8a854df 100644 --- a/cffu-core/src/test/java/io/foldright/demo/ConcurrencyStrategyDemo.java +++ b/cffu-core/src/test/java/io/foldright/demo/ConcurrencyStrategyDemo.java @@ -16,8 +16,8 @@ public class ConcurrencyStrategyDemo { public static void main(String[] args) throws Exception { //////////////////////////////////////////////////////////////////////// - // CffuFactory#allOfFastFail / allResultsOfFastFail - // CffuFactory#anyOfSuccess + // CffuFactory#allFastFailOf / allResultsFastFailOf + // CffuFactory#anySuccessOf //////////////////////////////////////////////////////////////////////// final Cffu successAfterLongTime = cffuFactory.supplyAsync(() -> { sleep(3000); // sleep LONG time @@ -26,18 +26,18 @@ public static void main(String[] args) throws Exception { final Cffu failed = cffuFactory.failedFuture(new RuntimeException("Bang!")); // Result type is Void! - Cffu cffuAll = cffuFactory.allOfFastFail(successAfterLongTime, failed); + Cffu cffuAll = cffuFactory.allFastFailOf(successAfterLongTime, failed); - Cffu> fastFailed = cffuFactory.allResultsOfFastFail(successAfterLongTime, failed); + Cffu> fastFailed = cffuFactory.allResultsFastFailOf(successAfterLongTime, failed); // fast failed without waiting successAfterLongTime System.out.println(fastFailed.exceptionNow()); - Cffu anyOfSuccess = cffuFactory.anyOfSuccess(successAfterLongTime, failed); - System.out.println(anyOfSuccess.get()); + Cffu anySuccessOf = cffuFactory.anySuccessOf(successAfterLongTime, failed); + System.out.println(anySuccessOf.get()); //////////////////////////////////////////////////////////////////////// - // or CompletableFutureUtils#allOfFastFail / allResultsOfFastFail - // CompletableFutureUtils#anyOfSuccess + // or CompletableFutureUtils#allFastFailOf / allResultsFastFailOf + // CompletableFutureUtils#anySuccessOf //////////////////////////////////////////////////////////////////////// final CompletableFuture successAfterLongTimeCf = CompletableFuture.supplyAsync(() -> { sleep(3000); // sleep LONG time @@ -46,13 +46,13 @@ public static void main(String[] args) throws Exception { final CompletableFuture failedCf = CompletableFutureUtils.failedFuture(new RuntimeException("Bang!")); // Result type is Void! - CompletableFuture cfAll = CompletableFutureUtils.allOfFastFail(successAfterLongTimeCf, failedCf); + CompletableFuture cfAll = CompletableFutureUtils.allFastFailOf(successAfterLongTimeCf, failedCf); - CompletableFuture> fastFailedCf = CompletableFutureUtils.allResultsOfFastFail(successAfterLongTimeCf, failedCf); + CompletableFuture> fastFailedCf = CompletableFutureUtils.allResultsFastFailOf(successAfterLongTimeCf, failedCf); // fast failed without waiting successAfterLongTime System.out.println(CompletableFutureUtils.exceptionNow(fastFailedCf)); - CompletableFuture cfSuccess = CompletableFutureUtils.anyOfSuccess(successAfterLongTimeCf, failedCf); + CompletableFuture cfSuccess = CompletableFutureUtils.anySuccessOf(successAfterLongTimeCf, failedCf); System.out.println(cfSuccess.get()); //////////////////////////////////////// diff --git a/cffu-kotlin/src/main/java/io/foldright/cffu/kotlin/CffuExtensions.kt b/cffu-kotlin/src/main/java/io/foldright/cffu/kotlin/CffuExtensions.kt index f5c08246..4c74a054 100644 --- a/cffu-kotlin/src/main/java/io/foldright/cffu/kotlin/CffuExtensions.kt +++ b/cffu-kotlin/src/main/java/io/foldright/cffu/kotlin/CffuExtensions.kt @@ -51,7 +51,7 @@ fun Array>.toCffu(cffuFactory: CffuFactory): Array Collection>.allResultsOfFastFailCffu(cffuFactory: CffuFactory): Cffu> = - cffuFactory.allResultsOfFastFail(*toTypedArray()) +@JvmName("allResultsFastFailOfCffuCs") +fun Collection>.allResultsFastFailOfCffu(cffuFactory: CffuFactory): Cffu> = + cffuFactory.allResultsFastFailOf(*toTypedArray()) /** * Returns a new Cffu with the results in the **same order** of the given stages arguments, @@ -136,15 +136,15 @@ fun Collection>.allResultsOfFastFailCffu(cffuFactory: * with a CompletionException holding this exception as its cause. * If no stages are provided, returns a Cffu completed with the value empty list. * - * This method is the same as [allOfFastFailCffu], except the returned Cffu contains the results of input Cffus. + * This method is the same as [allFastFailOfCffu], except the returned Cffu contains the results of input Cffus. * - * This method is the same as [CffuFactory.allResultsOfFastFail], providing this method is convenient for method chaining. + * This method is the same as [CffuFactory.allResultsFastFailOf], providing this method is convenient for method chaining. * - * @see allOfFastFailCffu - * @see CffuFactory.allResultsOfFastFail + * @see allFastFailOfCffu + * @see CffuFactory.allResultsFastFailOf */ -fun Array>.allResultsOfFastFailCffu(cffuFactory: CffuFactory): Cffu> = - cffuFactory.allResultsOfFastFail(*this) +fun Array>.allResultsFastFailOfCffu(cffuFactory: CffuFactory): Cffu> = + cffuFactory.allResultsFastFailOf(*this) /** * Returns a new Cffu with the most results in the **same order** of @@ -155,16 +155,16 @@ fun Array>.allResultsOfFastFailCffu(cffuFactory: * @param timeout how long to wait in units of `unit` * @param unit a `TimeUnit` determining how to interpret the `timeout` parameter * @param valueIfNotSuccess the value to return if not completed successfully - * @see CffuFactory.mostResultsOfSuccess - * @see CffuFactory.mostTupleOfSuccess + * @see CffuFactory.mostSuccessResultsOf + * @see CffuFactory.mostSuccessTupleOf * @see Cffu.getSuccessNow */ -fun Collection>.mostResultsOfSuccessCffu( +fun Collection>.mostSuccessResultsOfCffu( valueIfNotSuccess: T, timeout: Long, unit: TimeUnit, cffuFactory: CffuFactory = ABSENT ): Cffu> { val factory: CffuFactory = if (cffuFactory !== ABSENT) cffuFactory else firstOrNull()?.cffuFactory() ?: throw IllegalArgumentException(ERROR_MSG_FOR_COLL) - return factory.mostResultsOfSuccess(valueIfNotSuccess, timeout, unit, *toTypedArray()) + return factory.mostSuccessResultsOf(valueIfNotSuccess, timeout, unit, *toTypedArray()) } /** @@ -176,16 +176,16 @@ fun Collection>.mostResultsOfSuccessCffu( * @param timeout how long to wait in units of `unit` * @param unit a `TimeUnit` determining how to interpret the `timeout` parameter * @param valueIfNotSuccess the value to return if not completed successfully - * @see CffuFactory.mostResultsOfSuccess - * @see CffuFactory.mostTupleOfSuccess + * @see CffuFactory.mostSuccessResultsOf + * @see CffuFactory.mostSuccessTupleOf * @see Cffu.getSuccessNow */ -fun Array>.mostResultsOfSuccessCffu( +fun Array>.mostSuccessResultsOfCffu( valueIfNotSuccess: T, timeout: Long, unit: TimeUnit, cffuFactory: CffuFactory = ABSENT ): Cffu> { val factory: CffuFactory = if (cffuFactory !== ABSENT) cffuFactory else firstOrNull()?.cffuFactory() ?: throw IllegalArgumentException(ERROR_MSG_FOR_ARRAY) - return factory.mostResultsOfSuccess(valueIfNotSuccess, timeout, unit, *this) + return factory.mostSuccessResultsOf(valueIfNotSuccess, timeout, unit, *this) } /** @@ -197,15 +197,15 @@ fun Array>.mostResultsOfSuccessCffu( * @param timeout how long to wait in units of `unit` * @param unit a `TimeUnit` determining how to interpret the `timeout` parameter * @param valueIfNotSuccess the value to return if not completed successfully - * @see CffuFactory.mostResultsOfSuccess - * @see CffuFactory.mostTupleOfSuccess + * @see CffuFactory.mostSuccessResultsOf + * @see CffuFactory.mostSuccessTupleOf * @see Cffu.getSuccessNow */ -@JvmName("mostResultsOfSuccessCffuCs") -fun Collection>.mostResultsOfSuccessCffu( +@JvmName("mostSuccessResultsOfCffuCs") +fun Collection>.mostSuccessResultsOfCffu( valueIfNotSuccess: T, timeout: Long, unit: TimeUnit, cffuFactory: CffuFactory ): Cffu> = - cffuFactory.mostResultsOfSuccess(valueIfNotSuccess, timeout, unit, *toTypedArray()) + cffuFactory.mostSuccessResultsOf(valueIfNotSuccess, timeout, unit, *toTypedArray()) /** * Returns a new Cffu with the most results in the **same order** of @@ -217,14 +217,14 @@ fun Collection>.mostResultsOfSuccessCffu( * @param timeout how long to wait in units of `unit` * @param unit a `TimeUnit` determining how to interpret the `timeout` parameter * @param valueIfNotSuccess the value to return if not completed successfully - * @see CffuFactory.mostResultsOfSuccess - * @see CffuFactory.mostTupleOfSuccess + * @see CffuFactory.mostSuccessResultsOf + * @see CffuFactory.mostSuccessTupleOf * @see Cffu.getSuccessNow */ -fun Array>.mostResultsOfSuccessCffu( +fun Array>.mostSuccessResultsOfCffu( valueIfNotSuccess: T, timeout: Long, unit: TimeUnit, cffuFactory: CffuFactory ): Cffu> = - cffuFactory.mostResultsOfSuccess(valueIfNotSuccess, timeout, unit, *this) + cffuFactory.mostSuccessResultsOf(valueIfNotSuccess, timeout, unit, *this) /** * Returns a new Cffu with the results in the **same order** of the given Cffus arguments, @@ -316,18 +316,18 @@ fun Array>.allResultsOfCffu(cffuFactory: CffuFact * with a CompletionException holding this exception as its cause. * If no Cffus are provided, returns a Cffu completed with the value `null`. * - * This method is the same as [CffuFactory.allOfFastFail], providing this method is convenient for method chaining. + * This method is the same as [CffuFactory.allFastFailOf], providing this method is convenient for method chaining. * * If this collection is not empty, `cffuFactory` argument is optional, use the `cffuFactory` of the first cffu element. * If this collection is empty and no`cffuFactory` provided, throw [IllegalArgumentException]. * - * @see allResultsOfFastFailCffu - * @see CffuFactory.allOfFastFail + * @see allResultsFastFailOfCffu + * @see CffuFactory.allFastFailOf */ -fun Collection>.allOfFastFailCffu(cffuFactory: CffuFactory = ABSENT): Cffu { +fun Collection>.allFastFailOfCffu(cffuFactory: CffuFactory = ABSENT): Cffu { val factory: CffuFactory = if (cffuFactory !== ABSENT) cffuFactory else firstOrNull()?.cffuFactory() ?: throw IllegalArgumentException(ERROR_MSG_FOR_COLL) - return factory.allOfFastFail(*toTypedArray()) + return factory.allFastFailOf(*toTypedArray()) } /** @@ -339,18 +339,18 @@ fun Collection>.allOfFastFailCffu(cffuFactory: CffuFactory = ABSENT): Cf * with a CompletionException holding this exception as its cause. * If no Cffus are provided, returns a Cffu completed with the value `null`. * - * This method is the same as [CffuFactory.allOfFastFail], providing this method is convenient for method chaining. + * This method is the same as [CffuFactory.allFastFailOf], providing this method is convenient for method chaining. * * If this array is not empty, `cffuFactory` argument is optional, use the `cffuFactory` of the first cffu element. * If this array is empty and no`cffuFactory` provided, throw [IllegalArgumentException]. * - * @see allResultsOfFastFailCffu - * @see CffuFactory.allOfFastFail + * @see allResultsFastFailOfCffu + * @see CffuFactory.allFastFailOf */ -fun Array>.allOfFastFailCffu(cffuFactory: CffuFactory = ABSENT): Cffu { +fun Array>.allFastFailOfCffu(cffuFactory: CffuFactory = ABSENT): Cffu { val factory: CffuFactory = if (cffuFactory !== ABSENT) cffuFactory else firstOrNull()?.cffuFactory() ?: throw IllegalArgumentException(ERROR_MSG_FOR_ARRAY) - return factory.allOfFastFail(*this) + return factory.allFastFailOf(*this) } /** @@ -362,14 +362,14 @@ fun Array>.allOfFastFailCffu(cffuFactory: CffuFactory = ABSENT): Cff * with a CompletionException holding this exception as its cause. * If no stages are provided, returns a Cffu completed with the value `null`. * - * This method is the same as [CffuFactory.allOfFastFail], providing this method is convenient for method chaining. + * This method is the same as [CffuFactory.allFastFailOf], providing this method is convenient for method chaining. * - * @see allResultsOfFastFailCffu - * @see CffuFactory.allOfFastFail + * @see allResultsFastFailOfCffu + * @see CffuFactory.allFastFailOf */ -@JvmName("allOfFastFailCffuCs") -fun Collection>.allOfFastFailCffu(cffuFactory: CffuFactory): Cffu = - cffuFactory.allOfFastFail(*toTypedArray()) +@JvmName("allFastFailOfCffuCs") +fun Collection>.allFastFailOfCffu(cffuFactory: CffuFactory): Cffu = + cffuFactory.allFastFailOf(*toTypedArray()) /** * Returns a new Cffu that is successful when all the given stages success, @@ -380,13 +380,13 @@ fun Collection>.allOfFastFailCffu(cffuFactory: CffuFactory): * with a CompletionException holding this exception as its cause. * If no stages are provided, returns a Cffu completed with the value `null`. * - * This method is the same as [CffuFactory.allOfFastFail], providing this method is convenient for method chaining. + * This method is the same as [CffuFactory.allFastFailOf], providing this method is convenient for method chaining. * - * @see allResultsOfFastFailCffu - * @see CffuFactory.allOfFastFail + * @see allResultsFastFailOfCffu + * @see CffuFactory.allFastFailOf */ -fun Array>.allOfFastFailCffu(cffuFactory: CffuFactory): Cffu = - cffuFactory.allOfFastFail(*this) +fun Array>.allFastFailOfCffu(cffuFactory: CffuFactory): Cffu = + cffuFactory.allFastFailOf(*this) /** * Returns a new Cffu that is completed when all the given Cffus complete. @@ -479,18 +479,18 @@ fun Array>.allOfCffu(cffuFactory: CffuFactory): Cffu Collection>.anyOfSuccessCffu(cffuFactory: CffuFactory = ABSENT): Cffu { +fun Collection>.anySuccessOfCffu(cffuFactory: CffuFactory = ABSENT): Cffu { val factory: CffuFactory = if (cffuFactory !== ABSENT) cffuFactory else firstOrNull()?.cffuFactory() ?: throw IllegalArgumentException(ERROR_MSG_FOR_COLL) - return factory.anyOfSuccess(*toTypedArray()) + return factory.anySuccessOf(*toTypedArray()) } /** @@ -501,18 +501,18 @@ fun Collection>.anyOfSuccessCffu(cffuFactory: CffuFactory = ABSE * returns a new Cffu that is already completed exceptionally with a CompletionException * holding a [NoCfsProvidedException][io.foldright.cffu.NoCfsProvidedException] as its cause. * - * This method is the same as [CffuFactory.anyOfSuccess], providing this method is convenient for method chaining. + * This method is the same as [CffuFactory.anySuccessOf], providing this method is convenient for method chaining. * * If this array is not empty, `cffuFactory` argument is optional, use the `cffuFactory` of the first cffu element. * If this array is empty and no`cffuFactory` provided, throw [IllegalArgumentException]. * * @see anyOfCffu - * @see CffuFactory.anyOfSuccess + * @see CffuFactory.anySuccessOf */ -fun Array>.anyOfSuccessCffu(cffuFactory: CffuFactory = ABSENT): Cffu { +fun Array>.anySuccessOfCffu(cffuFactory: CffuFactory = ABSENT): Cffu { val factory: CffuFactory = if (cffuFactory !== ABSENT) cffuFactory else firstOrNull()?.cffuFactory() ?: throw IllegalArgumentException(ERROR_MSG_FOR_ARRAY) - return factory.anyOfSuccess(*this) + return factory.anySuccessOf(*this) } /** @@ -523,14 +523,14 @@ fun Array>.anyOfSuccessCffu(cffuFactory: CffuFactory = ABSEN * returns a new Cffu that is already completed exceptionally with a CompletionException * holding a [NoCfsProvidedException][io.foldright.cffu.NoCfsProvidedException] as its cause. * - * This method is the same as [CffuFactory.anyOfSuccess], providing this method is convenient for method chaining. + * This method is the same as [CffuFactory.anySuccessOf], providing this method is convenient for method chaining. * * @see anyOfCffu - * @see CffuFactory.anyOfSuccess + * @see CffuFactory.anySuccessOf */ -@JvmName("anyOfSuccessCffuCs") -fun Collection>.anyOfSuccessCffu(cffuFactory: CffuFactory): Cffu = - cffuFactory.anyOfSuccess(*toTypedArray()) +@JvmName("anySuccessOfCffuCs") +fun Collection>.anySuccessOfCffu(cffuFactory: CffuFactory): Cffu = + cffuFactory.anySuccessOf(*toTypedArray()) /** * Returns a new Cffu that is successful when any of the given stages success, @@ -540,13 +540,13 @@ fun Collection>.anyOfSuccessCffu(cffuFactory: CffuFac * returns a new Cffu that is already completed exceptionally with a CompletionException * holding a [NoCfsProvidedException][io.foldright.cffu.NoCfsProvidedException] as its cause. * - * This method is the same as [CffuFactory.anyOfSuccess], providing this method is convenient for method chaining. + * This method is the same as [CffuFactory.anySuccessOf], providing this method is convenient for method chaining. * * @see anyOfCffu - * @see CffuFactory.anyOfSuccess + * @see CffuFactory.anySuccessOf */ -fun Array>.anyOfSuccessCffu(cffuFactory: CffuFactory): Cffu = - cffuFactory.anyOfSuccess(*this) +fun Array>.anySuccessOfCffu(cffuFactory: CffuFactory): Cffu = + cffuFactory.anySuccessOf(*this) /** * Returns a new Cffu that is completed when any of the given Cffus complete, with the same result. diff --git a/cffu-kotlin/src/main/java/io/foldright/cffu/kotlin/CompletableFutureExtensions.kt b/cffu-kotlin/src/main/java/io/foldright/cffu/kotlin/CompletableFutureExtensions.kt index ad7d7d20..ea427d7a 100644 --- a/cffu-kotlin/src/main/java/io/foldright/cffu/kotlin/CompletableFutureExtensions.kt +++ b/cffu-kotlin/src/main/java/io/foldright/cffu/kotlin/CompletableFutureExtensions.kt @@ -20,7 +20,7 @@ import java.util.function.Function //////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////// -// region## allOf* Methods for Collection/Array(including mostResultsOfSuccess) +// region## allOf* Methods for Collection/Array(including mostSuccessResultsOf) //////////////////////////////////////////////////////////// /** @@ -31,16 +31,16 @@ import java.util.function.Function * with a CompletionException holding this exception as its cause. * If no CompletableFutures are provided, returns a CompletableFuture completed with the value empty list. * - * This method is the same as [allOfFastFailCompletableFuture], + * This method is the same as [allFastFailOfCompletableFuture], * except the returned CompletableFuture contains the results of input CompletableFutures. * - * This method is the same as [CompletableFutureUtils.allResultsOfFastFail], + * This method is the same as [CompletableFutureUtils.allResultsFastFailOf], * providing this method is convenient for method chaining. * - * @see allOfFastFailCompletableFuture + * @see allFastFailOfCompletableFuture */ -fun Collection>.allResultsOfFastFailCompletableFuture(): CompletableFuture> = - CompletableFutureUtils.allResultsOfFastFail(*toTypedArray()) +fun Collection>.allResultsFastFailOfCompletableFuture(): CompletableFuture> = + CompletableFutureUtils.allResultsFastFailOf(*toTypedArray()) /** * Returns a new CompletableFuture with the results in the **same order** of all the given @@ -50,16 +50,16 @@ fun Collection>.allResultsOfFastFailCompletableFuture * with a CompletionException holding this exception as its cause. * If no CompletableFutures are provided, returns a CompletableFuture completed with the value empty list. * - * This method is the same as [allOfFastFailCompletableFuture], + * This method is the same as [allFastFailOfCompletableFuture], * except the returned CompletableFuture contains the results of input CompletableFutures. * - * This method is the same as [CompletableFutureUtils.allResultsOfFastFail], + * This method is the same as [CompletableFutureUtils.allResultsFastFailOf], * providing this method is convenient for method chaining. * - * @see allOfFastFailCompletableFuture + * @see allFastFailOfCompletableFuture */ -fun Array>.allResultsOfFastFailCompletableFuture(): CompletableFuture> = - CompletableFutureUtils.allResultsOfFastFail(*this) +fun Array>.allResultsFastFailOfCompletableFuture(): CompletableFuture> = + CompletableFutureUtils.allResultsFastFailOf(*this) /** * Returns a new CompletableFuture with the most results in the **same order** of @@ -72,10 +72,10 @@ fun Array>.allResultsOfFastFailCompletableFuture( * @param valueIfNotSuccess the value to return if not completed successfully * @see getSuccessNow */ -fun Collection>.mostResultsOfSuccessCompletableFuture( +fun Collection>.mostSuccessResultsOfCompletableFuture( valueIfNotSuccess: T, timeout: Long, unit: TimeUnit ): CompletableFuture> = - CompletableFutureUtils.mostResultsOfSuccess(valueIfNotSuccess, timeout, unit, *toTypedArray()) + CompletableFutureUtils.mostSuccessResultsOf(valueIfNotSuccess, timeout, unit, *toTypedArray()) /** * Returns a new CompletableFuture with the most results in the **same order** of @@ -88,10 +88,10 @@ fun Collection>.mostResultsOfSuccessCompletableFuture * @param valueIfNotSuccess the value to return if not completed successfully * @see getSuccessNow */ -fun Array>.mostResultsOfSuccessCompletableFuture( +fun Array>.mostSuccessResultsOfCompletableFuture( valueIfNotSuccess: T, timeout: Long, unit: TimeUnit ): CompletableFuture> = - CompletableFutureUtils.mostResultsOfSuccess(valueIfNotSuccess, timeout, unit, *this) + CompletableFutureUtils.mostSuccessResultsOf(valueIfNotSuccess, timeout, unit, *this) /** * Returns a new CompletableFuture with the most results in the **same order** of @@ -105,10 +105,10 @@ fun Array>.mostResultsOfSuccessCompletableFuture( * @param valueIfNotSuccess the value to return if not completed successfully * @see getSuccessNow */ -fun Collection>.mostResultsOfSuccessCompletableFuture( +fun Collection>.mostSuccessResultsOfCompletableFuture( valueIfNotSuccess: T, executorWhenTimeout: Executor, timeout: Long, unit: TimeUnit ): CompletableFuture> = - CompletableFutureUtils.mostResultsOfSuccess( + CompletableFutureUtils.mostSuccessResultsOf( valueIfNotSuccess, executorWhenTimeout, timeout, unit, *toTypedArray() ) @@ -124,10 +124,10 @@ fun Collection>.mostResultsOfSuccessCompletableFuture * @param valueIfNotSuccess the value to return if not completed successfully * @see getSuccessNow */ -fun Array>.mostResultsOfSuccessCompletableFuture( +fun Array>.mostSuccessResultsOfCompletableFuture( valueIfNotSuccess: T, executorWhenTimeout: Executor, timeout: Long, unit: TimeUnit ): CompletableFuture> = - CompletableFutureUtils.mostResultsOfSuccess(valueIfNotSuccess, executorWhenTimeout, timeout, unit, *this) + CompletableFutureUtils.mostSuccessResultsOf(valueIfNotSuccess, executorWhenTimeout, timeout, unit, *this) /** * Returns a new CompletableFuture with the results in the **same order** of all the given @@ -176,15 +176,15 @@ fun Array>.allResultsOfCompletableFuture(): Compl * * If you need the results of given stages, prefer below methods: * - * - [allResultsOfFastFailCompletableFuture] + * - [allResultsFastFailOfCompletableFuture] * - * This method is the same as [CompletableFutureUtils.allOfFastFail], + * This method is the same as [CompletableFutureUtils.allFastFailOf], * providing this method is convenient for method chaining. * - * @see allResultsOfFastFailCompletableFuture + * @see allResultsFastFailOfCompletableFuture */ -fun Collection>.allOfFastFailCompletableFuture(): CompletableFuture = - CompletableFutureUtils.allOfFastFail(*toTypedArray()) +fun Collection>.allFastFailOfCompletableFuture(): CompletableFuture = + CompletableFutureUtils.allFastFailOf(*toTypedArray()) /** * Returns a new CompletableFuture that is successful when all the given CompletableFutures success, @@ -197,15 +197,15 @@ fun Collection>.allOfFastFailCompletableFuture(): Completable * * If you need the results of given stages, prefer below methods: * - * - [allResultsOfFastFailCompletableFuture] + * - [allResultsFastFailOfCompletableFuture] * - * This method is the same as [CompletableFutureUtils.allOfFastFail], + * This method is the same as [CompletableFutureUtils.allFastFailOf], * providing this method is convenient for method chaining. * - * @see allResultsOfFastFailCompletableFuture + * @see allResultsFastFailOfCompletableFuture */ -fun Array>.allOfFastFailCompletableFuture(): CompletableFuture = - CompletableFutureUtils.allOfFastFail(*this) +fun Array>.allFastFailOfCompletableFuture(): CompletableFuture = + CompletableFutureUtils.allFastFailOf(*this) /** * Returns a new CompletableFuture that is completed when all the given stages complete. @@ -258,13 +258,13 @@ fun Array>.allOfCompletableFuture(): CompletableFuture Collection>.anyOfSuccessCompletableFuture(): CompletableFuture = - CompletableFutureUtils.anyOfSuccess(*toTypedArray()) +fun Collection>.anySuccessOfCompletableFuture(): CompletableFuture = + CompletableFutureUtils.anySuccessOf(*toTypedArray()) /** * Returns a new CompletableFuture that is successful when any of the given CompletableFutures success, @@ -274,13 +274,13 @@ fun Collection>.anyOfSuccessCompletableFuture(): Comp * returns a new CompletableFuture that is already completed exceptionally with a CompletionException * holding a [NoCfsProvidedException][io.foldright.cffu.NoCfsProvidedException] as its cause. * - * This method is the same as [CompletableFutureUtils.anyOfSuccess], + * This method is the same as [CompletableFutureUtils.anySuccessOf], * providing this method is convenient for method chaining. * * @see anyOfCompletableFuture */ -fun Array>.anyOfSuccessCompletableFuture(): CompletableFuture = - CompletableFutureUtils.anyOfSuccess(*this) +fun Array>.anySuccessOfCompletableFuture(): CompletableFuture = + CompletableFutureUtils.anySuccessOf(*this) /** * Returns a new CompletableFuture that is completed @@ -291,7 +291,7 @@ fun Array>.anyOfSuccessCompletableFuture(): Compl * * This method is the same as [CompletableFutureUtils.anyOf], providing this method is convenient for method chaining. * - * @see anyOfSuccessCompletableFuture + * @see anySuccessOfCompletableFuture */ fun Collection>.anyOfCompletableFuture(): CompletableFuture = CompletableFutureUtils.anyOf(*toTypedArray()) @@ -305,7 +305,7 @@ fun Collection>.anyOfCompletableFuture(): Completable * * This method is the same as [CompletableFutureUtils.anyOf], providing this method is convenient for method chaining. * - * @see anyOfSuccessCompletableFuture + * @see anySuccessOfCompletableFuture */ fun Array>.anyOfCompletableFuture(): CompletableFuture = CompletableFutureUtils.anyOf(*this) @@ -333,13 +333,11 @@ fun Array>.anyOfCompletableFuture(): CompletableF * also does so *without* waiting other incomplete given CompletionStage, * with a CompletionException holding this exception as its cause. * - * This method is the same as [CompletableFuture.thenCombine] except for the fast-fail behavior. - * * @param fn the function to use to compute the value of the returned CompletableFuture * @return the new CompletableFuture * @see CompletionStage.thenCombine */ -fun CompletionStage.thenCombineFastFail( +fun CompletableFuture.thenCombineFastFail( other: CompletionStage, fn: BiFunction ): CompletableFuture = CompletableFutureUtils.thenCombineFastFail(this, other, fn) @@ -358,7 +356,7 @@ fun CompletionStage.thenCombineFastFail( * @return the new CompletableFuture * @see CompletionStage.thenCombineAsync */ -fun CompletionStage.thenCombineFastFailAsync( +fun CompletableFuture.thenCombineFastFailAsync( other: CompletionStage, fn: BiFunction ): CompletableFuture = CompletableFutureUtils.thenCombineFastFailAsync(this, other, fn) @@ -377,7 +375,7 @@ fun CompletionStage.thenCombineFastFailAsync( * @return the new CompletableFuture * @see CompletionStage.thenCombineAsync */ -fun CompletionStage.thenCombineFastFailAsync( +fun CompletableFuture.thenCombineFastFailAsync( other: CompletionStage, fn: BiFunction, executor: Executor ): CompletableFuture = CompletableFutureUtils.thenCombineFastFailAsync(this, other, fn, executor) @@ -395,7 +393,7 @@ fun CompletionStage.thenCombineFastFailAsync( * @return the new CompletableFuture * @see CompletionStage.thenAcceptBoth */ -fun CompletionStage.thenAcceptBothFastFail( +fun CompletableFuture.thenAcceptBothFastFail( other: CompletionStage, action: BiConsumer ): CompletableFuture = CompletableFutureUtils.thenAcceptBothFastFail(this, other, action) @@ -414,7 +412,7 @@ fun CompletionStage.thenAcceptBothFastFail( * @return the new CompletableFuture * @see CompletionStage.thenAcceptBothAsync */ -fun CompletionStage.thenAcceptBothFastFailAsync( +fun CompletableFuture.thenAcceptBothFastFailAsync( other: CompletionStage, action: BiConsumer ): CompletableFuture = CompletableFutureUtils.thenAcceptBothFastFailAsync(this, other, action) @@ -433,7 +431,7 @@ fun CompletionStage.thenAcceptBothFastFailAsync( * @return the new CompletableFuture * @see CompletionStage.thenAcceptBothAsync */ -fun CompletionStage.thenAcceptBothFastFailAsync( +fun CompletableFuture.thenAcceptBothFastFailAsync( other: CompletionStage, action: BiConsumer, executor: Executor ): CompletableFuture = CompletableFutureUtils.thenAcceptBothFastFailAsync(this, other, action, executor) @@ -450,7 +448,7 @@ fun CompletionStage.thenAcceptBothFastFailAsync( * @return the new CompletableFuture * @see CompletionStage.runAfterBoth */ -fun CompletionStage<*>.runAfterBothFastFail(other: CompletionStage<*>, action: Runnable): CompletableFuture = +fun CompletableFuture<*>.runAfterBothFastFail(other: CompletionStage<*>, action: Runnable): CompletableFuture = CompletableFutureUtils.runAfterBothFastFail(this, other, action) /** @@ -466,7 +464,10 @@ fun CompletionStage<*>.runAfterBothFastFail(other: CompletionStage<*>, action: R * @return the new CompletableFuture * @see CompletionStage.runAfterBothAsync */ -fun CompletionStage<*>.runAfterBothFastFailAsync(other: CompletionStage<*>, action: Runnable): CompletableFuture = +fun CompletableFuture<*>.runAfterBothFastFailAsync( + other: CompletionStage<*>, + action: Runnable +): CompletableFuture = CompletableFutureUtils.runAfterBothFastFailAsync(this, other, action) /** @@ -482,7 +483,7 @@ fun CompletionStage<*>.runAfterBothFastFailAsync(other: CompletionStage<*>, acti * @return the new CompletableFuture * @see CompletionStage.runAfterBothAsync */ -fun CompletionStage<*>.runAfterBothFastFailAsync( +fun CompletableFuture<*>.runAfterBothFastFailAsync( other: CompletionStage<*>, action: Runnable, executor: Executor ): CompletableFuture = CompletableFutureUtils.runAfterBothFastFailAsync(this, other, action, executor) @@ -508,7 +509,7 @@ fun CompletionStage<*>.runAfterBothFastFailAsync( * @return the new CompletableFuture * @see CompletionStage.applyToEither */ -fun CompletionStage.applyToEitherSuccess( +fun CompletableFuture.applyToEitherSuccess( other: CompletionStage, fn: Function ): CompletableFuture = CompletableFutureUtils.applyToEitherSuccess(this, other, fn) @@ -526,7 +527,7 @@ fun CompletionStage.applyToEitherSuccess( * @return the new CompletableFuture * @see CompletionStage.applyToEitherAsync */ -fun CompletionStage.applyToEitherSuccessAsync( +fun CompletableFuture.applyToEitherSuccessAsync( other: CompletionStage, fn: Function ): CompletableFuture = CompletableFutureUtils.applyToEitherSuccessAsync(this, other, fn) @@ -544,7 +545,7 @@ fun CompletionStage.applyToEitherSuccessAsync( * @return the new CompletableFuture * @see CompletionStage.applyToEitherAsync */ -fun CompletionStage.applyToEitherSuccessAsync( +fun CompletableFuture.applyToEitherSuccessAsync( other: CompletionStage, fn: Function, executor: Executor ): CompletableFuture = CompletableFutureUtils.applyToEitherSuccessAsync(this, other, fn, executor) @@ -560,7 +561,7 @@ fun CompletionStage.applyToEitherSuccessAsync( * @return the new CompletableFuture * @see CompletionStage.acceptEither */ -fun CompletionStage.acceptEitherSuccess( +fun CompletableFuture.acceptEitherSuccess( other: CompletionStage, action: Consumer ): CompletableFuture = CompletableFutureUtils.acceptEitherSuccess(this, other, action) @@ -577,7 +578,7 @@ fun CompletionStage.acceptEitherSuccess( * @return the new CompletableFuture * @see CompletionStage.acceptEitherAsync */ -fun CompletionStage.acceptEitherSuccessAsync( +fun CompletableFuture.acceptEitherSuccessAsync( other: CompletionStage, action: Consumer ): CompletableFuture = CompletableFutureUtils.acceptEitherSuccessAsync(this, other, action) @@ -594,7 +595,7 @@ fun CompletionStage.acceptEitherSuccessAsync( * @return the new CompletableFuture * @see CompletionStage.acceptEitherAsync */ -fun CompletionStage.acceptEitherSuccessAsync( +fun CompletableFuture.acceptEitherSuccessAsync( other: CompletionStage, action: Consumer, executor: Executor ): CompletableFuture = CompletableFutureUtils.acceptEitherSuccessAsync(this, other, action, executor) @@ -612,7 +613,7 @@ fun CompletionStage.acceptEitherSuccessAsync( * @return the new CompletableFuture * @see CompletionStage.runAfterEither */ -fun CompletionStage<*>.runAfterEitherSuccess(other: CompletionStage<*>, action: Runnable): CompletableFuture = +fun CompletableFuture<*>.runAfterEitherSuccess(other: CompletionStage<*>, action: Runnable): CompletableFuture = CompletableFutureUtils.runAfterEitherSuccess(this, other, action) /** @@ -629,7 +630,7 @@ fun CompletionStage<*>.runAfterEitherSuccess(other: CompletionStage<*>, action: * @return the new CompletableFuture * @see CompletionStage.runAfterEitherAsync */ -fun CompletionStage<*>.runAfterEitherSuccessAsync( +fun CompletableFuture<*>.runAfterEitherSuccessAsync( other: CompletionStage<*>, action: Runnable ): CompletableFuture = CompletableFutureUtils.runAfterEitherSuccessAsync(this, other, action) @@ -648,7 +649,7 @@ fun CompletionStage<*>.runAfterEitherSuccessAsync( * @return the new CompletableFuture * @see CompletionStage.runAfterEitherAsync */ -fun CompletionStage<*>.runAfterEitherSuccessAsync( +fun CompletableFuture<*>.runAfterEitherSuccessAsync( other: CompletionStage<*>, action: Runnable, executor: Executor ): CompletableFuture = CompletableFutureUtils.runAfterEitherSuccessAsync(this, other, action, executor) diff --git a/cffu-kotlin/src/test/java/io/foldright/cffu/test/CffuExtensionsTest.kt b/cffu-kotlin/src/test/java/io/foldright/cffu/test/CffuExtensionsTest.kt index d1f1c89c..b682ea36 100644 --- a/cffu-kotlin/src/test/java/io/foldright/cffu/test/CffuExtensionsTest.kt +++ b/cffu-kotlin/src/test/java/io/foldright/cffu/test/CffuExtensionsTest.kt @@ -196,31 +196,31 @@ class CffuExtensionsTest : FunSpec({ testCffuFactory.completedFuture(42), testCffuFactory.completedFuture(43), testCffuFactory.completedFuture(44), - ).allResultsOfFastFailCffu(testCffuFactory).await() shouldBe listOf(42, 43, 44) + ).allResultsFastFailOfCffu(testCffuFactory).await() shouldBe listOf(42, 43, 44) listOf( testCffuFactory.completedFuture(42), testCffuFactory.completedFuture(43), testCffuFactory.completedFuture(44), - ).allResultsOfFastFailCffu().await() shouldBe listOf(42, 43, 44) + ).allResultsFastFailOfCffu().await() shouldBe listOf(42, 43, 44) setOf( testCffuFactory.completedFuture(42), testCffuFactory.completedFuture(43), testCffuFactory.completedFuture(44), - ).allResultsOfFastFailCffu(testCffuFactory).await() shouldBe listOf(42, 43, 44) + ).allResultsFastFailOfCffu(testCffuFactory).await() shouldBe listOf(42, 43, 44) listOf( CompletableFuture.completedFuture(42), CompletableFuture.completedFuture(43), CompletableFuture.completedFuture(44), - ).allResultsOfFastFailCffu(testCffuFactory).await() shouldBe listOf(42, 43, 44) + ).allResultsFastFailOfCffu(testCffuFactory).await() shouldBe listOf(42, 43, 44) setOf( CompletableFuture.completedFuture(42), CompletableFuture.completedFuture(43), CompletableFuture.completedFuture(44), - ).allResultsOfFastFailCffu(testCffuFactory).await() shouldBe listOf(42, 43, 44) + ).allResultsFastFailOfCffu(testCffuFactory).await() shouldBe listOf(42, 43, 44) // Array @@ -228,19 +228,19 @@ class CffuExtensionsTest : FunSpec({ testCffuFactory.completedFuture(42), testCffuFactory.completedFuture(43), testCffuFactory.completedFuture(44), - ).allResultsOfFastFailCffu(testCffuFactory).await() shouldBe listOf(42, 43, 44) + ).allResultsFastFailOfCffu(testCffuFactory).await() shouldBe listOf(42, 43, 44) arrayOf( testCffuFactory.completedFuture(42), testCffuFactory.completedFuture(43), testCffuFactory.completedFuture(44), - ).allResultsOfFastFailCffu().await() shouldBe listOf(42, 43, 44) + ).allResultsFastFailOfCffu().await() shouldBe listOf(42, 43, 44) arrayOf( CompletableFuture.completedFuture(42), CompletableFuture.completedFuture(43), CompletableFuture.completedFuture(44), - ).allResultsOfFastFailCffu(testCffuFactory).await() shouldBe listOf(42, 43, 44) + ).allResultsFastFailOfCffu(testCffuFactory).await() shouldBe listOf(42, 43, 44) //////////////////////////////////////// @@ -250,31 +250,31 @@ class CffuExtensionsTest : FunSpec({ testCffuFactory.completedFuture(42), testCffuFactory.completedFuture(43), testCffuFactory.completedFuture(44), - ).allOfFastFailCffu(testCffuFactory).await().shouldBeNull() + ).allFastFailOfCffu(testCffuFactory).await().shouldBeNull() listOf( testCffuFactory.completedFuture(42), testCffuFactory.completedFuture(43), testCffuFactory.completedFuture(44), - ).allOfFastFailCffu().await().shouldBeNull() + ).allFastFailOfCffu().await().shouldBeNull() setOf( testCffuFactory.completedFuture(42), testCffuFactory.completedFuture(43), testCffuFactory.completedFuture(44), - ).allOfFastFailCffu(testCffuFactory).await().shouldBeNull() + ).allFastFailOfCffu(testCffuFactory).await().shouldBeNull() listOf( CompletableFuture.completedFuture(42), CompletableFuture.completedFuture(43), CompletableFuture.completedFuture(44), - ).allOfFastFailCffu(testCffuFactory).await().shouldBeNull() + ).allFastFailOfCffu(testCffuFactory).await().shouldBeNull() setOf( CompletableFuture.completedFuture(42), CompletableFuture.completedFuture(43), CompletableFuture.completedFuture(44), - ).allOfFastFailCffu(testCffuFactory).await().shouldBeNull() + ).allFastFailOfCffu(testCffuFactory).await().shouldBeNull() // Array @@ -282,60 +282,60 @@ class CffuExtensionsTest : FunSpec({ testCffuFactory.completedFuture(42), testCffuFactory.completedFuture(43), testCffuFactory.completedFuture(44), - ).allOfFastFailCffu(testCffuFactory).await().shouldBeNull() + ).allFastFailOfCffu(testCffuFactory).await().shouldBeNull() arrayOf( testCffuFactory.completedFuture(42), testCffuFactory.completedFuture(43), testCffuFactory.completedFuture(44), - ).allOfFastFailCffu().await().shouldBeNull() + ).allFastFailOfCffu().await().shouldBeNull() arrayOf( CompletableFuture.completedFuture(42), CompletableFuture.completedFuture(43), CompletableFuture.completedFuture(44), - ).allOfFastFailCffu(testCffuFactory).await().shouldBeNull() + ).allFastFailOfCffu(testCffuFactory).await().shouldBeNull() } - test("mostResultsOfSuccessCffu") { + test("mostSuccessResultsOfCffu") { // collection listOf( testCffuFactory.newIncompleteCffu(), testCffuFactory.completedFuture(42), - ).mostResultsOfSuccessCffu(-1, 10, TimeUnit.MILLISECONDS, testCffuFactory).await() shouldBe listOf(-1, 42) + ).mostSuccessResultsOfCffu(-1, 10, TimeUnit.MILLISECONDS, testCffuFactory).await() shouldBe listOf(-1, 42) setOf( testCffuFactory.newIncompleteCffu(), testCffuFactory.completedFuture(42), - ).mostResultsOfSuccessCffu(-1, 10, TimeUnit.MILLISECONDS).await() shouldBe listOf(-1, 42) + ).mostSuccessResultsOfCffu(-1, 10, TimeUnit.MILLISECONDS).await() shouldBe listOf(-1, 42) listOf( CompletableFuture(), CompletableFuture.completedFuture(42), - ).mostResultsOfSuccessCffu(-1, 10, TimeUnit.MILLISECONDS, testCffuFactory).await() shouldBe listOf(-1, 42) + ).mostSuccessResultsOfCffu(-1, 10, TimeUnit.MILLISECONDS, testCffuFactory).await() shouldBe listOf(-1, 42) // Array arrayOf( testCffuFactory.newIncompleteCffu(), testCffuFactory.completedFuture(42), - ).mostResultsOfSuccessCffu(-1, 10, TimeUnit.MILLISECONDS, testCffuFactory).await() shouldBe listOf(-1, 42) + ).mostSuccessResultsOfCffu(-1, 10, TimeUnit.MILLISECONDS, testCffuFactory).await() shouldBe listOf(-1, 42) arrayOf( testCffuFactory.newIncompleteCffu(), testCffuFactory.completedFuture(42), - ).mostResultsOfSuccessCffu(-1, 10, TimeUnit.MILLISECONDS).await() shouldBe listOf(-1, 42) + ).mostSuccessResultsOfCffu(-1, 10, TimeUnit.MILLISECONDS).await() shouldBe listOf(-1, 42) arrayOf( CompletableFuture(), CompletableFuture.completedFuture(42), - ).mostResultsOfSuccessCffu(-1, 10, TimeUnit.MILLISECONDS, testCffuFactory).await() shouldBe listOf(-1, 42) + ).mostSuccessResultsOfCffu(-1, 10, TimeUnit.MILLISECONDS, testCffuFactory).await() shouldBe listOf(-1, 42) // FIXME: java.lang.ClassCastException if not providing the type parameter explicitly: // class [Ljava.lang.Object; cannot be cast to class [Ljava.util.concurrent.CompletionStage; arrayOf>(CompletableFuture(), testCffuFactory.completedFuture(42)) - .mostResultsOfSuccessCffu(-1, 10, TimeUnit.MILLISECONDS, testCffuFactory).await() shouldBe listOf(-1, 42) + .mostSuccessResultsOfCffu(-1, 10, TimeUnit.MILLISECONDS, testCffuFactory).await() shouldBe listOf(-1, 42) } test("anyOf*") { @@ -453,31 +453,31 @@ class CffuExtensionsTest : FunSpec({ testCffuFactory.newIncompleteCffu(), testCffuFactory.newIncompleteCffu(), testCffuFactory.completedFuture(42), - ).anyOfSuccessCffu(testCffuFactory).await() shouldBe 42 + ).anySuccessOfCffu(testCffuFactory).await() shouldBe 42 listOf( testCffuFactory.newIncompleteCffu(), testCffuFactory.newIncompleteCffu(), testCffuFactory.completedFuture(42), - ).anyOfSuccessCffu().await() shouldBe 42 + ).anySuccessOfCffu().await() shouldBe 42 setOf( testCffuFactory.newIncompleteCffu(), testCffuFactory.completedFuture(42), testCffuFactory.newIncompleteCffu(), - ).anyOfSuccessCffu(testCffuFactory).await() shouldBe 42 + ).anySuccessOfCffu(testCffuFactory).await() shouldBe 42 listOf( CompletableFuture(), CompletableFuture(), CompletableFuture.completedFuture(42), - ).anyOfSuccessCffu(testCffuFactory).await() shouldBe 42 + ).anySuccessOfCffu(testCffuFactory).await() shouldBe 42 setOf( CompletableFuture(), CompletableFuture.completedFuture(42), CompletableFuture(), - ).anyOfSuccessCffu(testCffuFactory).await() shouldBe 42 + ).anySuccessOfCffu(testCffuFactory).await() shouldBe 42 // Array @@ -485,22 +485,22 @@ class CffuExtensionsTest : FunSpec({ testCffuFactory.newIncompleteCffu(), testCffuFactory.newIncompleteCffu(), testCffuFactory.completedFuture(42), - ).anyOfSuccessCffu(testCffuFactory).await() shouldBe 42 + ).anySuccessOfCffu(testCffuFactory).await() shouldBe 42 arrayOf( testCffuFactory.newIncompleteCffu(), testCffuFactory.newIncompleteCffu(), testCffuFactory.completedFuture(42), - ).anyOfSuccessCffu().await() shouldBe 42 + ).anySuccessOfCffu().await() shouldBe 42 arrayOf( CompletableFuture(), CompletableFuture(), CompletableFuture.completedFuture(42), - ).anyOfSuccessCffu(testCffuFactory).await() shouldBe 42 + ).anySuccessOfCffu(testCffuFactory).await() shouldBe 42 shouldThrow { - arrayOf>().anyOfSuccessCffu(testCffuFactory).await() + arrayOf>().anySuccessOfCffu(testCffuFactory).await() }.shouldBeTypeOf() //////////////////////////////////////// @@ -511,31 +511,31 @@ class CffuExtensionsTest : FunSpec({ testCffuFactory.newIncompleteCffu(), testCffuFactory.newIncompleteCffu(), testCffuFactory.completedFuture(42), - ).anyOfSuccessCffu(testCffuFactory).await() shouldBe 42 + ).anySuccessOfCffu(testCffuFactory).await() shouldBe 42 listOf( testCffuFactory.newIncompleteCffu(), testCffuFactory.newIncompleteCffu(), testCffuFactory.completedFuture(42), - ).anyOfSuccessCffu().await() shouldBe 42 + ).anySuccessOfCffu().await() shouldBe 42 setOf( testCffuFactory.newIncompleteCffu(), testCffuFactory.completedFuture(42), testCffuFactory.newIncompleteCffu(), - ).anyOfSuccessCffu(testCffuFactory).await() shouldBe 42 + ).anySuccessOfCffu(testCffuFactory).await() shouldBe 42 listOf( CompletableFuture(), CompletableFuture(), CompletableFuture.completedFuture(42), - ).anyOfSuccessCffu(testCffuFactory).await() shouldBe 42 + ).anySuccessOfCffu(testCffuFactory).await() shouldBe 42 setOf( CompletableFuture(), CompletableFuture.completedFuture(42), CompletableFuture(), - ).anyOfSuccessCffu(testCffuFactory).await() shouldBe 42 + ).anySuccessOfCffu(testCffuFactory).await() shouldBe 42 // Array @@ -543,19 +543,19 @@ class CffuExtensionsTest : FunSpec({ testCffuFactory.newIncompleteCffu(), testCffuFactory.newIncompleteCffu(), testCffuFactory.completedFuture(42), - ).anyOfSuccessCffu(testCffuFactory).await() shouldBe 42 + ).anySuccessOfCffu(testCffuFactory).await() shouldBe 42 arrayOf( testCffuFactory.newIncompleteCffu(), testCffuFactory.newIncompleteCffu(), testCffuFactory.completedFuture(42), - ).anyOfSuccessCffu().await() shouldBe 42 + ).anySuccessOfCffu().await() shouldBe 42 arrayOf( CompletableFuture(), CompletableFuture(), CompletableFuture.completedFuture(42), - ).anyOfSuccessCffu(testCffuFactory).await() shouldBe 42 + ).anySuccessOfCffu(testCffuFactory).await() shouldBe 42 } val cffuFactoryForOptional = CffuFactory.builder(Executors.newCachedThreadPool()).build() @@ -593,30 +593,30 @@ class CffuExtensionsTest : FunSpec({ assertEmptyArray { emptyArray.allOfCffu() } assertCffuFactoryForOptional(array.allOfCffu()) - assertEmptyCollection { emptyList.allResultsOfFastFailCffu() } - assertCffuFactoryForOptional(list.allResultsOfFastFailCffu()) - assertEmptyArray { emptyArray.allResultsOfFastFailCffu() } - assertCffuFactoryForOptional(array.allResultsOfFastFailCffu()) + assertEmptyCollection { emptyList.allResultsFastFailOfCffu() } + assertCffuFactoryForOptional(list.allResultsFastFailOfCffu()) + assertEmptyArray { emptyArray.allResultsFastFailOfCffu() } + assertCffuFactoryForOptional(array.allResultsFastFailOfCffu()) - assertEmptyCollection { emptyList.allOfFastFailCffu() } - assertCffuFactoryForOptional(list.allOfFastFailCffu()) - assertEmptyArray { emptyArray.allOfFastFailCffu() } - assertCffuFactoryForOptional(array.allOfFastFailCffu()) + assertEmptyCollection { emptyList.allFastFailOfCffu() } + assertCffuFactoryForOptional(list.allFastFailOfCffu()) + assertEmptyArray { emptyArray.allFastFailOfCffu() } + assertCffuFactoryForOptional(array.allFastFailOfCffu()) - assertEmptyCollection { emptyList.mostResultsOfSuccessCffu(4, 1, TimeUnit.MILLISECONDS) } - assertCffuFactoryForOptional(list.mostResultsOfSuccessCffu(4, 1, TimeUnit.MILLISECONDS)) - assertEmptyArray { emptyArray.mostResultsOfSuccessCffu(4, 1, TimeUnit.MILLISECONDS) } - assertCffuFactoryForOptional(array.mostResultsOfSuccessCffu(4, 1, TimeUnit.MILLISECONDS)) + assertEmptyCollection { emptyList.mostSuccessResultsOfCffu(4, 1, TimeUnit.MILLISECONDS) } + assertCffuFactoryForOptional(list.mostSuccessResultsOfCffu(4, 1, TimeUnit.MILLISECONDS)) + assertEmptyArray { emptyArray.mostSuccessResultsOfCffu(4, 1, TimeUnit.MILLISECONDS) } + assertCffuFactoryForOptional(array.mostSuccessResultsOfCffu(4, 1, TimeUnit.MILLISECONDS)) assertEmptyCollection { emptyList.anyOfCffu() } assertCffuFactoryForOptional(list.anyOfCffu()) assertEmptyArray { emptyArray.anyOfCffu() } assertCffuFactoryForOptional(array.anyOfCffu()) - assertEmptyCollection { emptyList.anyOfSuccessCffu() } - assertCffuFactoryForOptional(list.anyOfSuccessCffu()) - assertEmptyArray { emptyArray.anyOfSuccessCffu() } - assertCffuFactoryForOptional(array.anyOfSuccessCffu()) + assertEmptyCollection { emptyList.anySuccessOfCffu() } + assertCffuFactoryForOptional(list.anySuccessOfCffu()) + assertEmptyArray { emptyArray.anySuccessOfCffu() } + assertCffuFactoryForOptional(array.anySuccessOfCffu()) } //////////////////////////////////////// diff --git a/cffu-kotlin/src/test/java/io/foldright/cffu/test/CompletableFutureExtensionsTest.kt b/cffu-kotlin/src/test/java/io/foldright/cffu/test/CompletableFutureExtensionsTest.kt index 60c9776d..e7ab8e0a 100644 --- a/cffu-kotlin/src/test/java/io/foldright/cffu/test/CompletableFutureExtensionsTest.kt +++ b/cffu-kotlin/src/test/java/io/foldright/cffu/test/CompletableFutureExtensionsTest.kt @@ -73,21 +73,21 @@ class CompletableFutureExtensionsTest : FunSpec({ CompletableFuture.completedFuture(42), CompletableFuture.completedFuture(43), CompletableFuture.completedFuture(44), - ).allResultsOfFastFailCompletableFuture().await() shouldBe listOf(42, 43, 44) - listOf>().allResultsOfFastFailCompletableFuture().await() shouldBe emptyList() + ).allResultsFastFailOfCompletableFuture().await() shouldBe listOf(42, 43, 44) + listOf>().allResultsFastFailOfCompletableFuture().await() shouldBe emptyList() setOf( CompletableFuture.completedFuture(42), CompletableFuture.completedFuture(43), CompletableFuture.completedFuture(44), - ).allResultsOfFastFailCompletableFuture().await() shouldBe listOf(42, 43, 44) + ).allResultsFastFailOfCompletableFuture().await() shouldBe listOf(42, 43, 44) arrayOf( CompletableFuture.completedFuture(42), CompletableFuture.completedFuture(43), CompletableFuture.completedFuture(44), - ).allResultsOfFastFailCompletableFuture().await() shouldBe listOf(42, 43, 44) - arrayOf>().allResultsOfFastFailCompletableFuture().await() shouldBe emptyList() + ).allResultsFastFailOfCompletableFuture().await() shouldBe listOf(42, 43, 44) + arrayOf>().allResultsFastFailOfCompletableFuture().await() shouldBe emptyList() //////////////////////////////////////// @@ -95,34 +95,34 @@ class CompletableFutureExtensionsTest : FunSpec({ CompletableFuture.completedFuture(42), CompletableFuture.completedFuture("42"), CompletableFuture.completedFuture(42.0), - ).allOfFastFailCompletableFuture().await().shouldBeNull() - listOf>().allOfFastFailCompletableFuture().await().shouldBeNull() + ).allFastFailOfCompletableFuture().await().shouldBeNull() + listOf>().allFastFailOfCompletableFuture().await().shouldBeNull() setOf( CompletableFuture.completedFuture(42), CompletableFuture.completedFuture("42"), CompletableFuture.completedFuture(42.0), - ).allOfFastFailCompletableFuture().await().shouldBeNull() + ).allFastFailOfCompletableFuture().await().shouldBeNull() arrayOf( CompletableFuture.completedFuture(42), CompletableFuture.completedFuture("42"), CompletableFuture.completedFuture(42.0), - ).allOfFastFailCompletableFuture().await().shouldBeNull() - arrayOf>().allOfFastFailCompletableFuture().await().shouldBeNull() + ).allFastFailOfCompletableFuture().await().shouldBeNull() + arrayOf>().allFastFailOfCompletableFuture().await().shouldBeNull() } - test("mostResultsOfSuccessCompletableFuture") { + test("mostSuccessResultsOfCompletableFuture") { listOf(CompletableFuture(), CompletableFuture.completedFuture(42)) - .mostResultsOfSuccessCompletableFuture(null, 10, TimeUnit.MILLISECONDS).await() shouldBe listOf(null, 42) + .mostSuccessResultsOfCompletableFuture(null, 10, TimeUnit.MILLISECONDS).await() shouldBe listOf(null, 42) listOf(CompletableFuture(), CompletableFuture.completedFuture(42)) - .mostResultsOfSuccessCompletableFuture(null, testThreadPoolExecutor, 10, TimeUnit.MILLISECONDS) + .mostSuccessResultsOfCompletableFuture(null, testThreadPoolExecutor, 10, TimeUnit.MILLISECONDS) .await() shouldBe listOf(null, 42) arrayOf(CompletableFuture(), CompletableFuture.completedFuture(42)) - .mostResultsOfSuccessCompletableFuture(null, 10, TimeUnit.MILLISECONDS).await() shouldBe listOf(null, 42) + .mostSuccessResultsOfCompletableFuture(null, 10, TimeUnit.MILLISECONDS).await() shouldBe listOf(null, 42) arrayOf(CompletableFuture(), CompletableFuture.completedFuture(42)) - .mostResultsOfSuccessCompletableFuture(null, testThreadPoolExecutor, 10, TimeUnit.MILLISECONDS) + .mostSuccessResultsOfCompletableFuture(null, testThreadPoolExecutor, 10, TimeUnit.MILLISECONDS) .await() shouldBe listOf(null, 42) } @@ -175,24 +175,24 @@ class CompletableFutureExtensionsTest : FunSpec({ CompletableFuture(), CompletableFuture(), CompletableFuture.completedFuture(42), - ).anyOfSuccessCompletableFuture().await() shouldBe 42 + ).anySuccessOfCompletableFuture().await() shouldBe 42 shouldThrow { - listOf>().anyOfSuccessCompletableFuture().await() + listOf>().anySuccessOfCompletableFuture().await() } setOf( CompletableFuture(), CompletableFuture.completedFuture(42), CompletableFuture(), - ).anyOfSuccessCompletableFuture().await() shouldBe 42 + ).anySuccessOfCompletableFuture().await() shouldBe 42 arrayOf( CompletableFuture(), CompletableFuture.completedFuture(42), CompletableFuture(), - ).anyOfSuccessCompletableFuture().await() shouldBe 42 + ).anySuccessOfCompletableFuture().await() shouldBe 42 shouldThrow { - arrayOf>().anyOfSuccessCompletableFuture().await() + arrayOf>().anySuccessOfCompletableFuture().await() } //////////////////////////////////////// @@ -201,24 +201,24 @@ class CompletableFutureExtensionsTest : FunSpec({ CompletableFuture(), CompletableFuture(), CompletableFuture.completedFuture(42), - ).anyOfSuccessCompletableFuture().await() shouldBe 42 + ).anySuccessOfCompletableFuture().await() shouldBe 42 shouldThrow { - listOf>().anyOfSuccessCompletableFuture().await() + listOf>().anySuccessOfCompletableFuture().await() } setOf( CompletableFuture(), CompletableFuture(), CompletableFuture.completedFuture(42), - ).anyOfSuccessCompletableFuture().await() shouldBe 42 + ).anySuccessOfCompletableFuture().await() shouldBe 42 arrayOf( CompletableFuture(), CompletableFuture(), CompletableFuture.completedFuture(42), - ).anyOfSuccessCompletableFuture().await() shouldBe 42 + ).anySuccessOfCompletableFuture().await() shouldBe 42 shouldThrow { - arrayOf>().anyOfSuccessCompletableFuture().await() + arrayOf>().anySuccessOfCompletableFuture().await() } } diff --git a/cffu-ttl-executor-wrapper/README.md b/cffu-ttl-executor-wrapper/README.md index 1e9f22eb..460cb15c 100644 --- a/cffu-ttl-executor-wrapper/README.md +++ b/cffu-ttl-executor-wrapper/README.md @@ -18,7 +18,7 @@ For `Maven` projects: io.foldright cffu-ttl-executor-wrapper runtime - 1.0.0-Alpha11 + 1.0.0-Alpha12 ``` @@ -26,12 +26,12 @@ For `Gradle` projects: ```groovy // Gradle Kotlin DSL -runtimeOnly("io.foldright:cffu-ttl-executor-wrapper:1.0.0-Alpha11") +runtimeOnly("io.foldright:cffu-ttl-executor-wrapper:1.0.0-Alpha12") ``` ```groovy // Gradle Groovy DSL -runtimeOnly 'io.foldright:cffu-ttl-executor-wrapper:1.0.0-Alpha11' +runtimeOnly 'io.foldright:cffu-ttl-executor-wrapper:1.0.0-Alpha12' ``` `cffu-ttl-executor-wrapper` has published to maven central, find the latest version at diff --git a/demos/cffu-demo/src/main/java/io/foldright/demo/cffu/CffuDemo.java b/demos/cffu-demo/src/main/java/io/foldright/demo/cffu/CffuDemo.java index e7478e08..012c252e 100644 --- a/demos/cffu-demo/src/main/java/io/foldright/demo/cffu/CffuDemo.java +++ b/demos/cffu-demo/src/main/java/io/foldright/demo/cffu/CffuDemo.java @@ -40,8 +40,8 @@ public static void main(String[] args) throws Exception { .orTimeout(1500, TimeUnit.MILLISECONDS); System.out.println("combined result: " + combined.get()); - final Cffu anyOfSuccess = cffuFactory.anyOfSuccess(longTaskC, longFailedTask); - System.out.println("anyOfSuccess result: " + anyOfSuccess.get()); + final Cffu anySuccessOf = cffuFactory.anySuccessOf(longTaskC, longFailedTask); + System.out.println("anySuccessOf result: " + anySuccessOf.get()); //////////////////////////////////////// // cleanup diff --git a/demos/cffu-demo/src/main/java/io/foldright/demo/cffu/CompletableFutureUtilsDemo.java b/demos/cffu-demo/src/main/java/io/foldright/demo/cffu/CompletableFutureUtilsDemo.java index a91ee65b..ef67136b 100644 --- a/demos/cffu-demo/src/main/java/io/foldright/demo/cffu/CompletableFutureUtilsDemo.java +++ b/demos/cffu-demo/src/main/java/io/foldright/demo/cffu/CompletableFutureUtilsDemo.java @@ -38,8 +38,8 @@ public static void main(String[] args) throws Exception { CompletableFutureUtils.orTimeout(combined, 1500, TimeUnit.MILLISECONDS); System.out.println("combined result: " + combinedWithTimeout.get()); - final CompletableFuture anyOfSuccess = CompletableFutureUtils.anyOfSuccess(longTaskC, longFailedTask); - System.out.println("anyOfSuccess result: " + anyOfSuccess.get()); + final CompletableFuture anySuccessOf = CompletableFutureUtils.anySuccessOf(longTaskC, longFailedTask); + System.out.println("anySuccessOf result: " + anySuccessOf.get()); //////////////////////////////////////// // cleanup diff --git a/demos/cffu-demo/src/main/java/io/foldright/demo/cffu/CovariantDemo.java b/demos/cffu-demo/src/main/java/io/foldright/demo/cffu/CovariantDemo.java index 4363a5b6..c82f5ddc 100644 --- a/demos/cffu-demo/src/main/java/io/foldright/demo/cffu/CovariantDemo.java +++ b/demos/cffu-demo/src/main/java/io/foldright/demo/cffu/CovariantDemo.java @@ -34,26 +34,26 @@ public static void useAllOf() { } public static void useAnyOf() { - CompletableFuture cf1 = CompletableFutureUtils.anyOfSuccess( + CompletableFuture cf1 = CompletableFutureUtils.anySuccessOf( CompletableFuture.completedFuture(42), CompletableFuture.completedFuture(42.0) ).thenApply(Number::byteValue); cf1.thenAccept(System.out::println); - CompletableFuture cf2 = CompletableFutureUtils.anyOfSuccess( + CompletableFuture cf2 = CompletableFutureUtils.anySuccessOf( CompletableFuture.completedFuture(42), CompletableFuture.completedFuture(42.0) ); cf2.thenAccept(System.out::println); - CompletableFutureUtils.anyOfSuccess( + CompletableFutureUtils.anySuccessOf( CompletableFuture.completedFuture(42), CompletableFuture.completedFuture(42.0) ) .thenApply(Number::byteValue) .thenAccept(System.out::println); - CompletableFuture cf5 = CompletableFutureUtils.anyOfSuccess( + CompletableFuture cf5 = CompletableFutureUtils.anySuccessOf( CompletableFuture.completedFuture(42), CompletableFuture.completedFuture(42) ); diff --git a/demos/cffu-kotlin-demo/src/main/java/io/foldright/demo/cffu/kotlin/CffuDemo.kt b/demos/cffu-kotlin-demo/src/main/java/io/foldright/demo/cffu/kotlin/CffuDemo.kt index 05af50e3..6e9f0f58 100644 --- a/demos/cffu-kotlin-demo/src/main/java/io/foldright/demo/cffu/kotlin/CffuDemo.kt +++ b/demos/cffu-kotlin-demo/src/main/java/io/foldright/demo/cffu/kotlin/CffuDemo.kt @@ -2,7 +2,7 @@ package io.foldright.demo.cffu.kotlin import io.foldright.cffu.Cffu import io.foldright.cffu.CffuFactory -import io.foldright.cffu.kotlin.anyOfSuccessCffu +import io.foldright.cffu.kotlin.anySuccessOfCffu import java.lang.Thread.sleep import java.util.concurrent.ExecutorService import java.util.concurrent.Executors @@ -41,8 +41,8 @@ fun main() { .orTimeout(1500, TimeUnit.MILLISECONDS) println("combined result: ${combined.get()}") - val anyOfSuccess: Cffu = listOf(longTaskC, longFailedTask).anyOfSuccessCffu() - println("anyOfSuccess result: ${anyOfSuccess.get()}") + val anySuccessOf: Cffu = listOf(longTaskC, longFailedTask).anySuccessOfCffu() + println("anySuccessOf result: ${anySuccessOf.get()}") //////////////////////////////////////// // cleanup diff --git a/src/main/javadoc/overview.html b/src/main/javadoc/overview.html index b1acb13f..d99c2db5 100644 --- a/src/main/javadoc/overview.html +++ b/src/main/javadoc/overview.html @@ -3,8 +3,8 @@

This is the API documentation for the 🦝 Java CompletableFuture Fu(aka. CF-Fu, pronounced "Shifu"), - a tiny sidekick library for + a tiny sidekick library to make CompletableFuture - to improve user experience and reduce misuse. + more convenient, more efficient and safer in your application. 😋🚀🦺