Package com.spotify.futures
Class ListenableFuturesExtra
java.lang.Object
com.spotify.futures.ListenableFuturesExtra
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <V> CompletableFuture<V>toCompletableFuture(com.google.common.util.concurrent.ListenableFuture<V> future) Wrap aListenableFuturein aCompletableFuture.static <V> CompletableFuture<V>toCompletableFuture(com.google.common.util.concurrent.ListenableFuture<V> future, Executor executor) Wrap aListenableFuturein aCompletableFuture.
-
Constructor Details
-
ListenableFuturesExtra
public ListenableFuturesExtra()
-
-
Method Details
-
toCompletableFuture
public static <V> CompletableFuture<V> toCompletableFuture(com.google.common.util.concurrent.ListenableFuture<V> future) Wrap aListenableFuturein aCompletableFuture. 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- TheListenableFutureto wrap in aCompletableFuture.- Returns:
- A
CompletableFuturethat completes when the original future completes.
-
toCompletableFuture
public static <V> CompletableFuture<V> toCompletableFuture(com.google.common.util.concurrent.ListenableFuture<V> future, Executor executor) Wrap aListenableFuturein aCompletableFuture. 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- TheListenableFutureto wrap in aCompletableFuture.executor- the executor where the listener is running.- Returns:
- A
CompletableFuturethat completes when the original future completes.
-