Package org.bitcoinj.base.internal
Class FutureUtils
java.lang.Object
org.bitcoinj.base.internal.FutureUtils
Utilities for
CompletableFuture
.
Note: When the bitcoinj migration to CompletableFuture
is finished this class will
either be removed or its remaining methods changed to use generic CompletableFuture
s.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic interface
Subinterface ofSupplier
for Lambdas which throw exceptions. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T> CompletableFuture<List<T>>
allAsList
(List<? extends CompletionStage<? extends T>> stages) Note: When the migration toCompletableFuture
is complete this routine will either be removed or changed to return a genericCompletableFuture
.static <T> CompletableFuture<T>
Can be replaced withCompletableFuture.failedFuture(Throwable)
in Java 9+.static <T> CompletableFuture<List<T>>
successfulAsList
(List<? extends CompletionStage<? extends T>> stages) Note: When the migration toCompletableFuture
is complete this routine will either be removed or changed to return a genericCompletableFuture
.
-
Constructor Details
-
FutureUtils
public FutureUtils()
-
-
Method Details
-
allAsList
public static <T> CompletableFuture<List<T>> allAsList(List<? extends CompletionStage<? extends T>> stages) Note: When the migration toCompletableFuture
is complete this routine will either be removed or changed to return a genericCompletableFuture
.- Type Parameters:
T
- the result type- Parameters:
stages
- A list ofCompletionStage
s all returning the same type- Returns:
- A CompletableFuture that returns a list of result type
-
successfulAsList
public static <T> CompletableFuture<List<T>> successfulAsList(List<? extends CompletionStage<? extends T>> stages) Note: When the migration toCompletableFuture
is complete this routine will either be removed or changed to return a genericCompletableFuture
.- Type Parameters:
T
- the result type- Parameters:
stages
- A list ofCompletionStage
s all returning the same type- Returns:
- A CompletableFuture that returns a list of result type
-
failedFuture
Can be replaced withCompletableFuture.failedFuture(Throwable)
in Java 9+.- Type Parameters:
T
- the future's return type- Parameters:
t
- Exception that is causing the failure- Returns:
- a failed future containing the specified exception
-