Package jsonvalues.future
Class JsObjFuture
- java.lang.Object
-
- jsonvalues.future.JsObjFuture
-
- All Implemented Interfaces:
Supplier<CompletableFuture<JsObj>>
,JsFuture<JsObj>
public class JsObjFuture extends Object implements JsFuture<JsObj>
Represents a supplier of a completable future which result is a json object. It has the same recursive structure as a json object. Each key has a completable future associated that it's executed asynchronously. When all the futures are completed, all the results are combined into a json object:JsObjFuture(a-> CompletableFuture(1), b-> CompletableFuture("a"), c-> CompletableFuture(true) ) = CompletableFuture(JsObj(a->1, b->"a", c->true ) )
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static JsObjFuture
empty()
returns a JsObjFuture that is completed returning the empty Json objectJsObjFuture
executor(Executor executor)
the executor to use for the asynchronous operation assigned to this future.CompletableFuture<JsObj>
get()
it triggers the execution of all the completable futures, combining the results into a JsObjstatic JsObjFuture
of(String key, JsFuture<?> fut)
static factory method to create a JsObjFuture of one mappingstatic JsObjFuture
of(String key1, JsFuture<?> fut1, String key2, JsFuture<?> fut2)
static factory method to create a JsObjFuture of one mappingstatic JsObjFuture
of(String key1, JsFuture<?> fut1, String key2, JsFuture<?> fut2, String key3, JsFuture<?> fut3)
static factory method to create a JsObjFuture of three mappingsstatic JsObjFuture
of(String key1, JsFuture<?> fut1, String key2, JsFuture<?> fut2, String key3, JsFuture<?> fut3, String key4, JsFuture<?> fut4)
static factory method to create a JsObjFuture of four mappingsstatic JsObjFuture
of(String key1, JsFuture<?> fut1, String key2, JsFuture<?> fut2, String key3, JsFuture<?> fut3, String key4, JsFuture<?> fut4, String key5, JsFuture<?> fut5)
static factory method to create a JsObjFuture of five mappingsstatic JsObjFuture
of(String key1, JsFuture<?> fut1, String key2, JsFuture<?> fut2, String key3, JsFuture<?> fut3, String key4, JsFuture<?> fut4, String key5, JsFuture<?> fut5, String key6, JsFuture<?> fut6)
static factory method to create a JsObjFuture of six mappingsstatic JsObjFuture
of(String key1, JsFuture<?> fut1, String key2, JsFuture<?> fut2, String key3, JsFuture<?> fut3, String key4, JsFuture<?> fut4, String key5, JsFuture<?> fut5, String key6, JsFuture<?> fut6, String key7, JsFuture<?> fut7)
static factory method to create a JsObjFuture of seven mappingsstatic JsObjFuture
of(String key1, JsFuture<?> fut1, String key2, JsFuture<?> fut2, String key3, JsFuture<?> fut3, String key4, JsFuture<?> fut4, String key5, JsFuture<?> fut5, String key6, JsFuture<?> fut6, String key7, JsFuture<?> fut7, String key8, JsFuture<?> fut8)
static factory method to create a JsObjFuture of eight mappingsstatic JsObjFuture
of(String key1, JsFuture<?> fut1, String key2, JsFuture<?> fut2, String key3, JsFuture<?> fut3, String key4, JsFuture<?> fut4, String key5, JsFuture<?> fut5, String key6, JsFuture<?> fut6, String key7, JsFuture<?> fut7, String key8, JsFuture<?> fut8, String key9, JsFuture<?> fut9)
static factory method to create a JsObjFuture of nine mappingsstatic JsObjFuture
of(String key1, JsFuture<?> fut1, String key2, JsFuture<?> fut2, String key3, JsFuture<?> fut3, String key4, JsFuture<?> fut4, String key5, JsFuture<?> fut5, String key6, JsFuture<?> fut6, String key7, JsFuture<?> fut7, String key8, JsFuture<?> fut8, String key9, JsFuture<?> fut9, String key10, JsFuture<?> fut10)
static factory method to create a JsObjFuture of ten mappingsstatic JsObjFuture
of(String key1, JsFuture<?> fut1, String key2, JsFuture<?> fut2, String key3, JsFuture<?> fut3, String key4, JsFuture<?> fut4, String key5, JsFuture<?> fut5, String key6, JsFuture<?> fut6, String key7, JsFuture<?> fut7, String key8, JsFuture<?> fut8, String key9, JsFuture<?> fut9, String key10, JsFuture<?> fut10, String key11, JsFuture<?> fut11)
static factory method to create a JsObjFuture of eleven mappingsstatic JsObjFuture
of(String key1, JsFuture<?> fut1, String key2, JsFuture<?> fut2, String key3, JsFuture<?> fut3, String key4, JsFuture<?> fut4, String key5, JsFuture<?> fut5, String key6, JsFuture<?> fut6, String key7, JsFuture<?> fut7, String key8, JsFuture<?> fut8, String key9, JsFuture<?> fut9, String key10, JsFuture<?> fut10, String key11, JsFuture<?> fut11, String key12, JsFuture<?> fut12)
static factory method to create a JsObjFuture of twelve mappingsstatic JsObjFuture
of(String key1, JsFuture<?> fut1, String key2, JsFuture<?> fut2, String key3, JsFuture<?> fut3, String key4, JsFuture<?> fut4, String key5, JsFuture<?> fut5, String key6, JsFuture<?> fut6, String key7, JsFuture<?> fut7, String key8, JsFuture<?> fut8, String key9, JsFuture<?> fut9, String key10, JsFuture<?> fut10, String key11, JsFuture<?> fut11, String key12, JsFuture<?> fut12, String key13, JsFuture<?> fut13)
static factory method to create a JsObjFuture of thirteen mappingsstatic JsObjFuture
of(String key1, JsFuture<?> fut1, String key2, JsFuture<?> fut2, String key3, JsFuture<?> fut3, String key4, JsFuture<?> fut4, String key5, JsFuture<?> fut5, String key6, JsFuture<?> fut6, String key7, JsFuture<?> fut7, String key8, JsFuture<?> fut8, String key9, JsFuture<?> fut9, String key10, JsFuture<?> fut10, String key11, JsFuture<?> fut11, String key12, JsFuture<?> fut12, String key13, JsFuture<?> fut13, String key14, JsFuture<?> fut14)
static factory method to create a JsObjFuture of fourteen mappingsstatic JsObjFuture
of(String key1, JsFuture<?> fut1, String key2, JsFuture<?> fut2, String key3, JsFuture<?> fut3, String key4, JsFuture<?> fut4, String key5, JsFuture<?> fut5, String key6, JsFuture<?> fut6, String key7, JsFuture<?> fut7, String key8, JsFuture<?> fut8, String key9, JsFuture<?> fut9, String key10, JsFuture<?> fut10, String key11, JsFuture<?> fut11, String key12, JsFuture<?> fut12, String key13, JsFuture<?> fut13, String key14, JsFuture<?> fut14, String key15, JsFuture<?> fut15)
static factory method to create a JsObjFuture of fifteen mappingsJsObjFuture
set(String key, JsFuture<?> future)
returns a new object future inserting the given future at the given key
-
-
-
Method Detail
-
of
public static JsObjFuture of(String key, JsFuture<?> fut)
static factory method to create a JsObjFuture of one mapping- Parameters:
key
- the keyfut
- the mapping associated to the key- Returns:
- a JsObjFuture
-
of
public static JsObjFuture of(String key1, JsFuture<?> fut1, String key2, JsFuture<?> fut2)
static factory method to create a JsObjFuture of one mapping- Parameters:
key1
- the first keyfut1
- the mapping associated to the first keykey2
- the second keyfut2
- the mapping associated to the second key- Returns:
- a JsObjFuture
-
of
public static JsObjFuture of(String key1, JsFuture<?> fut1, String key2, JsFuture<?> fut2, String key3, JsFuture<?> fut3)
static factory method to create a JsObjFuture of three mappings- Parameters:
key1
- the first keyfut1
- the mapping associated to the first keykey2
- the second keyfut2
- the mapping associated to the second keykey3
- the third keyfut3
- the mapping associated to the third key- Returns:
- a JsObjFuture
-
of
public static JsObjFuture of(String key1, JsFuture<?> fut1, String key2, JsFuture<?> fut2, String key3, JsFuture<?> fut3, String key4, JsFuture<?> fut4)
static factory method to create a JsObjFuture of four mappings- Parameters:
key1
- the first keyfut1
- the mapping associated to the first keykey2
- the second keyfut2
- the mapping associated to the second keykey3
- the third keyfut3
- the mapping associated to the third keykey4
- the fourth keyfut4
- the mapping associated to the fourth key- Returns:
- a JsObjFuture
-
of
public static JsObjFuture of(String key1, JsFuture<?> fut1, String key2, JsFuture<?> fut2, String key3, JsFuture<?> fut3, String key4, JsFuture<?> fut4, String key5, JsFuture<?> fut5)
static factory method to create a JsObjFuture of five mappings- Parameters:
key1
- the first keyfut1
- the mapping associated to the first keykey2
- the second keyfut2
- the mapping associated to the second keykey3
- the third keyfut3
- the mapping associated to the third keykey4
- the fourth keyfut4
- the mapping associated to the fourth keykey5
- the fifth keyfut5
- the mapping associated to the fifth key- Returns:
- a JsObjFuture
-
of
public static JsObjFuture of(String key1, JsFuture<?> fut1, String key2, JsFuture<?> fut2, String key3, JsFuture<?> fut3, String key4, JsFuture<?> fut4, String key5, JsFuture<?> fut5, String key6, JsFuture<?> fut6)
static factory method to create a JsObjFuture of six mappings- Parameters:
key1
- the first keyfut1
- the mapping associated to the first keykey2
- the second keyfut2
- the mapping associated to the second keykey3
- the third keyfut3
- the mapping associated to the third keykey4
- the fourth keyfut4
- the mapping associated to the fourth keykey5
- the fifth keyfut5
- the mapping associated to the fifth keykey6
- the sixth keyfut6
- the mapping associated to the sixth key- Returns:
- a JsObjFuture
-
of
public static JsObjFuture of(String key1, JsFuture<?> fut1, String key2, JsFuture<?> fut2, String key3, JsFuture<?> fut3, String key4, JsFuture<?> fut4, String key5, JsFuture<?> fut5, String key6, JsFuture<?> fut6, String key7, JsFuture<?> fut7)
static factory method to create a JsObjFuture of seven mappings- Parameters:
key1
- the first keyfut1
- the mapping associated to the first keykey2
- the second keyfut2
- the mapping associated to the second keykey3
- the third keyfut3
- the mapping associated to the third keykey4
- the fourth keyfut4
- the mapping associated to the fourth keykey5
- the fifth keyfut5
- the mapping associated to the fifth keykey6
- the sixth keyfut6
- the mapping associated to the sixth keykey7
- the seventh keyfut7
- the mapping associated to the seventh key- Returns:
- a JsObjFuture
-
of
public static JsObjFuture of(String key1, JsFuture<?> fut1, String key2, JsFuture<?> fut2, String key3, JsFuture<?> fut3, String key4, JsFuture<?> fut4, String key5, JsFuture<?> fut5, String key6, JsFuture<?> fut6, String key7, JsFuture<?> fut7, String key8, JsFuture<?> fut8)
static factory method to create a JsObjFuture of eight mappings- Parameters:
key1
- the first keyfut1
- the mapping associated to the first keykey2
- the second keyfut2
- the mapping associated to the second keykey3
- the third keyfut3
- the mapping associated to the third keykey4
- the fourth keyfut4
- the mapping associated to the fourth keykey5
- the fifth keyfut5
- the mapping associated to the fifth keykey6
- the sixth keyfut6
- the mapping associated to the sixth keykey7
- the seventh keyfut7
- the mapping associated to the seventh keykey8
- the eighth keyfut8
- the mapping associated to the eighth key- Returns:
- a JsObjFuture
-
of
public static JsObjFuture of(String key1, JsFuture<?> fut1, String key2, JsFuture<?> fut2, String key3, JsFuture<?> fut3, String key4, JsFuture<?> fut4, String key5, JsFuture<?> fut5, String key6, JsFuture<?> fut6, String key7, JsFuture<?> fut7, String key8, JsFuture<?> fut8, String key9, JsFuture<?> fut9)
static factory method to create a JsObjFuture of nine mappings- Parameters:
key1
- the first keyfut1
- the mapping associated to the first keykey2
- the second keyfut2
- the mapping associated to the second keykey3
- the third keyfut3
- the mapping associated to the third keykey4
- the fourth keyfut4
- the mapping associated to the fourth keykey5
- the fifth keyfut5
- the mapping associated to the fifth keykey6
- the sixth keyfut6
- the mapping associated to the sixth keykey7
- the seventh keyfut7
- the mapping associated to the seventh keykey8
- the eighth keyfut8
- the mapping associated to the eighth keykey9
- the ninth keyfut9
- the mapping associated to the ninth key- Returns:
- a JsObjFuture
-
of
public static JsObjFuture of(String key1, JsFuture<?> fut1, String key2, JsFuture<?> fut2, String key3, JsFuture<?> fut3, String key4, JsFuture<?> fut4, String key5, JsFuture<?> fut5, String key6, JsFuture<?> fut6, String key7, JsFuture<?> fut7, String key8, JsFuture<?> fut8, String key9, JsFuture<?> fut9, String key10, JsFuture<?> fut10)
static factory method to create a JsObjFuture of ten mappings- Parameters:
key1
- the first keyfut1
- the mapping associated to the first keykey2
- the second keyfut2
- the mapping associated to the second keykey3
- the third keyfut3
- the mapping associated to the third keykey4
- the fourth keyfut4
- the mapping associated to the fourth keykey5
- the fifth keyfut5
- the mapping associated to the fifth keykey6
- the sixth keyfut6
- the mapping associated to the sixth keykey7
- the seventh keyfut7
- the mapping associated to the seventh keykey8
- the eighth keyfut8
- the mapping associated to the eighth keykey9
- the ninth keyfut9
- the mapping associated to the ninth keykey10
- the tenth keyfut10
- the mapping associated to the tenth key- Returns:
- a JsObjFuture
-
of
public static JsObjFuture of(String key1, JsFuture<?> fut1, String key2, JsFuture<?> fut2, String key3, JsFuture<?> fut3, String key4, JsFuture<?> fut4, String key5, JsFuture<?> fut5, String key6, JsFuture<?> fut6, String key7, JsFuture<?> fut7, String key8, JsFuture<?> fut8, String key9, JsFuture<?> fut9, String key10, JsFuture<?> fut10, String key11, JsFuture<?> fut11)
static factory method to create a JsObjFuture of eleven mappings- Parameters:
key1
- the first keyfut1
- the mapping associated to the first keykey2
- the second keyfut2
- the mapping associated to the second keykey3
- the third keyfut3
- the mapping associated to the third keykey4
- the fourth keyfut4
- the mapping associated to the fourth keykey5
- the fifth keyfut5
- the mapping associated to the fifth keykey6
- the sixth keyfut6
- the mapping associated to the sixth keykey7
- the seventh keyfut7
- the mapping associated to the seventh keykey8
- the eighth keyfut8
- the mapping associated to the eighth keykey9
- the ninth keyfut9
- the mapping associated to the ninth keykey10
- the tenth keyfut10
- the mapping associated to the eleventh keykey11
- the tenth keyfut11
- the mapping associated to the eleventh key- Returns:
- a JsObjFuture
-
of
public static JsObjFuture of(String key1, JsFuture<?> fut1, String key2, JsFuture<?> fut2, String key3, JsFuture<?> fut3, String key4, JsFuture<?> fut4, String key5, JsFuture<?> fut5, String key6, JsFuture<?> fut6, String key7, JsFuture<?> fut7, String key8, JsFuture<?> fut8, String key9, JsFuture<?> fut9, String key10, JsFuture<?> fut10, String key11, JsFuture<?> fut11, String key12, JsFuture<?> fut12)
static factory method to create a JsObjFuture of twelve mappings- Parameters:
key1
- the first keyfut1
- the mapping associated to the first keykey2
- the second keyfut2
- the mapping associated to the second keykey3
- the third keyfut3
- the mapping associated to the third keykey4
- the fourth keyfut4
- the mapping associated to the fourth keykey5
- the fifth keyfut5
- the mapping associated to the fifth keykey6
- the sixth keyfut6
- the mapping associated to the sixth keykey7
- the seventh keyfut7
- the mapping associated to the seventh keykey8
- the eighth keyfut8
- the mapping associated to the eighth keykey9
- the ninth keyfut9
- the mapping associated to the ninth keykey10
- the tenth keyfut10
- the mapping associated to the eleventh keykey11
- the eleventh keyfut11
- the mapping associated to the eleventh keykey12
- the twelfth keyfut12
- the mapping associated to the twelfth key- Returns:
- a JsObjFuture
-
of
public static JsObjFuture of(String key1, JsFuture<?> fut1, String key2, JsFuture<?> fut2, String key3, JsFuture<?> fut3, String key4, JsFuture<?> fut4, String key5, JsFuture<?> fut5, String key6, JsFuture<?> fut6, String key7, JsFuture<?> fut7, String key8, JsFuture<?> fut8, String key9, JsFuture<?> fut9, String key10, JsFuture<?> fut10, String key11, JsFuture<?> fut11, String key12, JsFuture<?> fut12, String key13, JsFuture<?> fut13)
static factory method to create a JsObjFuture of thirteen mappings- Parameters:
key1
- the first keyfut1
- the mapping associated to the first keykey2
- the second keyfut2
- the mapping associated to the second keykey3
- the third keyfut3
- the mapping associated to the third keykey4
- the fourth keyfut4
- the mapping associated to the fourth keykey5
- the fifth keyfut5
- the mapping associated to the fifth keykey6
- the sixth keyfut6
- the mapping associated to the sixth keykey7
- the seventh keyfut7
- the mapping associated to the seventh keykey8
- the eighth keyfut8
- the mapping associated to the eighth keykey9
- the ninth keyfut9
- the mapping associated to the ninth keykey10
- the tenth keyfut10
- the mapping associated to the eleventh keykey11
- the eleventh keyfut11
- the mapping associated to the eleventh keykey12
- the twelfth keyfut12
- the mapping associated to the twelfth key,key13
- the thirteenth keyfut13
- the mapping associated to the thirteenth key- Returns:
- a JsObjFuture
-
of
public static JsObjFuture of(String key1, JsFuture<?> fut1, String key2, JsFuture<?> fut2, String key3, JsFuture<?> fut3, String key4, JsFuture<?> fut4, String key5, JsFuture<?> fut5, String key6, JsFuture<?> fut6, String key7, JsFuture<?> fut7, String key8, JsFuture<?> fut8, String key9, JsFuture<?> fut9, String key10, JsFuture<?> fut10, String key11, JsFuture<?> fut11, String key12, JsFuture<?> fut12, String key13, JsFuture<?> fut13, String key14, JsFuture<?> fut14)
static factory method to create a JsObjFuture of fourteen mappings- Parameters:
key1
- the first keyfut1
- the mapping associated to the first keykey2
- the second keyfut2
- the mapping associated to the second keykey3
- the third keyfut3
- the mapping associated to the third keykey4
- the fourth keyfut4
- the mapping associated to the fourth keykey5
- the fifth keyfut5
- the mapping associated to the fifth keykey6
- the sixth keyfut6
- the mapping associated to the sixth keykey7
- the seventh keyfut7
- the mapping associated to the seventh keykey8
- the eighth keyfut8
- the mapping associated to the eighth keykey9
- the ninth keyfut9
- the mapping associated to the ninth keykey10
- the tenth keyfut10
- the mapping associated to the eleventh keykey11
- the eleventh keyfut11
- the mapping associated to the eleventh keykey12
- the twelfth keyfut12
- the mapping associated to the twelfth key,key13
- the thirteenth keyfut13
- the mapping associated to the thirteenth keykey14
- the fourteenth keyfut14
- the mapping associated to the fourteenth key- Returns:
- a JsObjFuture
-
of
public static JsObjFuture of(String key1, JsFuture<?> fut1, String key2, JsFuture<?> fut2, String key3, JsFuture<?> fut3, String key4, JsFuture<?> fut4, String key5, JsFuture<?> fut5, String key6, JsFuture<?> fut6, String key7, JsFuture<?> fut7, String key8, JsFuture<?> fut8, String key9, JsFuture<?> fut9, String key10, JsFuture<?> fut10, String key11, JsFuture<?> fut11, String key12, JsFuture<?> fut12, String key13, JsFuture<?> fut13, String key14, JsFuture<?> fut14, String key15, JsFuture<?> fut15)
static factory method to create a JsObjFuture of fifteen mappings- Parameters:
key1
- the first keyfut1
- the mapping associated to the first keykey2
- the second keyfut2
- the mapping associated to the second keykey3
- the third keyfut3
- the mapping associated to the third keykey4
- the fourth keyfut4
- the mapping associated to the fourth keykey5
- the fifth keyfut5
- the mapping associated to the fifth keykey6
- the sixth keyfut6
- the mapping associated to the sixth keykey7
- the seventh keyfut7
- the mapping associated to the seventh keykey8
- the eighth keyfut8
- the mapping associated to the eighth keykey9
- the ninth keyfut9
- the mapping associated to the ninth keykey10
- the tenth keyfut10
- the mapping associated to the eleventh keykey11
- the eleventh keyfut11
- the mapping associated to the eleventh keykey12
- the twelfth keyfut12
- the mapping associated to the twelfth key,key13
- the thirteenth keyfut13
- the mapping associated to the thirteenth keykey14
- the fourteenth keyfut14
- the mapping associated to the fourteenth keykey15
- the fifteenth keyfut15
- the mapping associated to the fifteenth key- Returns:
- a JsObjFuture
-
empty
public static JsObjFuture empty()
returns a JsObjFuture that is completed returning the empty Json object- Returns:
- a JsObjFuture
-
set
public JsObjFuture set(String key, JsFuture<?> future)
returns a new object future inserting the given future at the given key- Parameters:
key
- the given keyfuture
- the given future- Returns:
- a new JsObjFuture
-
executor
public JsObjFuture 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 associated to the keys can run on threads froms different executors. The job to do by this JsObjFuture is to iterate the pairs (key,future), trigger every future and compose the result of every completed future to the final json object that will be returned.- Parameters:
executor
- the executor- Returns:
- the same this JsObjFuture
-
get
public CompletableFuture<JsObj> get()
it triggers the execution of all the completable futures, combining the results into a JsObj- Specified by:
get
in interfaceSupplier<CompletableFuture<JsObj>>
- Returns:
- a CompletableFuture of a json object
-
-