Class ListenableFuturesExtra

java.lang.Object
com.spotify.futures.ListenableFuturesExtra

public class ListenableFuturesExtra extends Object
  • Constructor Details

    • ListenableFuturesExtra

      public ListenableFuturesExtra()
  • Method Details

    • toCompletableFuture

      public static <V> CompletableFuture<V> toCompletableFuture(com.google.common.util.concurrent.ListenableFuture<V> future)
      Wrap a ListenableFuture in a CompletableFuture. The returned future will complete with the same result or failure as the original future. Completing the returned future does not complete the original future.
      Parameters:
      future - The ListenableFuture to wrap in a CompletableFuture.
      Returns:
      A CompletableFuture that completes when the original future completes.
    • toCompletableFuture

      public static <V> CompletableFuture<V> toCompletableFuture(com.google.common.util.concurrent.ListenableFuture<V> future, Executor executor)
      Wrap a ListenableFuture in a CompletableFuture. The returned future will complete with the same result or failure as the original future. Completing the returned future does not complete the original future.
      Parameters:
      future - The ListenableFuture to wrap in a CompletableFuture.
      executor - the executor where the listener is running.
      Returns:
      A CompletableFuture that completes when the original future completes.