public interface PromisedValues<T>
CompletionStages to be combined together and completed
as one and should something go wrong, instead of throwing CompletionExceptions it captures the cause and returns null for that
data value, other wise it allows you to access them as a list of values.
This class really encapsulate a list of promised values. It is considered finished when all of the underlying futures
are finished.
You can get that list of values via toList(). You can also compose a CompletableFuture of that
list of values via toCompletableFuture() ()}| Modifier and Type | Method and Description |
|---|---|
static <T> PromisedValues<T> |
allOf(java.util.concurrent.CompletionStage<T> f1,
java.util.concurrent.CompletionStage<T> f2)
Returns a new
PromisedValues that is completed when all of
the given CompletionStages complete. |
static <T> PromisedValues<T> |
allOf(java.util.concurrent.CompletionStage<T> f1,
java.util.concurrent.CompletionStage<T> f2,
java.util.concurrent.CompletionStage<T> f3)
Returns a new
PromisedValues that is completed when all of
the given CompletionStages complete. |
static <T> PromisedValues<T> |
allOf(java.util.concurrent.CompletionStage<T> f1,
java.util.concurrent.CompletionStage<T> f2,
java.util.concurrent.CompletionStage<T> f3,
java.util.concurrent.CompletionStage<T> f4)
Returns a new
PromisedValues that is completed when all of
the given CompletionStages complete. |
static <T> PromisedValues<T> |
allOf(java.util.List<? extends java.util.concurrent.CompletionStage<T>> cfs)
Returns a new
PromisedValues that is completed when all of
the given CompletionStages complete. |
static <T> PromisedValues<T> |
allPromisedValues(java.util.List<PromisedValues<T>> cfs)
Returns a new
PromisedValues that is completed when all of
the given PromisedValuess complete. |
static <T> PromisedValues<T> |
allPromisedValues(PromisedValues<T> pv1,
PromisedValues<T> pv2)
Returns a new
PromisedValues that is completed when all of
the given PromisedValuess complete. |
static <T> PromisedValues<T> |
allPromisedValues(PromisedValues<T> pv1,
PromisedValues<T> pv2,
PromisedValues<T> pv3)
Returns a new
PromisedValues that is completed when all of
the given PromisedValuess complete. |
static <T> PromisedValues<T> |
allPromisedValues(PromisedValues<T> pv1,
PromisedValues<T> pv2,
PromisedValues<T> pv3,
PromisedValues<T> pv4)
Returns a new
PromisedValues that is completed when all of
the given PromisedValuess complete. |
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
|
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
|
static <T> PromisedValues<T> allOf(java.util.List<? extends java.util.concurrent.CompletionStage<T>> cfs)
PromisedValues that is completed when all of
the given CompletionStages complete. If any of the given
CompletionStages complete exceptionally, then the returned
PromisedValues also does so.T - the type of valuescfs - the CompletionStages to combinestatic <T> PromisedValues<T> allOf(java.util.concurrent.CompletionStage<T> f1, java.util.concurrent.CompletionStage<T> f2)
PromisedValues that is completed when all of
the given CompletionStages complete. If any of the given
CompletionStages complete exceptionally, then the returned
PromisedValues also does so.T - the type of valuesf1 - the 1st completable futuref2 - the 2nd completable futurestatic <T> PromisedValues<T> allOf(java.util.concurrent.CompletionStage<T> f1, java.util.concurrent.CompletionStage<T> f2, java.util.concurrent.CompletionStage<T> f3)
PromisedValues that is completed when all of
the given CompletionStages complete. If any of the given
CompletionStages complete exceptionally, then the returned
PromisedValues also does so.T - the type of valuesf1 - the 1st completable futuref2 - the 2nd completable futuref3 - the 3rd completable futurestatic <T> PromisedValues<T> allOf(java.util.concurrent.CompletionStage<T> f1, java.util.concurrent.CompletionStage<T> f2, java.util.concurrent.CompletionStage<T> f3, java.util.concurrent.CompletionStage<T> f4)
PromisedValues that is completed when all of
the given CompletionStages complete. If any of the given
CompletionStages complete exceptionally, then the returned
PromisedValues also does so.T - the type of valuesf1 - the 1st completable futuref2 - the 2nd completable futuref3 - the 3rd completable futuref4 - the 4th completable futurestatic <T> PromisedValues<T> allPromisedValues(java.util.List<PromisedValues<T>> cfs)
PromisedValues that is completed when all of
the given PromisedValuess complete. If any of the given
PromisedValuess complete exceptionally, then the returned
PromisedValues also does so.T - the type of valuescfs - the list to combinestatic <T> PromisedValues<T> allPromisedValues(PromisedValues<T> pv1, PromisedValues<T> pv2)
PromisedValues that is completed when all of
the given PromisedValuess complete. If any of the given
PromisedValuess complete exceptionally, then the returned
PromisedValues also does so.T - the type of valuespv1 - the 1st promised valuepv2 - the 2nd promised valuestatic <T> PromisedValues<T> allPromisedValues(PromisedValues<T> pv1, PromisedValues<T> pv2, PromisedValues<T> pv3)
PromisedValues that is completed when all of
the given PromisedValuess complete. If any of the given
PromisedValuess complete exceptionally, then the returned
PromisedValues also does so.T - the type of valuespv1 - the 1st promised valuepv2 - the 2nd promised valuepv3 - the 3rd promised valuestatic <T> PromisedValues<T> allPromisedValues(PromisedValues<T> pv1, PromisedValues<T> pv2, PromisedValues<T> pv3, PromisedValues<T> pv4)
PromisedValues that is completed when all of
the given PromisedValuess complete. If any of the given
PromisedValuess complete exceptionally, then the returned
PromisedValues also does so.T - the type of valuespv1 - the 1st promised valuepv2 - the 2nd promised valuepv3 - the 3rd promised valuepv4 - the 4th promised valuePromisedValues<T> thenAccept(java.util.function.Consumer<PromisedValues<T>> handler)
PromisedValues as a parameterhandler - the call back which will be given this objectPromisedValues which you can compose more computations withboolean succeeded()
boolean failed()
boolean isDone()
PromisedValues has completed)java.lang.Throwable cause()
boolean succeeded(int index)
CompletionStage at the specified index succeededindex - the index of the CompletionStagejava.lang.Throwable cause(int index)
index - the index of the CompletionStageT get(int index)
index - the index of the futurejava.util.List<T> toList()
int size()
CompletionStages under the coversjava.util.List<T> join()
CompletionException with the underlying
exception as its cause.toList()java.util.concurrent.CancellationException - if the computation was cancelledjava.util.concurrent.CompletionException - if this future completed
exceptionally or a completion computation threw an exceptionjava.util.concurrent.CompletableFuture<java.util.List<T>> toCompletableFuture()
CompletableFuture that returns the list of underlying values