Package org.bitcoinj.base.internal
Class FutureUtils
- java.lang.Object
-
- org.bitcoinj.base.internal.FutureUtils
-
public class FutureUtils extends java.lang.Object
Utilities forCompletableFuture
.Note: When the bitcoinj migration to
CompletableFuture
is finished this class will either be removed or its remaining methods changed to use genericCompletableFuture
s.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
FutureUtils.ThrowingSupplier<T>
Subinterface ofSupplier
for Lambdas which throw exceptions.
-
Constructor Summary
Constructors Constructor Description FutureUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T> java.util.concurrent.CompletableFuture<java.util.List<T>>
allAsList(java.util.List<? extends java.util.concurrent.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> java.util.concurrent.CompletableFuture<T>
failedFuture(java.lang.Throwable t)
Can be replaced withCompletableFuture.failedFuture(Throwable)
in Java 9+.static <T> java.util.concurrent.CompletableFuture<java.util.List<T>>
successfulAsList(java.util.List<? extends java.util.concurrent.CompletionStage<? extends T>> stages)
Note: When the migration toCompletableFuture
is complete this routine will either be removed or changed to return a genericCompletableFuture
.
-
-
-
Method Detail
-
allAsList
public static <T> java.util.concurrent.CompletableFuture<java.util.List<T>> allAsList(java.util.List<? extends java.util.concurrent.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> java.util.concurrent.CompletableFuture<java.util.List<T>> successfulAsList(java.util.List<? extends java.util.concurrent.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
public static <T> java.util.concurrent.CompletableFuture<T> failedFuture(java.lang.Throwable t)
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
-
-