Class JsArrayFuture

  • All Implemented Interfaces:
    java.util.function.Supplier<java.util.concurrent.CompletableFuture<JsArray>>, JsFuture<JsArray>

    public class JsArrayFuture
    extends java.lang.Object
    implements JsFuture<JsArray>
    Represents a supplier of a completable future which result is a json array. It has the same recursive structure as a json array. Each index of the array is a completable future that it's executed asynchronously. When all the futures are completed, all the results are combined into a json array. JsArrayFuture(CompletableFuture(1),CompletableFuture("a"),CompletableFuture(true)) = CompletableFuture(JsArray(1,"a",true))
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      JsArrayFuture append​(JsFuture<?> future)  
      static JsArrayFuture empty()
      returns a JsArrayFuture that is completed returning the empty Json array
      JsArrayFuture executor​(java.util.concurrent.Executor executor)
      the executor to use for the asynchronous operation assigned to this future.
      java.util.concurrent.CompletableFuture<JsArray> get()
      it triggers the execution of all the completable futures, combining the results into a JsArray
      static JsArrayFuture tuple​(JsFuture<?> head, JsFuture<?>... tail)
      returns a JsArrayFuture from the given head and the tail
      • Methods inherited from class java.lang.Object

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

      • tuple

        public static JsArrayFuture tuple​(JsFuture<?> head,
                                          JsFuture<?>... tail)
        returns a JsArrayFuture from the given head and the tail
        Parameters:
        head - the head
        tail - the tail
        Returns:
        a new JsArrayFuture
      • empty

        public static JsArrayFuture empty()
        returns a JsArrayFuture that is completed returning the empty Json array
        Returns:
        a JsArrayFuture
      • executor

        public JsArrayFuture executor​(java.util.concurrent.Executor executor)
        the executor to use for the asynchronous operation assigned to this future. By default the ForkJoinPool.commonPool() will be used. Notice that any future of the array can run on threads froms different executors. The job to do by this JsArrayFuture is to iterate the array of futures, trigger every future and append the result of every completed future to the final array that will be returned.
        Parameters:
        executor - the executor
        Returns:
        the same this JsArrayFuture
      • get

        public java.util.concurrent.CompletableFuture<JsArray> get()
        it triggers the execution of all the completable futures, combining the results into a JsArray
        Specified by:
        get in interface java.util.function.Supplier<java.util.concurrent.CompletableFuture<JsArray>>
        Returns:
        a CompletableFuture of a json array