Class CompletableFutureAdapter


  • public class CompletableFutureAdapter
    extends java.lang.Object
    This class helps in converting between threadly's ListenableFuture and java's provided CompletableFuture. The threadly project prefers ListenableFuture 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 Detail

      • CompletableFutureAdapter

        public CompletableFutureAdapter()
    • Method Detail

      • toCompletable

        public static <T> java.util.concurrent.CompletableFuture<T> toCompletable​(ListenableFuture<? extends T> lf)
        Convert from a ListenableFuture to CompletableFuture.
        Type Parameters:
        T - Type of result provided by the future
        Parameters:
        lf - The future to adapt into a CompletableFuture
        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 a CompletableFuture to ListenableFuture.
        Type Parameters:
        T - Type of result provided by the future
        Parameters:
        cf - The future to adapt into a ListenableFuture
        Returns:
        A ListenableFuture instance which's state will be connected to the provided future