Package dev.webfx.platform.async
Interface CompositeFuture
- All Superinterfaces:
AsyncResult<CompositeFuture>
,Future<CompositeFuture>
- All Known Implementing Classes:
CompositeFutureImpl
The composite future wraps a list of
futures
, it is useful when several futures
needs to be coordinated.
The handlers set for the coordinated futures are overridden by the handler of the composite future.- Author:
- Julien Viet
-
Method Summary
Modifier and TypeMethodDescriptioncause
(int index) Returns a cause of a wrapped futurecauses()
boolean
failed
(int index) Returns true if a wrapped future is failedboolean
isComplete
(int index) Returns true if a wrapped future is completeddefault <T> List<T>
list()
onComplete
(Handler<AsyncResult<CompositeFuture>> handler) Deprecated.default CompositeFuture
Add a handler to be notified of the failed result.default CompositeFuture
onSuccess
(Handler<CompositeFuture> handler) Add a handler to be notified of the succeeded result.<T> T
resultAt
(int index) Returns the result of a wrapped futureint
size()
boolean
succeeded
(int index) Returns true if a wrapped future is succeededMethods inherited from interface dev.webfx.platform.async.Future
andThen, cause, compose, compose, eventually, eventually, failed, flatMap, isComplete, map, map, mapEmpty, onComplete, otherwise, otherwise, otherwiseEmpty, recover, result, succeeded, transform
-
Method Details
-
onComplete
Deprecated.instead useFuture.join(List)
LikeFuture.join(Future, Future)
but with a list of futures.When the list is empty, the returned future will be already completed.
- Specified by:
onComplete
in interfaceFuture<CompositeFuture>
- Parameters:
handler
- the handler that will be called with the result- Returns:
- a reference to this, so it can be used fluently
-
onSuccess
Description copied from interface:Future
Add a handler to be notified of the succeeded result.WARNING: this is a terminal operation. If several
handler
s are registered, there is no guarantee that they will be invoked in order of registration.- Specified by:
onSuccess
in interfaceFuture<CompositeFuture>
- Parameters:
handler
- the handler that will be called with the succeeded result- Returns:
- a reference to this, so it can be used fluently
-
onFailure
Description copied from interface:Future
Add a handler to be notified of the failed result.WARNING: this is a terminal operation. If several
handler
s are registered, there is no guarantee that they will be invoked in order of registration.- Specified by:
onFailure
in interfaceFuture<CompositeFuture>
- Parameters:
handler
- the handler that will be called with the failed result- Returns:
- a reference to this, so it can be used fluently
-
cause
Returns a cause of a wrapped future- Parameters:
index
- the wrapped future index
-
succeeded
boolean succeeded(int index) Returns true if a wrapped future is succeeded- Parameters:
index
- the wrapped future index
-
failed
boolean failed(int index) Returns true if a wrapped future is failed- Parameters:
index
- the wrapped future index
-
isComplete
boolean isComplete(int index) Returns true if a wrapped future is completed- Parameters:
index
- the wrapped future index
-
resultAt
<T> T resultAt(int index) Returns the result of a wrapped future- Parameters:
index
- the wrapped future index
-
size
int size()- Returns:
- the number of wrapped future
-
list
- Returns:
- a list of the current completed values. If one future is not yet resolved or is failed, null will be used
-
causes
- Returns:
- a list of all the eventual failure causes. If no future failed, returns a list of null values.
-
Future.join(List)