Class FutureUtils
- java.lang.Object
-
- org.apache.jackrabbit.oak.commons.internal.concurrent.FutureUtils
-
public class FutureUtils extends Object
Utils methods forCompletableFuture
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T> CompletableFuture<List<T>>allAsList(Iterable<? extends CompletableFuture<? extends T>> tasks)Returns aCompletableFuturethat completes when all of the given input futures complete.static <T> CompletableFuture<List<T>>successfulAsList(List<CompletableFuture<T>> futures)Returns aCompletableFuturethat completes when all of the given futures complete.
-
-
-
Method Detail
-
successfulAsList
public static <T> CompletableFuture<List<T>> successfulAsList(List<CompletableFuture<T>> futures)
Returns aCompletableFuturethat completes when all of the given futures complete.The resulting list contains the results of each input future, or
nullfor any future that completed exceptionally. This mimics Guava'sFutures.successfulAsListbehavior.- Type Parameters:
T- the result type- Parameters:
futures- the list of CompletableFutures to aggregate- Returns:
- a CompletableFuture containing a list of results (or null for failed futures)
-
allAsList
public static <T> CompletableFuture<List<T>> allAsList(Iterable<? extends CompletableFuture<? extends T>> tasks)
Returns aCompletableFuturethat completes when all of the given input futures complete. If all input futures complete successfully, the returned future completes with a list of all results, maintaining the input order.If any input future completes exceptionally or is cancelled, the returned future also completes exceptionally. This method is analogous to Guava's
Futures.allAsList(tasks).- Type Parameters:
T- the result type of the futures- Parameters:
tasks- the list of CompletableFutures to combine- Returns:
- a CompletableFuture that completes with a list of all input results, in order
-
-