Package org.forgerock.openig.tools
Class FutureUtils
- java.lang.Object
-
- org.forgerock.openig.tools.FutureUtils
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T,E extends Exception>
Promise<T,E>futureToPromise(CompletionStage<T> completionStage, Class<E> exceptionType)Converts aCompletionStageto aPromise.static <T,E extends Exception>
CompletableFuture<T>promiseToFuture(Promise<T,E> promise)Converts aPromiseto aCompletableFuture.
-
-
-
Method Detail
-
promiseToFuture
public static <T,E extends Exception> CompletableFuture<T> promiseToFuture(Promise<T,E> promise)
Converts aPromiseto aCompletableFuture.- 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 aCompletionStageto aPromise.- 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, notnull.- Returns:
- The equivalent as a
Promise. - Throws:
NullPointerException- if the exceptionType isnull.
-
-