Package org.threadly.concurrent.future
Class CompletableFutureAdapter
- java.lang.Object
-
- org.threadly.concurrent.future.CompletableFutureAdapter
-
public class CompletableFutureAdapter extends java.lang.Object
This class helps in converting between threadly'sListenableFuture
and java's providedCompletableFuture
. The threadly project prefersListenableFuture
as it is able to be more performant, as well as in some cases provide additional features. Still, the concepts are very similar, making it easy for this class to convert between the types.- Since:
- 5.43
-
-
Constructor Summary
Constructors Constructor Description CompletableFutureAdapter()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T> java.util.concurrent.CompletableFuture<T>
toCompletable(ListenableFuture<? extends T> lf)
Convert from aListenableFuture
toCompletableFuture
.static <T> ListenableFuture<T>
toListenable(java.util.concurrent.CompletableFuture<? extends T> cf)
Convert from aCompletableFuture
toListenableFuture
.
-
-
-
Method Detail
-
toCompletable
public static <T> java.util.concurrent.CompletableFuture<T> toCompletable(ListenableFuture<? extends T> lf)
Convert from aListenableFuture
toCompletableFuture
.- Type Parameters:
T
- Type of result provided by the future- Parameters:
lf
- The future to adapt into aCompletableFuture
- Returns:
- A CompletableFuture instance which's state will be connected to the provided future
-
toListenable
public static <T> ListenableFuture<T> toListenable(java.util.concurrent.CompletableFuture<? extends T> cf)
Convert from aCompletableFuture
toListenableFuture
.- Type Parameters:
T
- Type of result provided by the future- Parameters:
cf
- The future to adapt into aListenableFuture
- Returns:
- A ListenableFuture instance which's state will be connected to the provided future
-
-