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 bdd565ad..263a904d 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 @@ -40,7 +40,7 @@ import java.util.concurrent.TimeUnit * @see allOfCffu * @see allOfCompletableFutureVoid */ -fun Collection>.allOfCompletableFuture(): CompletableFuture> = +fun Collection>.allOfCompletableFuture(): CompletableFuture> = CompletableFutureUtils.allResultsOf(*this.toTypedArray()) /** @@ -57,7 +57,7 @@ fun Collection>.allOfCompletableFuture(): CompletableFu * @see allOfCffu * @see allOfCompletableFutureVoid */ -fun Array>.allOfCompletableFuture(): CompletableFuture> = +fun Array>.allOfCompletableFuture(): CompletableFuture> = CompletableFutureUtils.allResultsOf(*this) /** @@ -119,7 +119,7 @@ fun Array>.allOfCompletableFutureVoid(): CompletableFut * @see allOfFastFailCffu * @see allOfFastFailCompletableFutureVoid */ -fun Collection>.allOfFastFailCompletableFuture(): CompletableFuture> = +fun Collection>.allOfFastFailCompletableFuture(): CompletableFuture> = CompletableFutureUtils.allResultsOfFastFail(*this.toTypedArray()) /** @@ -137,7 +137,7 @@ fun Collection>.allOfFastFailCompletableFuture(): Compl * @see allOfFastFailCffu * @see allOfFastFailCompletableFutureVoid */ -fun Array>.allOfFastFailCompletableFuture(): CompletableFuture> = +fun Array>.allOfFastFailCompletableFuture(): CompletableFuture> = CompletableFutureUtils.allResultsOfFastFail(*this) /** @@ -185,7 +185,6 @@ fun Array>.allOfFastFailCompletableFutureVoid(): Comple // - anyOfCompletableFuture // - anyOfCompletableFutureAny // - anyOfSuccessCompletableFuture -// - anyOfSuccessCompletableFutureAny //////////////////////////////////////// /** @@ -195,13 +194,11 @@ fun Array>.allOfFastFailCompletableFutureVoid(): Comple * with a CompletionException holding this exception as its cause. * If no CompletableFutures are provided, returns an incomplete CompletableFuture. * - * Same as [anyOfCompletableFutureAny], but return result type is specified type instead of type `Any`. * Same as [CompletableFutureUtils.anyOf], providing this method is convenient for method chaining. * * @see anyOfCffu - * @see anyOfCompletableFutureAny */ -fun Collection>.anyOfCompletableFuture(): CompletableFuture = +fun Collection>.anyOfCompletableFuture(): CompletableFuture = CompletableFutureUtils.anyOf(*this.toTypedArray()) /** @@ -211,49 +208,13 @@ fun Collection>.anyOfCompletableFuture(): CompletableFu * with a CompletionException holding this exception as its cause. * If no CompletableFutures are provided, returns an incomplete CompletableFuture. * - * Same as [anyOfCompletableFutureAny], but return result type is specified type instead of type `Any`. * Same as [CompletableFutureUtils.anyOf], providing this method is convenient for method chaining. * * @see anyOfCffu - * @see anyOfCompletableFutureAny */ -fun Array>.anyOfCompletableFuture(): CompletableFuture = +fun Array>.anyOfCompletableFuture(): CompletableFuture = CompletableFutureUtils.anyOf(*this) -/** - * Returns a new CompletableFuture that is completed - * when any of the given CompletableFutures complete, with the same result. - * Otherwise, if it completed exceptionally, the returned CompletableFuture also does so, - * with a CompletionException holding this exception as its cause. - * If no CompletableFutures are provided, returns an incomplete CompletableFuture. - * - * Same as [CompletableFuture.anyOf], providing this method is convenient for method chaining. - * - * @see anyOfCffu - * @see anyOfCffuAny - * @see anyOfCompletableFuture - * @see CompletableFuture.anyOf - */ -fun Collection>.anyOfCompletableFutureAny(): CompletableFuture = - CompletableFuture.anyOf(*this.toTypedArray()) - -/** - * Returns a new CompletableFuture that is completed - * when any of the given CompletableFutures complete, with the same result. - * Otherwise, if it completed exceptionally, the returned CompletableFuture also does so, - * with a CompletionException holding this exception as its cause. - * If no CompletableFutures are provided, returns an incomplete CompletableFuture. - * - * Same as [CompletableFuture.anyOf], providing this method is convenient for method chaining. - * - * @see anyOfCffu - * @see anyOfCffuAny - * @see anyOfCompletableFuture - * @see CompletableFuture.anyOf - */ -fun Array>.anyOfCompletableFutureAny(): CompletableFuture = - CompletableFuture.anyOf(*this) - /** * Returns a new CompletableFuture that is successful when any of the given CompletableFutures success, * with the same result. Otherwise, all the given CompletableFutures complete exceptionally, @@ -262,13 +223,12 @@ fun Array>.anyOfCompletableFutureAny(): CompletableFutu * returns a new CompletableFuture that is already completed exceptionally with a CompletionException * holding a [NoCfsProvidedException][io.foldright.cffu.NoCfsProvidedException] as its cause. * - * Same as [anyOfSuccessCompletableFutureAny], but return result type is specified type instead of type `Any`. * Same as [CompletableFutureUtils.anyOfSuccess], providing this method is convenient for method chaining. * * @see anyOfCompletableFuture * @see CompletableFutureUtils.anyOfSuccess */ -fun Collection>.anyOfSuccessCompletableFuture(): CompletableFuture = +fun Collection>.anyOfSuccessCompletableFuture(): CompletableFuture = CompletableFutureUtils.anyOfSuccess(*this.toTypedArray()) /** @@ -279,47 +239,12 @@ fun Collection>.anyOfSuccessCompletableFuture(): Comple * returns a new CompletableFuture that is already completed exceptionally with a CompletionException * holding a [NoCfsProvidedException][io.foldright.cffu.NoCfsProvidedException] as its cause. * - * Same as [anyOfSuccessCompletableFutureAny], but return result type is specified type instead of type `Any`. - * Same as [CompletableFutureUtils.anyOfSuccess], providing this method is convenient for method chaining. - * - * @see anyOfCompletableFuture - * @see CompletableFutureUtils.anyOfSuccess - */ -fun Array>.anyOfSuccessCompletableFuture(): CompletableFuture = - CompletableFutureUtils.anyOfSuccess(*this) - -/** - * Returns a new CompletableFuture that is successful when any of the given CompletableFutures success, - * with the same result. Otherwise, all the given CompletableFutures complete exceptionally, - * the returned CompletableFuture also does so, with a CompletionException holding - * an exception from any of the given CompletableFutures as its cause. If no CompletableFutures are provided, - * returns a new CompletableFuture that is already completed exceptionally with a CompletionException - * holding a [NoCfsProvidedException][io.foldright.cffu.NoCfsProvidedException] as its cause. - * - * Same as [CompletableFutureUtils.anyOfSuccess], providing this method is convenient for method chaining. - * - * @see anyOfSuccessCffu - * @see anyOfCompletableFuture - * @see CompletableFutureUtils.anyOfSuccess - */ -fun Collection>.anyOfSuccessCompletableFutureAny(): CompletableFuture = - CompletableFutureUtils.anyOfSuccess(*this.toTypedArray()) - -/** - * Returns a new CompletableFuture that is successful when any of the given CompletableFutures success, - * with the same result. Otherwise, all the given CompletableFutures complete exceptionally, - * the returned CompletableFuture also does so, with a CompletionException holding - * an exception CompletableFuture any of the given CompletableFutures as its cause. If no CompletableFutures are provided, - * returns a new Cffu that is already completed exceptionally with a CompletionException - * holding a [NoCfsProvidedException][io.foldright.cffu.NoCfsProvidedException] as its cause. - * * Same as [CompletableFutureUtils.anyOfSuccess], providing this method is convenient for method chaining. * - * @see anyOfSuccessCffu * @see anyOfCompletableFuture * @see CompletableFutureUtils.anyOfSuccess */ -fun Array>.anyOfSuccessCompletableFutureAny(): CompletableFuture = +fun Array>.anyOfSuccessCompletableFuture(): CompletableFuture = CompletableFutureUtils.anyOfSuccess(*this) //////////////////////////////////////// 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 1af93fbf..2eb7aaac 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 @@ -139,21 +139,21 @@ class CompletableFutureExtensionsTest : FunSpec({ CompletableFuture(), CompletableFuture(), CompletableFuture.completedFuture(42), - ).anyOfCompletableFutureAny().await() shouldBe 42 - listOf>().anyOfCompletableFutureAny().isDone.shouldBeFalse() + ).anyOfCompletableFuture().await() shouldBe 42 + listOf>().anyOfCompletableFuture().isDone.shouldBeFalse() setOf( CompletableFuture(), CompletableFuture(), CompletableFuture.completedFuture(42), - ).anyOfCompletableFutureAny().await() shouldBe 42 + ).anyOfCompletableFuture().await() shouldBe 42 arrayOf( CompletableFuture(), CompletableFuture(), CompletableFuture.completedFuture(42), - ).anyOfCompletableFutureAny().await() shouldBe 42 - arrayOf>().anyOfCompletableFutureAny().isDone.shouldBeFalse() + ).anyOfCompletableFuture().await() shouldBe 42 + arrayOf>().anyOfCompletableFuture().isDone.shouldBeFalse() //////////////////////////////////////// @@ -187,24 +187,24 @@ class CompletableFutureExtensionsTest : FunSpec({ CompletableFuture(), CompletableFuture(), CompletableFuture.completedFuture(42), - ).anyOfSuccessCompletableFutureAny().await() shouldBe 42 + ).anyOfSuccessCompletableFuture().await() shouldBe 42 shouldThrow { - listOf>().anyOfSuccessCompletableFutureAny().await() + listOf>().anyOfSuccessCompletableFuture().await() } setOf( CompletableFuture(), CompletableFuture(), CompletableFuture.completedFuture(42), - ).anyOfSuccessCompletableFutureAny().await() shouldBe 42 + ).anyOfSuccessCompletableFuture().await() shouldBe 42 arrayOf( CompletableFuture(), CompletableFuture(), CompletableFuture.completedFuture(42), - ).anyOfSuccessCompletableFutureAny().await() shouldBe 42 + ).anyOfSuccessCompletableFuture().await() shouldBe 42 shouldThrow { - arrayOf>().anyOfSuccessCompletableFutureAny().await() + arrayOf>().anyOfSuccessCompletableFuture().await() } }