Class FutureConverter

    • 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 a ListenableFuture to a CompletableFuture.

        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 Java CompletableFuture to a Guava ListenableFuture.

        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