Class FutureUtils

java.lang.Object
org.forgerock.openig.tools.FutureUtils

public final class FutureUtils extends Object
Utility class for Futures and Promises.
  • Method Details

    • promiseToFuture

      public static <T, E extends Exception> CompletableFuture<T> promiseToFuture(Promise<T,E> promise)
      Converts a Promise to a CompletableFuture.
      Type Parameters:
      T - The type's result of the promise.
      E - The type of the exception thrown by the promise.
      Parameters:
      promise - The promise to convert.
      Returns:
      The equivalent CompletableFuture.
    • futureToPromise

      public static <T, E extends Exception> Promise<T,E> futureToPromise(CompletionStage<T> completionStage, Class<E> exceptionType)
      Converts a CompletionStage to a Promise.
      Type Parameters:
      T - The type's result expected by the promise.
      E - The type of the exception expected by the promise.
      Parameters:
      completionStage - The completion stage to convert.
      exceptionType - The expected exception type, not null.
      Returns:
      The equivalent as a Promise.
      Throws:
      NullPointerException - if the exceptionType is null.