From 3adfe123f2cfad95d709b1b6780fbd3299f548e9 Mon Sep 17 00:00:00 2001 From: Jerry Lee Date: Sun, 30 Jun 2024 15:19:48 +0800 Subject: [PATCH] fixup --- README.md | 26 ++++----- .../java/io/foldright/cffu/CffuFactory.java | 54 +++++++++---------- .../cffu/CompletableFutureUtils.java | 48 ++++++++--------- .../io/foldright/cffu/CffuFactoryTest.java | 38 ++++++------- .../cffu/CompletableFutureUtilsTest.java | 42 +++++++-------- .../demo/ConcurrencyStrategyDemo.java | 8 +-- .../foldright/cffu/kotlin/CffuExtensions.kt | 42 +++++++-------- .../kotlin/CompletableFutureExtensions.kt | 20 +++---- .../foldright/cffu/test/CffuExtensionsTest.kt | 24 ++++----- .../test/CompletableFutureExtensionsTest.kt | 10 ++-- 10 files changed, 156 insertions(+), 156 deletions(-) diff --git a/README.md b/README.md index 1e692fc9..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 高效灵活的并发执行策略(`allResultsOfFastFail`/`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%A5allresultsoffastfailanysuccessofmostsuccessresultsof) + - [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,10 +64,10 @@ - ☘️ **补全业务使用中缺失的功能** - 更方便的功能,如 - - `allResultsOfFastFail`/`allResultsOf`方法:返回多个`CF`的结果,而不是无返回结果`Void`(`CompletableFuture#allOf()`) - - `allTupleOfFastFail`/`allTupleOf`方法:返回多个`CF`不同类型的结果,而不是同一类型(`allResultsOf`) + - `allResultsFastFailOf`/`allResultsOf`方法:返回多个`CF`的结果,而不是无返回结果`Void`(`CompletableFuture#allOf()`) + - `allTupleFastFailOf`/`allTupleOf`方法:返回多个`CF`不同类型的结果,而不是同一类型(`allResultsOf`) - 更高效灵活的并发执行策略,如 - - `allResultsOfFastFail`/`allFastFailOf`方法:有`CF`失败时快速返回,而不再等待所有`CF`运行完成(`allOf`) + - `allResultsFastFailOf`/`allFastFailOf`方法:有`CF`失败时快速返回,而不再等待所有`CF`运行完成(`allOf`) - `anySuccessOf`方法:返回首个成功的`CF`结果,而不是首个完成(但可能失败)的`CF`(`anyOf`) - `mostSuccessResultsOf`方法:返回指定时间内成功`CF`的结果,忽略失败或还没有运行完成的`CF`(使用缺省值) - 更安全的使用方式,如 @@ -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,12 +416,12 @@ public class DefaultExecutorSettingForCffu { > \# 完整可运行的Demo代码参见[`DefaultExecutorSettingForCffu.java`](cffu-core/src/test/java/io/foldright/demo/DefaultExecutorSettingForCffu.java)。 -### 2.3 高效灵活的并发执行策略(`allResultsOfFastFail`/`anySuccessOf`/`mostSuccessResultsOf`) +### 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`提供了相应的`anySuccessOf`方法 @@ -452,7 +452,7 @@ public class ConcurrencyStrategyDemo { public static void main(String[] args) throws Exception { //////////////////////////////////////////////////////////////////////// - // CffuFactory#allResultsOfFastFail + // CffuFactory#allResultsFastFailOf // CffuFactory#anySuccessOf //////////////////////////////////////////////////////////////////////// final Cffu successAfterLongTime = cffuFactory.supplyAsync(() -> { @@ -464,7 +464,7 @@ public class ConcurrencyStrategyDemo { // Result type is Void! 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()); @@ -472,7 +472,7 @@ public class ConcurrencyStrategyDemo { System.out.println(anySuccessOf.get()); //////////////////////////////////////////////////////////////////////// - // or CompletableFutureUtils#allFastFailOf / allResultsOfFastFail + // or CompletableFutureUtils#allFastFailOf / allResultsFastFailOf // CompletableFutureUtils#anySuccessOf //////////////////////////////////////////////////////////////////////// final CompletableFuture successAfterLongTimeCf = CompletableFuture.supplyAsync(() -> { @@ -484,7 +484,7 @@ public class ConcurrencyStrategyDemo { // Result type is Void! 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)); 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 c1ff72bc..667e52dd 100644 --- a/cffu-core/src/main/java/io/foldright/cffu/CffuFactory.java +++ b/cffu-core/src/main/java/io/foldright/cffu/CffuFactory.java @@ -161,7 +161,7 @@ public Cffu runAsync(Runnable action, Executor executor) { * @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) { @@ -177,7 +177,7 @@ public final Cffu> mSupplyFastFailAsync(Supplier... sup * @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) { @@ -329,7 +329,7 @@ public Cffu mRunAsync(Executor executor, Runnable... actions) { * in the same order of the given Suppliers arguments. * * @return the new Cffu - * @see #allResultsOfFastFail(CompletionStage[]) + * @see #allResultsFastFailOf(CompletionStage[]) */ public Cffu> tupleMSupplyFastFailAsync( Supplier supplier1, Supplier supplier2) { @@ -343,7 +343,7 @@ public Cffu> tupleMSupplyFastFailAsync( * * @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) { @@ -356,7 +356,7 @@ public Cffu> tupleMSupplyFastFailAsync( * in the same order of the given Suppliers arguments. * * @return the new Cffu - * @see #allResultsOfFastFail(CompletionStage[]) + * @see #allResultsFastFailOf(CompletionStage[]) */ public Cffu> tupleMSupplyFastFailAsync( Supplier supplier1, Supplier supplier2, Supplier supplier3) { @@ -370,7 +370,7 @@ public Cffu> tupleMSupplyFastFailAsync( * * @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) { @@ -383,7 +383,7 @@ public Cffu> tupleMSupplyFastFailAsync( * in the same order of the given Suppliers arguments. * * @return the new Cffu - * @see #allResultsOfFastFail(CompletionStage[]) + * @see #allResultsFastFailOf(CompletionStage[]) */ public Cffu> tupleMSupplyFastFailAsync( Supplier supplier1, Supplier supplier2, @@ -398,7 +398,7 @@ public Cffu> tupleMSupplyFastFailAsync( * * @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, @@ -412,7 +412,7 @@ public Cffu> tupleMSupplyFastFailAsync( * in the same order of the given Suppliers arguments. * * @return the new Cffu - * @see #allResultsOfFastFail(CompletionStage[]) + * @see #allResultsFastFailOf(CompletionStage[]) */ public Cffu> tupleMSupplyFastFailAsync( Supplier supplier1, Supplier supplier2, @@ -427,7 +427,7 @@ public Cffu> tupleMSupplyFastFai * * @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, @@ -679,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)); } /** @@ -735,9 +735,9 @@ 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) *
*

@@ -849,12 +849,12 @@ public final Cffu anyOf(CompletionStage... cfs) { * * @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)); } /** @@ -864,12 +864,12 @@ public Cffu> allTupleOfFastFail( * * @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)); } /** @@ -879,13 +879,13 @@ public Cffu> allTupleOfFastFail( * * @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)); } /** @@ -895,13 +895,13 @@ public Cffu> allTupleOfFastFail( * * @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)); } /** 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 e490a871..c392abac 100644 --- a/cffu-core/src/main/java/io/foldright/cffu/CompletableFutureUtils.java +++ b/cffu-core/src/main/java/io/foldright/cffu/CompletableFutureUtils.java @@ -44,7 +44,7 @@ public final class CompletableFutureUtils { * @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 @@ -61,7 +61,7 @@ public static CompletableFuture> mSupplyFastFailAsync(Supplier the suppliers' return type * @return the new CompletableFuture - * @see #allResultsOfFastFail(CompletionStage[]) + * @see #allResultsFastFailOf(CompletionStage[]) * @see CompletableFuture#supplyAsync(Supplier, Executor) */ @SafeVarargs @@ -70,7 +70,7 @@ public static CompletableFuture> mSupplyFastFailAsync( requireNonNull(executor, "executor is null"); requireArrayAndEleNonNull("supplier", suppliers); - return allResultsOfFastFail(wrapSuppliers(executor, suppliers)); + return allResultsFastFailOf(wrapSuppliers(executor, suppliers)); } /** @@ -267,7 +267,7 @@ private static CompletableFuture[] wrapRunnables(Executor executor, Runnab * in the same order of the given Suppliers arguments. * * @return the new CompletableFuture - * @see #allResultsOfFastFail(CompletionStage[]) + * @see #allResultsFastFailOf(CompletionStage[]) * @see CompletableFuture#supplyAsync(Supplier) */ public static CompletableFuture> tupleMSupplyFastFailAsync( @@ -282,7 +282,7 @@ public static CompletableFuture> tupleMSupplyFastFailAsy * * @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( @@ -300,7 +300,7 @@ public static CompletableFuture> tupleMSupplyFastFailAsy * in the same order of the given Suppliers arguments. * * @return the new CompletableFuture - * @see #allResultsOfFastFail(CompletionStage[]) + * @see #allResultsFastFailOf(CompletionStage[]) * @see CompletableFuture#supplyAsync(Supplier) */ public static CompletableFuture> tupleMSupplyFastFailAsync( @@ -315,7 +315,7 @@ public static CompletableFuture> tupleMSupplyFas * * @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( @@ -334,7 +334,7 @@ public static CompletableFuture> tupleMSupplyFas * in the same order of the given Suppliers arguments. * * @return the new CompletableFuture - * @see #allResultsOfFastFail(CompletionStage[]) + * @see #allResultsFastFailOf(CompletionStage[]) * @see CompletableFuture#supplyAsync(Supplier) */ public static CompletableFuture> tupleMSupplyFastFailAsync( @@ -350,7 +350,7 @@ public static CompletableFuture> tupleMS * * @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( @@ -369,7 +369,7 @@ public static CompletableFuture> tupleMS * in the same order of the given Suppliers arguments. * * @return the new CompletableFuture - * @see #allResultsOfFastFail(CompletionStage[]) + * @see #allResultsFastFailOf(CompletionStage[]) * @see CompletableFuture#supplyAsync(Supplier) */ public static CompletableFuture> tupleMSupplyFastFailAsync( @@ -385,7 +385,7 @@ public static CompletableFuture> * * @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( @@ -781,7 +781,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()); @@ -905,9 +905,9 @@ 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) *
*

@@ -1187,10 +1187,10 @@ public static CompletableFuture anyOf(CompletionStage... cfs * * @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)); } @@ -1202,10 +1202,10 @@ public static CompletableFuture> allTupleOfFastFail( * * @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)); } @@ -1217,10 +1217,10 @@ public static CompletableFuture> allTupleOfFastF * * @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)); @@ -1233,10 +1233,10 @@ public static CompletableFuture> allTupl * * @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)); @@ -1617,7 +1617,7 @@ public static CompletableFuture> thenMApplyFastFailAsync( requireNonNull(executor, "executor is null"); requireArrayAndEleNonNull("fn", fns); - return cfThis.thenCompose(v -> allResultsOfFastFail(wrapFunctions(executor, v, fns))); + return cfThis.thenCompose(v -> allResultsFastFailOf(wrapFunctions(executor, v, fns))); } /** 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 8da2177f..35fb0cc2 100644 --- a/cffu-core/src/test/java/io/foldright/cffu/CffuFactoryTest.java +++ b/cffu-core/src/test/java/io/foldright/cffu/CffuFactoryTest.java @@ -281,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() ); } @@ -310,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) @@ -559,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), @@ -588,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), @@ -616,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), 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 eafcd97d..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()); //////////////////////////////////////////////////////////////////////////////// @@ -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() @@ -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()); } 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 857eccda..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,7 +16,7 @@ public class ConcurrencyStrategyDemo { public static void main(String[] args) throws Exception { //////////////////////////////////////////////////////////////////////// - // CffuFactory#allFastFailOf / allResultsOfFastFail + // CffuFactory#allFastFailOf / allResultsFastFailOf // CffuFactory#anySuccessOf //////////////////////////////////////////////////////////////////////// final Cffu successAfterLongTime = cffuFactory.supplyAsync(() -> { @@ -28,7 +28,7 @@ public static void main(String[] args) throws Exception { // Result type is Void! 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()); @@ -36,7 +36,7 @@ public static void main(String[] args) throws Exception { System.out.println(anySuccessOf.get()); //////////////////////////////////////////////////////////////////////// - // or CompletableFutureUtils#allFastFailOf / allResultsOfFastFail + // or CompletableFutureUtils#allFastFailOf / allResultsFastFailOf // CompletableFutureUtils#anySuccessOf //////////////////////////////////////////////////////////////////////// final CompletableFuture successAfterLongTimeCf = CompletableFuture.supplyAsync(() -> { @@ -48,7 +48,7 @@ public static void main(String[] args) throws Exception { // Result type is Void! 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)); 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 1b80bdf7..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 @@ -71,18 +71,18 @@ private const val ERROR_MSG_FOR_ARRAY = "no cffuFactory argument provided when t * * 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. * * 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 allFastFailOfCffu - * @see CffuFactory.allResultsOfFastFail + * @see CffuFactory.allResultsFastFailOf */ -fun Collection>.allResultsOfFastFailCffu(cffuFactory: CffuFactory = ABSENT): Cffu> { +fun Collection>.allResultsFastFailOfCffu(cffuFactory: CffuFactory = ABSENT): Cffu> { val factory: CffuFactory = if (cffuFactory !== ABSENT) cffuFactory else firstOrNull()?.cffuFactory() ?: throw IllegalArgumentException(ERROR_MSG_FOR_COLL) - return factory.allResultsOfFastFail(*toTypedArray()) + return factory.allResultsFastFailOf(*toTypedArray()) } /** @@ -95,18 +95,18 @@ fun Collection>.allResultsOfFastFailCffu(cffuFactory: CffuFactor * * 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. * * 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 allFastFailOfCffu - * @see CffuFactory.allResultsOfFastFail + * @see CffuFactory.allResultsFastFailOf */ -fun Array>.allResultsOfFastFailCffu(cffuFactory: CffuFactory = ABSENT): Cffu> { +fun Array>.allResultsFastFailOfCffu(cffuFactory: CffuFactory = ABSENT): Cffu> { val factory: CffuFactory = if (cffuFactory !== ABSENT) cffuFactory else firstOrNull()?.cffuFactory() ?: throw IllegalArgumentException(ERROR_MSG_FOR_ARRAY) - return factory.allResultsOfFastFail(*this) + return factory.allResultsFastFailOf(*this) } /** @@ -119,14 +119,14 @@ fun Array>.allResultsOfFastFailCffu(cffuFactory: CffuFactory * * 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 allFastFailOfCffu - * @see CffuFactory.allResultsOfFastFail + * @see CffuFactory.allResultsFastFailOf */ -@JvmName("allResultsOfFastFailCffuCs") -fun 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, @@ -138,13 +138,13 @@ fun Collection>.allResultsOfFastFailCffu(cffuFactory: * * 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 allFastFailOfCffu - * @see CffuFactory.allResultsOfFastFail + * @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 @@ -321,7 +321,7 @@ fun Array>.allResultsOfCffu(cffuFactory: CffuFact * 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 allResultsFastFailOfCffu * @see CffuFactory.allFastFailOf */ fun Collection>.allFastFailOfCffu(cffuFactory: CffuFactory = ABSENT): Cffu { @@ -344,7 +344,7 @@ fun Collection>.allFastFailOfCffu(cffuFactory: CffuFactory = ABSENT): Cf * 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 allResultsFastFailOfCffu * @see CffuFactory.allFastFailOf */ fun Array>.allFastFailOfCffu(cffuFactory: CffuFactory = ABSENT): Cffu { @@ -364,7 +364,7 @@ fun Array>.allFastFailOfCffu(cffuFactory: CffuFactory = ABSENT): Cff * * This method is the same as [CffuFactory.allFastFailOf], providing this method is convenient for method chaining. * - * @see allResultsOfFastFailCffu + * @see allResultsFastFailOfCffu * @see CffuFactory.allFastFailOf */ @JvmName("allFastFailOfCffuCs") @@ -382,7 +382,7 @@ fun Collection>.allFastFailOfCffu(cffuFactory: CffuFactory): * * This method is the same as [CffuFactory.allFastFailOf], providing this method is convenient for method chaining. * - * @see allResultsOfFastFailCffu + * @see allResultsFastFailOfCffu * @see CffuFactory.allFastFailOf */ fun Array>.allFastFailOfCffu(cffuFactory: CffuFactory): Cffu = 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 44b180d7..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 @@ -34,13 +34,13 @@ import java.util.function.Function * 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 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 @@ -53,13 +53,13 @@ fun Collection>.allResultsOfFastFailCompletableFuture * 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 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 @@ -176,12 +176,12 @@ fun Array>.allResultsOfCompletableFuture(): Compl * * If you need the results of given stages, prefer below methods: * - * - [allResultsOfFastFailCompletableFuture] + * - [allResultsFastFailOfCompletableFuture] * * This method is the same as [CompletableFutureUtils.allFastFailOf], * providing this method is convenient for method chaining. * - * @see allResultsOfFastFailCompletableFuture + * @see allResultsFastFailOfCompletableFuture */ fun Collection>.allFastFailOfCompletableFuture(): CompletableFuture = CompletableFutureUtils.allFastFailOf(*toTypedArray()) @@ -197,12 +197,12 @@ fun Collection>.allFastFailOfCompletableFuture(): Completable * * If you need the results of given stages, prefer below methods: * - * - [allResultsOfFastFailCompletableFuture] + * - [allResultsFastFailOfCompletableFuture] * * This method is the same as [CompletableFutureUtils.allFastFailOf], * providing this method is convenient for method chaining. * - * @see allResultsOfFastFailCompletableFuture + * @see allResultsFastFailOfCompletableFuture */ fun Array>.allFastFailOfCompletableFuture(): CompletableFuture = CompletableFutureUtils.allFastFailOf(*this) 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 fe685730..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) //////////////////////////////////////// @@ -593,10 +593,10 @@ 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.allFastFailOfCffu() } assertCffuFactoryForOptional(list.allFastFailOfCffu()) 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 14ccedca..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() ////////////////////////////////////////