Package jsonvalues.future
Class JsArrayFuture
- java.lang.Object
-
- jsonvalues.future.JsArrayFuture
-
- All Implemented Interfaces:
Supplier<CompletableFuture<JsArray>>
,JsFuture<JsArray>
public class JsArrayFuture extends 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 arrayJsArrayFuture
executor(Executor executor)
the executor to use for the asynchronous operation assigned to this future.CompletableFuture<JsArray>
get()
it triggers the execution of all the completable futures, combining the results into a JsArraystatic JsArrayFuture
tuple(JsFuture<?> head, JsFuture<?>... tail)
returns a JsArrayFuture from the given head and the tail
-
-
-
Method Detail
-
tuple
public static JsArrayFuture tuple(JsFuture<?> head, JsFuture<?>... tail)
returns a JsArrayFuture from the given head and the tail- Parameters:
head
- the headtail
- 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(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 CompletableFuture<JsArray> get()
it triggers the execution of all the completable futures, combining the results into a JsArray- Specified by:
get
in interfaceSupplier<CompletableFuture<JsArray>>
- Returns:
- a CompletableFuture of a json array
-
append
public JsArrayFuture append(JsFuture<?> future)
-
-