Class FutureUtil


  • public final class FutureUtil
    extends Object
    Utility class for future-related operations.
    • Method Detail

      • toFuture

        public static <T> CompletableFuture<T> toFuture​(io.netty.util.concurrent.Future<T> future)
        Translates the Netty Future to a CompletableFuture.
        Type Parameters:
        T - The result type of the future
        Parameters:
        future - The future to be translated
        Returns:
        The translated CompletableFuture
      • completeOnAnyOfExceptionally

        public static void completeOnAnyOfExceptionally​(CompletableFuture<?> future,
                                                        Collection<CompletableFuture<?>> futures)
        Completes future exceptionally if one of the given futures are completed exceptionally. If the given array of futures is empty, nothing happens.
        Parameters:
        future - future that should be completed
        futures - futures that should be waited for
        Throws:
        NullPointerException - if future or futures is null
      • completeOnAnyOfExceptionally

        public static void completeOnAnyOfExceptionally​(CompletableFuture<?> future,
                                                        CompletableFuture<?>... futures)
        Completes future exceptionally if one of the given futures are completed exceptionally. If the given array of futures is empty, nothing happens.
        Parameters:
        future - future that should be completed
        futures - futures that should be waited for
        Throws:
        NullPointerException - if future or futures is null
      • getCompleteOnAllOf

        public static CompletableFuture<Void> getCompleteOnAllOf​(Collection<CompletableFuture<?>> futures)
        Returns a completed future if all of the given futures are completed. When any of the given futures completes exceptionally, the future will also completes exceptionally immediately. If the given list of futures is empty, the future is completed immediately.
        Parameters:
        futures - futures that should be waited for
        Throws:
        NullPointerException - if futures is null
      • getCompleteOnAllOf

        public static CompletableFuture<Void> getCompleteOnAllOf​(CompletableFuture<?>... futures)
        Returns a completed future if all of the given futures are completed. When any of the given futures completes exceptionally, the future will also completes exceptionally immediately. If the given array of futures is empty, the future is completed immediately.
        Parameters:
        futures - futures that should be waited for
        Throws:
        NullPointerException - if futures is null
      • completeOnAllOf

        public static void completeOnAllOf​(CompletableFuture<Void> future,
                                           Collection<CompletableFuture<?>> futures)
        Completes future if all of the given futures are completed. When any of the given futures completes exceptionally, the given future will also completes exceptionally immediately. If the given list of futures is empty, the future is completed immediately.
        Parameters:
        future - future that should be completed
        futures - futures that should be waited for
        Throws:
        NullPointerException - if future or futures is null
      • completeOnAllOf

        public static void completeOnAllOf​(CompletableFuture<Void> future,
                                           CompletableFuture<?>... futures)
        Completes future if all of the given futures are completed. When any of the given futures completes exceptionally, the given future will also completes exceptionally immediately. If the given array of futures is empty, the future is completed immediately.
        Parameters:
        future - future that should be completed
        futures - futures that should be waited for
        Throws:
        NullPointerException - if future or futures is null