Class FutureConverter
- java.lang.Object
-
- org.apache.jackrabbit.oak.commons.internal.concurrent.FutureConverter
-
public class FutureConverter extends Object
Utility to convertListenableFuturetoCompletableFuture
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T> List<CompletableFuture<T>>toCompletableFuture(List<? extends org.apache.jackrabbit.guava.common.util.concurrent.ListenableFuture<T>> listenableFutures)static <T> CompletableFuture<T>toCompletableFuture(org.apache.jackrabbit.guava.common.util.concurrent.ListenableFuture<T> listenableFuture)Converts aListenableFutureto aCompletableFuture.static <T> org.apache.jackrabbit.guava.common.util.concurrent.ListenableFuture<T>toListenableFuture(CompletableFuture<T> completableFuture)Converts a JavaCompletableFutureto a GuavaListenableFuture.
-
-
-
Method Detail
-
toCompletableFuture
public static <T> List<CompletableFuture<T>> toCompletableFuture(List<? extends org.apache.jackrabbit.guava.common.util.concurrent.ListenableFuture<T>> listenableFutures)
-
toCompletableFuture
public static <T> CompletableFuture<T> toCompletableFuture(org.apache.jackrabbit.guava.common.util.concurrent.ListenableFuture<T> listenableFuture)
Converts aListenableFutureto aCompletableFuture.The returned CompletableFuture will be completed when the ListenableFuture completes, either with its result or with an exception if the ListenableFuture fails.
- Type Parameters:
T- the result type- Parameters:
listenableFuture- the ListenableFuture to convert- Returns:
- a CompletableFuture representing the same computation
-
toListenableFuture
public static <T> org.apache.jackrabbit.guava.common.util.concurrent.ListenableFuture<T> toListenableFuture(CompletableFuture<T> completableFuture)
Converts a JavaCompletableFutureto a GuavaListenableFuture.The returned ListenableFuture will complete when the given CompletableFuture completes, with the same result or exception. This is a one-way conversion; cancelling the ListenableFuture will not cancel the original CompletableFuture.
- Type Parameters:
T- the type of the future result- Parameters:
completableFuture- the Java CompletableFuture to convert- Returns:
- a Guava ListenableFuture that completes when the CompletableFuture completes
-
-