Class FutureUtils

java.lang.Object
org.bitcoinj.base.internal.FutureUtils

public class FutureUtils extends Object
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 CompletableFutures.

  • 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 to CompletableFuture is complete this routine will either be removed or changed to return a generic CompletableFuture.
      Type Parameters:
      T - the result type
      Parameters:
      stages - A list of CompletionStages 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 to CompletableFuture is complete this routine will either be removed or changed to return a generic CompletableFuture.
      Type Parameters:
      T - the result type
      Parameters:
      stages - A list of CompletionStages all returning the same type
      Returns:
      A CompletableFuture that returns a list of result type
    • failedFuture

      public static <T> CompletableFuture<T> failedFuture(Throwable t)
      Can be replaced with CompletableFuture.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