Enum CompletableFutures

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Comparable<CompletableFutures>

    public enum CompletableFutures
    extends java.lang.Enum<CompletableFutures>
    Utility class with CompletableFuture and CompletionStage useful methods.
    Since:
    5.2
    Author:
    Pedro Ruivo
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
      INSTANCE  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.util.concurrent.CompletableFuture<java.lang.Boolean> completedFalse()  
      static <T> java.util.concurrent.CompletableFuture<T> completedNull()
      A null completed CompletableFuture.
      static java.util.concurrent.CompletableFuture<java.lang.Boolean> completedTrue()  
      static <T> T join​(java.util.concurrent.CompletableFuture<T> cf)
      Waits for the CompletableFuture to complete.
      static <T> T join​(java.util.concurrent.CompletionStage<T> cs)
      Same as join(CompletableFuture) but it receives a CompletionStage as parameter.
      static <T> java.util.function.Function<T,​java.lang.Void> toVoidFunction()  
      static CompletableFutures valueOf​(java.lang.String name)
      Returns the enum constant of this type with the specified name.
      static CompletableFutures[] values()
      Returns an array containing the constants of this enum type, in the order they are declared.
      static <T> java.util.function.Consumer<T> voidConsumer()
      Consumes any value and return a Void.
      static java.util.concurrent.CompletionException wrapAsCompletionException​(java.lang.Throwable throwable)
      Wraps the throwable into CompletionException.
      • Methods inherited from class java.lang.Enum

        clone, compareTo, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOf
      • Methods inherited from class java.lang.Object

        getClass, notify, notifyAll, wait, wait, wait
    • Method Detail

      • values

        public static CompletableFutures[] values()
        Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:
        for (CompletableFutures c : CompletableFutures.values())
            System.out.println(c);
        
        Returns:
        an array containing the constants of this enum type, in the order they are declared
      • valueOf

        public static CompletableFutures valueOf​(java.lang.String name)
        Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
        Parameters:
        name - the name of the enum constant to be returned.
        Returns:
        the enum constant with the specified name
        Throws:
        java.lang.IllegalArgumentException - if this enum type has no constant with the specified name
        java.lang.NullPointerException - if the argument is null
      • join

        public static <T> T join​(java.util.concurrent.CompletableFuture<T> cf)
        Waits for the CompletableFuture to complete.

        Any non RuntimeException thrown is converted to a RuntimeException.

        Type Parameters:
        T - The value type.
        Parameters:
        cf - The CompletableFuture
        Returns:
        The value of the completed CompletableFuture.
      • completedNull

        public static <T> java.util.concurrent.CompletableFuture<T> completedNull()
        A null completed CompletableFuture.
        Type Parameters:
        T - The value type.
        Returns:
        The CompletableFuture.
      • voidConsumer

        public static <T> java.util.function.Consumer<T> voidConsumer()
        Consumes any value and return a Void.
        Type Parameters:
        T - The value type.
        Returns:
        The Consumer.
      • wrapAsCompletionException

        public static java.util.concurrent.CompletionException wrapAsCompletionException​(java.lang.Throwable throwable)
        Wraps the throwable into CompletionException.
        Parameters:
        throwable - The Throwable to wrap.
        Returns:
        The CompletionException with throwable.
      • toVoidFunction

        public static <T> java.util.function.Function<T,​java.lang.Void> toVoidFunction()
        Type Parameters:
        T - The value's type.
        Returns:
        A Function that converts any value to Void.
      • completedTrue

        public static java.util.concurrent.CompletableFuture<java.lang.Boolean> completedTrue()
        Returns:
        A CompletableFuture completed with value Boolean.TRUE
      • completedFalse

        public static java.util.concurrent.CompletableFuture<java.lang.Boolean> completedFalse()
        Returns:
        A CompletableFuture completed with value Boolean.FALSE