Class PromisedValuesImpl<T>

    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.Throwable cause()
      The exception cause or null if it didn't fail
      java.lang.Throwable cause​(int index)
      The exception cause at the specified index or null if it didn't fail
      static <T> PromisedValues<T> combineAllOf​(java.util.List<? extends java.util.concurrent.CompletionStage<T>> cfs)  
      static <T> PromisedValues<T> combinePromisedValues​(java.util.List<PromisedValues<T>> promisedValues)  
      boolean failed()  
      T get​(int index)
      The value at index or null if it failed
      boolean isDone()
      The true if the all the futures have completed (and hence this PromisedValues has completed)
      java.util.List<T> join()
      Waits for the underlying futures to complete.
      int size()  
      boolean succeeded()  
      boolean succeeded​(int index)
      The true if the CompletionStage at the specified index succeeded
      PromisedValues<T> thenAccept​(java.util.function.Consumer<PromisedValues<T>> handler)
      When the all the futures complete, this call back will be invoked with this PromisedValues as a parameter
      java.util.concurrent.CompletableFuture<java.util.List<T>> toCompletableFuture()  
      java.util.List<T> toList()
      Returns the underlying values as a list
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • combineAllOf

        public static <T> PromisedValues<T> combineAllOf​(java.util.List<? extends java.util.concurrent.CompletionStage<T>> cfs)
      • succeeded

        public boolean succeeded()
        Specified by:
        succeeded in interface PromisedValues<T>
        Returns:
        true if all the futures completed successfully
      • failed

        public boolean failed()
        Specified by:
        failed in interface PromisedValues<T>
        Returns:
        true if any of the futures completed unsuccessfully
      • isDone

        public boolean isDone()
        Description copied from interface: PromisedValues
        The true if the all the futures have completed (and hence this PromisedValues has completed)
        Specified by:
        isDone in interface PromisedValues<T>
        Returns:
        true if all the futures have completed
      • cause

        public java.lang.Throwable cause()
        Description copied from interface: PromisedValues
        The exception cause or null if it didn't fail
        Specified by:
        cause in interface PromisedValues<T>
        Returns:
        an exception or null if the future did not fail
      • succeeded

        public boolean succeeded​(int index)
        Description copied from interface: PromisedValues
        The true if the CompletionStage at the specified index succeeded
        Specified by:
        succeeded in interface PromisedValues<T>
        Parameters:
        index - the index of the CompletionStage
        Returns:
        true if the future at the specified index succeeded
      • cause

        public java.lang.Throwable cause​(int index)
        Description copied from interface: PromisedValues
        The exception cause at the specified index or null if it didn't fail
        Specified by:
        cause in interface PromisedValues<T>
        Parameters:
        index - the index of the CompletionStage
        Returns:
        an exception or null if the future did not fail
      • get

        public T get​(int index)
        Description copied from interface: PromisedValues
        The value at index or null if it failed
        Specified by:
        get in interface PromisedValues<T>
        Parameters:
        index - the index of the future
        Returns:
        the value of the future
      • toList

        public java.util.List<T> toList()
        Description copied from interface: PromisedValues
        Returns the underlying values as a list
        Specified by:
        toList in interface PromisedValues<T>
        Returns:
        the list of underlying values
      • size

        public int size()
        Specified by:
        size in interface PromisedValues<T>
        Returns:
        the number of CompletionStages under the covers
      • join

        public java.util.List<T> join()
        Description copied from interface: PromisedValues
        Waits for the underlying futures to complete. To better conform with the use of common functional forms, if a computation involved in the completion of this CompletableFuture threw an exception, this method throws an (unchecked) CompletionException with the underlying exception as its cause.
        Specified by:
        join in interface PromisedValues<T>
        Returns:
        the list of completed values similar to PromisedValues.toList()
      • toCompletableFuture

        public java.util.concurrent.CompletableFuture<java.util.List<T>> toCompletableFuture()
        Specified by:
        toCompletableFuture in interface PromisedValues<T>
        Returns:
        this as a CompletableFuture that returns the list of underlying values