Skip to content

Commit

Permalink
refactor: move default value argument forward ⚠️
Browse files Browse the repository at this point in the history
Because the nullable default value argument and last varargs are not distinguished by compiler,
missing the default argument can NOT point out at compile-time.
  • Loading branch information
oldratlee committed Jun 22, 2024
1 parent d9135ff commit 4343f1f
Show file tree
Hide file tree
Showing 8 changed files with 102 additions and 110 deletions.
22 changes: 11 additions & 11 deletions cffu-core/src/main/java/io/foldright/cffu/CffuFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ public final <T> Cffu<T>[] toCffuArray(CompletionStage<T>... stages) {
* <p>
* If you need the successful results of given stages in the given time, prefer below methods:
* <ul>
* <li>{@link #mostResultsOfSuccess(long, TimeUnit, Object, CompletionStage[])}
* <li>{@link #mostResultsOfSuccess(Object, long, TimeUnit, CompletionStage[])}
* <li>{@link #mostTupleOfSuccess(long, TimeUnit, CompletionStage, CompletionStage)}
* <li>{@link #mostTupleOfSuccess(long, TimeUnit, CompletionStage, CompletionStage, CompletionStage, CompletionStage, CompletionStage)}
* </ul>
Expand All @@ -314,7 +314,7 @@ public final <T> Cffu<T>[] toCffuArray(CompletionStage<T>... stages) {
* @see #allResultsOf(CompletionStage[])
* @see #allTupleOf(CompletionStage, CompletionStage)
* @see #allTupleOf(CompletionStage, CompletionStage, CompletionStage, CompletionStage, CompletionStage)
* @see #mostResultsOfSuccess(long, TimeUnit, Object, CompletionStage[])
* @see #mostResultsOfSuccess(Object, long, TimeUnit, CompletionStage[])
* @see #mostTupleOfSuccess(long, TimeUnit, CompletionStage, CompletionStage)
* @see #mostTupleOfSuccess(long, TimeUnit, CompletionStage, CompletionStage, CompletionStage, CompletionStage, CompletionStage)
* @see CompletableFutureUtils#allOf(CompletionStage[])
Expand Down Expand Up @@ -366,7 +366,7 @@ public final <T> Cffu<List<T>> allResultsOf(CompletionStage<? extends T>... cfs)
* <p>
* If you need the successful results of given stages in the given time, prefer below methods:
* <ul>
* <li>{@link #mostResultsOfSuccess(long, TimeUnit, Object, CompletionStage[])}
* <li>{@link #mostResultsOfSuccess(Object, long, TimeUnit, CompletionStage[])}
* <li>{@link #mostTupleOfSuccess(long, TimeUnit, CompletionStage, CompletionStage)}
* <li>{@link #mostTupleOfSuccess(long, TimeUnit, CompletionStage, CompletionStage, CompletionStage, CompletionStage, CompletionStage)}
* </ul>
Expand All @@ -377,7 +377,7 @@ public final <T> Cffu<List<T>> allResultsOf(CompletionStage<? extends T>... cfs)
* @see #allResultsOfFastFail(CompletionStage[])
* @see #allTupleOfFastFail(CompletionStage, CompletionStage)
* @see #allTupleOfFastFail(CompletionStage, CompletionStage, CompletionStage, CompletionStage, CompletionStage)
* @see #mostResultsOfSuccess(long, TimeUnit, Object, CompletionStage[])
* @see #mostResultsOfSuccess(Object, long, TimeUnit, CompletionStage[])
* @see #mostTupleOfSuccess(long, TimeUnit, CompletionStage, CompletionStage)
* @see #mostTupleOfSuccess(long, TimeUnit, CompletionStage, CompletionStage, CompletionStage, CompletionStage, CompletionStage)
* @see #allOf(CompletionStage[])
Expand Down Expand Up @@ -418,18 +418,18 @@ public final <T> Cffu<List<T>> allResultsOfFastFail(CompletionStage<? extends T>
* <p>
* If the given stage is successful, its result is the completed value; Otherwise the given valueIfNotSuccess.
*
* @param valueIfNotSuccess the value to return if not completed successfully
* @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 valueIfNotSuccess the value to return if not completed successfully
* @param cfs the stages
* @see Cffu#getSuccessNow(Object)
*/
@Contract(pure = true)
@SafeVarargs
public final <T> Cffu<List<T>> mostResultsOfSuccess(
long timeout, TimeUnit unit, @Nullable T valueIfNotSuccess, CompletionStage<? extends T>... cfs) {
@Nullable T valueIfNotSuccess, long timeout, TimeUnit unit, CompletionStage<? extends T>... cfs) {
return create(CompletableFutureUtils.mostResultsOfSuccess(
defaultExecutor, timeout, unit, valueIfNotSuccess, cfs));
valueIfNotSuccess, defaultExecutor, timeout, unit, cfs));
}

////////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -636,7 +636,7 @@ public <T1, T2, T3, T4, T5> Cffu<Tuple5<T1, T2, T3, T4, T5>> 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(long, TimeUnit, Object, CompletionStage[])
* @see #mostResultsOfSuccess(Object, long, TimeUnit, CompletionStage[])
* @see Cffu#getSuccessNow(Object)
*/
@Contract(pure = true)
Expand All @@ -654,7 +654,7 @@ public <T1, T2> Cffu<Tuple2<T1, T2>> 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(long, TimeUnit, Object, CompletionStage[])
* @see #mostResultsOfSuccess(Object, long, TimeUnit, CompletionStage[])
* @see Cffu#getSuccessNow(Object)
*/
@Contract(pure = true)
Expand All @@ -673,7 +673,7 @@ public <T1, T2, T3> Cffu<Tuple3<T1, T2, T3>> 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(long, TimeUnit, Object, CompletionStage[])
* @see #mostResultsOfSuccess(Object, long, TimeUnit, CompletionStage[])
* @see Cffu#getSuccessNow(Object)
*/
@Contract(pure = true)
Expand All @@ -693,7 +693,7 @@ public <T1, T2, T3, T4> Cffu<Tuple4<T1, T2, T3, T4>> 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(long, TimeUnit, Object, CompletionStage[])
* @see #mostResultsOfSuccess(Object, long, TimeUnit, CompletionStage[])
* @see Cffu#getSuccessNow(Object)
*/
@Contract(pure = true)
Expand Down
Loading

0 comments on commit 4343f1f

Please sign in to comment.