@@ -35,6 +35,8 @@ public class Promises {
3535
3636 /**
3737 * Method to create a successfully resolved {@link Promise} with a value provided
38+ * @param <T>
39+ * a type of the value
3840 * @param value
3941 * a value to wrap
4042 * @return
@@ -61,6 +63,8 @@ public static Promise<?> failure(Throwable exception) {
6163
6264 /**
6365 * Adapts a stage passed to the {@link Promise} API
66+ * @param <T>
67+ * a type of the value
6468 * @param stage
6569 * a {@link CompletionStage} to be wrapped
6670 * @return
@@ -111,7 +115,9 @@ public boolean cancel(boolean mayInterruptIfRunning) {
111115 * if any promise completed exceptionally, then resulting promise is resolved faulty as well.
112116 * <p>The resolved result of this promise contains a list of the resolved results of the {@link CompletionStage}-s passed as an
113117 * argument at corresponding positions.
114- * <p>When resulting promise is resolved faulty, any remaining {@link CompletionStage}-s is cancelled.
118+ * <p>When resulting promise is resolved faulty, all remaining incomplete {@link CompletionStage}-s are cancelled.
119+ * @param <T>
120+ * a common supertype of the resulting values
115121 * @param promises
116122 * an array of {@link CompletionStage}-s to combine
117123 * @return
@@ -127,7 +133,10 @@ public static <T> Promise<List<T>> all(final CompletionStage<? extends T>... pro
127133 * if all promises completed exceptionally, then resulting promise is resolved faulty as well.
128134 * <p>The resolved result of this promise contains a value of the first resolved result of the {@link CompletionStage}-s passed as an
129135 * argument.
130- * <p>When resulting promise is resolved successfully, any remaining {@link CompletionStage}-s is cancelled.
136+ * <p>When resulting promise is resolved successfully, all remaining incomplete {@link CompletionStage}-s are cancelled.
137+ *
138+ * @param <T>
139+ * a common supertype of the resulting values
131140 * @param promises
132141 * an array of {@link CompletionStage}-s to combine
133142 * @return
@@ -144,7 +153,9 @@ public static <T> Promise<T> any(final CompletionStage<? extends T>... promises)
144153 * (unlike non-Strict variant, where exceptions are ignored if result is available at all).
145154 * <p>The resolved result of this promise contains a value of the first resolved result of the {@link CompletionStage}-s passed as an
146155 * argument.
147- * <p>When resulting promise is resolved either successfully or faulty, any remaining {@link CompletionStage}-s is cancelled.
156+ * <p>When resulting promise is resolved either successfully or faulty, all remaining incomplete {@link CompletionStage}-s are cancelled.
157+ * @param <T>
158+ * a common supertype of the resulting values
148159 * @param promises
149160 * an array of {@link CompletionStage}-s to combine
150161 * @return
@@ -162,8 +173,10 @@ public static <T> Promise<T> anyStrict(final CompletionStage<? extends T>... pro
162173 * is resolved faulty.
163174 * <p>The resolved result of this promise contains a list of the resolved results of the {@link CompletionStage}-s passed as an
164175 * argument at corresponding positions. Non-completed or completed exceptionally promises have <code>null</code> values.
165- * <p>When resulting promise is resolved successfully, any remaining {@link CompletionStage}-s is cancelled.
176+ * <p>When resulting promise is resolved successfully, all remaining incomplete {@link CompletionStage}-s are cancelled.
166177 *
178+ * @param <T>
179+ * a common supertype of the resulting values
167180 * @param minResultsCount
168181 * a minimum number of promises that should be completed normally to resolve resulting promise successfully
169182 * @param promises
@@ -184,8 +197,10 @@ public static <T> Promise<List<T>> atLeast(final int minResultsCount, final Comp
184197 * resulting promise is resolved faulty as well.
185198 * <p>The resolved result of this promise contains a list of the resolved results of the {@link CompletionStage}-s passed as an
186199 * argument at corresponding positions. Non-completed promises have <code>null</code> values.
187- * <p>When resulting promise is resolved either successfully or faulty, any remaining {@link CompletionStage}-s is cancelled.
188- *
200+ * <p>When resulting promise is resolved either successfully or faulty, all remaining incomplete {@link CompletionStage}-s are cancelled.
201+ *
202+ * @param <T>
203+ * a common supertype of the resulting values
189204 * @param minResultsCount
190205 * a minimum number of promises that should be completed normally to resolve resulting promise successfully
191206 * @param promises
@@ -198,6 +213,32 @@ public static <T> Promise<List<T>> atLeastStrict(final int minResultsCount, fina
198213 return atLeast (minResultsCount , 0 , true , promises );
199214 }
200215
216+ /**
217+ * <p>General method to combine several {@link CompletionStage}-s passed as arguments into single promise.</p>
218+ * <p>The resulting promise is resolved successfully when at least <code>minResultCount</code> of {@link CompletionStage}-s passed as parameters
219+ * are completed normally (race is possible).
220+ * <p>If less than <code>minResultCount</code> of promises completed normally, then resulting promise is resolved faulty.
221+ * <p>If <code>maxErrorsCount</code> of promises completed exceptionally <em>before</em> <code>minResultCount</code> of results are available, then
222+ * resulting promise is resolved faulty as well.
223+ * <p>The resolved result of this promise contains a list of the resolved results of the {@link CompletionStage}-s passed as an
224+ * argument at corresponding positions. Non-completed promises and promises completed exceptionally have <code>null</code> values.
225+ * <p>When resulting promise is resolved either successfully or faulty, all remaining incomplete {@link CompletionStage}-s are cancelled <em>if</em>
226+ * <code>cancelRemaining</code> parameter is <code>true</code>.
227+ *
228+ * @param <T>
229+ * a common supertype of the resulting values
230+ * @param minResultsCount
231+ * a minimum number of promises that should be completed normally to resolve resulting promise successfully
232+ * @param maxErrorsCount
233+ * a maximum number of promises that may be completed exceptionally before resolving resulting promise faulty
234+ * @param cancelRemaining
235+ * a flag that indicates (if true) whether or not all remaining incomplete {@link CompletionStage}-s should be cancelled
236+ * once a resulting promise outcome is known.
237+ * @param promises
238+ * an array of {@link CompletionStage}-s to combine
239+ * @return
240+ * a combined promise
241+ */
201242 @ SafeVarargs
202243 public static <T > Promise <List <T >> atLeast (final int minResultsCount , final int maxErrorsCount , final boolean cancelRemaining ,
203244 final CompletionStage <? extends T >... promises ) {
0 commit comments