Skip to content

Commit

Permalink
refactor: reorder tupleM* methods 🚞
Browse files Browse the repository at this point in the history
  • Loading branch information
oldratlee committed Jun 22, 2024
1 parent 175b628 commit 7de3fe5
Show file tree
Hide file tree
Showing 2 changed files with 486 additions and 471 deletions.
253 changes: 129 additions & 124 deletions cffu-core/src/main/java/io/foldright/cffu/CffuFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,135 @@ public Cffu<Void> runAsync(Runnable action, Executor executor) {
return create(CompletableFuture.runAsync(action, executor));
}

// endregion
////////////////////////////////////////////////////////////
// region## Multi-Actions(M*) Methods(create by 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 <strong>same order</strong> of the given Suppliers arguments.
* <p>
* This method is the same as {@link #allTupleOfMSupplyAsync(Supplier, Supplier)} except for the fast-fail behavior.
*
* @return the new Cffu
* @see #allResultsOfFastFail(CompletionStage[])
*/
@Contract(pure = true)
public <T1, T2> Cffu<Tuple2<T1, T2>> allTupleOfMSupplyFastFailAsync(
Supplier<? extends T1> supplier1, Supplier<? extends T2> supplier2) {
return create(CompletableFutureUtils.allTupleOfMSupplyFastFailAsync(supplier1, supplier2));
}

/**
* 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 <strong>same order</strong> of the given Suppliers arguments.
* <p>
* This method is the same as {@link #allTupleOfMSupplyAsync(Supplier, Supplier, Supplier)} except for the fast-fail behavior.
*
* @return the new Cffu
* @see #allResultsOfFastFail(CompletionStage[])
*/
@Contract(pure = true)
public <T1, T2, T3> Cffu<Tuple3<T1, T2, T3>> allTupleOfMSupplyFastFailAsync(
Supplier<? extends T1> supplier1, Supplier<? extends T2> supplier2, Supplier<? extends T3> supplier3) {
return create(CompletableFutureUtils.allTupleOfMSupplyFastFailAsync(supplier1, supplier2, supplier3));
}

/**
* 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 <strong>same order</strong> of the given Suppliers arguments.
* <p>
* This method is the same as {@link #allTupleOfMSupplyAsync(Supplier, Supplier, Supplier, Supplier)} except for the fast-fail behavior.
*
* @return the new Cffu
* @see #allResultsOfFastFail(CompletionStage[])
*/
@Contract(pure = true)
public <T1, T2, T3, T4> Cffu<Tuple4<T1, T2, T3, T4>> allTupleOfMSupplyFastFailAsync(
Supplier<? extends T1> supplier1, Supplier<? extends T2> supplier2,
Supplier<? extends T3> supplier3, Supplier<? extends T4> supplier4) {
return create(CompletableFutureUtils.allTupleOfMSupplyFastFailAsync(supplier1, supplier2, supplier3, supplier4));
}

/**
* 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 <strong>same order</strong> of the given Suppliers arguments.
* <p>
* This method is the same as {@link #allTupleOfMSupplyAsync(Supplier, Supplier, Supplier, Supplier, Supplier)} except for the fast-fail behavior.
*
* @return the new Cffu
* @see #allResultsOfFastFail(CompletionStage[])
*/
@Contract(pure = true)
public <T1, T2, T3, T4, T5> Cffu<Tuple5<T1, T2, T3, T4, T5>> allTupleOfMSupplyFastFailAsync(
Supplier<? extends T1> supplier1, Supplier<? extends T2> supplier2, Supplier<? extends T3> supplier3,
Supplier<? extends T4> supplier4, Supplier<? extends T5> supplier5) {
return create(CompletableFutureUtils.allTupleOfMSupplyFastFailAsync(supplier1, supplier2, supplier3, supplier4, supplier5));
}

/**
* 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 <strong>same order</strong> of the given Suppliers arguments.
*
* @return the new Cffu
* @see #allResultsOf(CompletionStage[])
*/
@Contract(pure = true)
public <T1, T2> Cffu<Tuple2<T1, T2>> allTupleOfMSupplyAsync(
Supplier<? extends T1> supplier1, Supplier<? extends T2> supplier2) {
return create(CompletableFutureUtils.allTupleOfMSupplyAsync(supplier1, supplier2));
}

/**
* 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 <strong>same order</strong> of the given Suppliers arguments.
*
* @return the new Cffu
* @see #allResultsOf(CompletionStage[])
*/
@Contract(pure = true)
public <T1, T2, T3> Cffu<Tuple3<T1, T2, T3>> allTupleOfMSupplyAsync(
Supplier<? extends T1> supplier1, Supplier<? extends T2> supplier2, Supplier<? extends T3> supplier3) {
return create(CompletableFutureUtils.allTupleOfMSupplyAsync(supplier1, supplier2, supplier3));
}

/**
* 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 <strong>same order</strong> of the given Suppliers arguments.
*
* @return the new Cffu
* @see #allResultsOf(CompletionStage[])
*/
@Contract(pure = true)
public <T1, T2, T3, T4> Cffu<Tuple4<T1, T2, T3, T4>> allTupleOfMSupplyAsync(
Supplier<? extends T1> supplier1, Supplier<? extends T2> supplier2,
Supplier<? extends T3> supplier3, Supplier<? extends T4> supplier4) {
return create(CompletableFutureUtils.allTupleOfMSupplyAsync(supplier1, supplier2, supplier3, supplier4));
}

/**
* 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 <strong>same order</strong> of the given Suppliers arguments.
*
* @return the new Cffu
* @see #allResultsOf(CompletionStage[])
*/
@Contract(pure = true)
public <T1, T2, T3, T4, T5> Cffu<Tuple5<T1, T2, T3, T4, T5>> allTupleOfMSupplyAsync(
Supplier<? extends T1> supplier1, Supplier<? extends T2> supplier2, Supplier<? extends T3> supplier3,
Supplier<? extends T4> supplier4, Supplier<? extends T5> supplier5) {
return create(CompletableFutureUtils.allTupleOfMSupplyAsync(supplier1, supplier2, supplier3, supplier4, supplier5));
}

// endregion
////////////////////////////////////////////////////////////////////////////////
// region## allOf* Methods(including mostResultsOfSuccess)
Expand Down Expand Up @@ -547,130 +676,6 @@ public <T1, T2, T3, T4, T5> Cffu<Tuple5<T1, T2, T3, T4, T5>> mostTupleOfSuccess(
return create(CompletableFutureUtils.mostTupleOfSuccess(defaultExecutor, timeout, unit, cf1, cf2, cf3, cf4, cf5));
}

/**
* 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 <strong>same order</strong> of the given Suppliers arguments.
* <p>
* This method is the same as {@link #allTupleOfMSupplyAsync(Supplier, Supplier)} except for the fast-fail behavior.
*
* @return the new Cffu
* @see #allResultsOfFastFail(CompletionStage[])
*/
@Contract(pure = true)
public <T1, T2> Cffu<Tuple2<T1, T2>> allTupleOfMSupplyFastFailAsync(
Supplier<? extends T1> supplier1, Supplier<? extends T2> supplier2) {
return create(CompletableFutureUtils.allTupleOfMSupplyFastFailAsync(supplier1, supplier2));
}

/**
* 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 <strong>same order</strong> of the given Suppliers arguments.
*
* @return the new Cffu
* @see #allResultsOf(CompletionStage[])
*/
@Contract(pure = true)
public <T1, T2> Cffu<Tuple2<T1, T2>> allTupleOfMSupplyAsync(
Supplier<? extends T1> supplier1, Supplier<? extends T2> supplier2) {
return create(CompletableFutureUtils.allTupleOfMSupplyAsync(supplier1, supplier2));
}

/**
* 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 <strong>same order</strong> of the given Suppliers arguments.
* <p>
* This method is the same as {@link #allTupleOfMSupplyAsync(Supplier, Supplier, Supplier)} except for the fast-fail behavior.
*
* @return the new Cffu
* @see #allResultsOfFastFail(CompletionStage[])
*/
@Contract(pure = true)
public <T1, T2, T3> Cffu<Tuple3<T1, T2, T3>> allTupleOfMSupplyFastFailAsync(
Supplier<? extends T1> supplier1, Supplier<? extends T2> supplier2, Supplier<? extends T3> supplier3) {
return create(CompletableFutureUtils.allTupleOfMSupplyFastFailAsync(supplier1, supplier2, supplier3));
}

/**
* 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 <strong>same order</strong> of the given Suppliers arguments.
*
* @return the new Cffu
* @see #allResultsOf(CompletionStage[])
*/
@Contract(pure = true)
public <T1, T2, T3> Cffu<Tuple3<T1, T2, T3>> allTupleOfMSupplyAsync(
Supplier<? extends T1> supplier1, Supplier<? extends T2> supplier2, Supplier<? extends T3> supplier3) {
return create(CompletableFutureUtils.allTupleOfMSupplyAsync(supplier1, supplier2, supplier3));
}

/**
* 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 <strong>same order</strong> of the given Suppliers arguments.
* <p>
* This method is the same as {@link #allTupleOfMSupplyAsync(Supplier, Supplier, Supplier, Supplier)} except for the fast-fail behavior.
*
* @return the new Cffu
* @see #allResultsOfFastFail(CompletionStage[])
*/
@Contract(pure = true)
public <T1, T2, T3, T4> Cffu<Tuple4<T1, T2, T3, T4>> allTupleOfMSupplyFastFailAsync(
Supplier<? extends T1> supplier1, Supplier<? extends T2> supplier2,
Supplier<? extends T3> supplier3, Supplier<? extends T4> supplier4) {
return create(CompletableFutureUtils.allTupleOfMSupplyFastFailAsync(supplier1, supplier2, supplier3, supplier4));
}

/**
* 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 <strong>same order</strong> of the given Suppliers arguments.
*
* @return the new Cffu
* @see #allResultsOf(CompletionStage[])
*/
@Contract(pure = true)
public <T1, T2, T3, T4> Cffu<Tuple4<T1, T2, T3, T4>> allTupleOfMSupplyAsync(
Supplier<? extends T1> supplier1, Supplier<? extends T2> supplier2,
Supplier<? extends T3> supplier3, Supplier<? extends T4> supplier4) {
return create(CompletableFutureUtils.allTupleOfMSupplyAsync(supplier1, supplier2, supplier3, supplier4));
}

/**
* 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 <strong>same order</strong> of the given Suppliers arguments.
* <p>
* This method is the same as {@link #allTupleOfMSupplyAsync(Supplier, Supplier, Supplier, Supplier, Supplier)} except for the fast-fail behavior.
*
* @return the new Cffu
* @see #allResultsOfFastFail(CompletionStage[])
*/
@Contract(pure = true)
public <T1, T2, T3, T4, T5> Cffu<Tuple5<T1, T2, T3, T4, T5>> allTupleOfMSupplyFastFailAsync(
Supplier<? extends T1> supplier1, Supplier<? extends T2> supplier2, Supplier<? extends T3> supplier3,
Supplier<? extends T4> supplier4, Supplier<? extends T5> supplier5) {
return create(CompletableFutureUtils.allTupleOfMSupplyFastFailAsync(supplier1, supplier2, supplier3, supplier4, supplier5));
}

/**
* 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 <strong>same order</strong> of the given Suppliers arguments.
*
* @return the new Cffu
* @see #allResultsOf(CompletionStage[])
*/
@Contract(pure = true)
public <T1, T2, T3, T4, T5> Cffu<Tuple5<T1, T2, T3, T4, T5>> allTupleOfMSupplyAsync(
Supplier<? extends T1> supplier1, Supplier<? extends T2> supplier2, Supplier<? extends T3> supplier3,
Supplier<? extends T4> supplier4, Supplier<? extends T5> supplier5) {
return create(CompletableFutureUtils.allTupleOfMSupplyAsync(supplier1, supplier2, supplier3, supplier4, supplier5));
}

/**
* Returns a new Cffu that, when the given stage completes normally,
* is executed using the {@link #defaultExecutor()},
Expand Down
Loading

0 comments on commit 7de3fe5

Please sign in to comment.