Class CompositeFutureImpl
- All Implemented Interfaces:
AsyncResult<CompositeFuture>
,CompositeFuture
,Future<CompositeFuture>
,FutureInternal<CompositeFuture>
,Listener<Object>
- Author:
- Julien Viet
-
Method Summary
Modifier and TypeMethodDescriptionstatic CompositeFuture
static CompositeFuture
cause
(int index) Returns a cause of a wrapped future<U> Future<U>
compose
(Function<CompositeFuture, Future<U>> successMapper, Function<Throwable, Future<U>> failureMapper) Compose this future with asuccessMapper
andfailureMapper
functions.protected final void
emitFailure
(Throwable cause, Listener<CompositeFuture> listener) protected final void
emitSuccess
(CompositeFuture value, Listener<CompositeFuture> listener) Create a future that hasn't completed yet<U> Future<CompositeFuture>
eventually
(Function<Void, Future<U>> mapper) Compose this future with afunction
that will be always be called.boolean
failed
(int index) Returns true if a wrapped future is failedprotected void
formatValue
(Object value, StringBuilder sb) boolean
isComplete
(int index) Returns true if a wrapped future is completedstatic CompositeFuture
<U> Future<U>
map
(Function<CompositeFuture, U> mapper) Apply amapper
function on this future.<V> Future<V>
map
(V value) Map the result of a future to a specificvalue
.onComplete
(Handler<AsyncResult<CompositeFuture>> handler) Add a handler to be notified of the result.Add a handler to be notified of the failed result.void
Signal the failureonSuccess
(Handler<CompositeFuture> handler) Add a handler to be notified of the succeeded result.void
Signal the success.otherwise
(Function<Throwable, CompositeFuture> mapper) Apply amapper
function on this future.otherwise
(CompositeFuture value) Map the failure of a future to a specificvalue
.<T> T
resultAt
(int index) Returns the result of a wrapped futureint
size()
boolean
succeeded
(int index) Returns true if a wrapped future is succeeded<U> Future<U>
transform
(Function<AsyncResult<CompositeFuture>, Future<U>> mapper) Transform this future with amapper
functions.Methods inherited from class dev.webfx.platform.async.impl.FutureImpl
addListener, cause, failed, isComplete, onComplete, removeListener, result, succeeded, toString, tryComplete, tryFail
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface dev.webfx.platform.async.CompositeFuture
causes, list
Methods 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
-
all
-
any
-
join
-
onSuccess
Description copied from interface:Listener
Signal the success. -
onFailure
Description copied from interface:Listener
Signal the failure -
cause
Description copied from interface:CompositeFuture
Returns a cause of a wrapped future- Specified by:
cause
in interfaceCompositeFuture
- Parameters:
index
- the wrapped future index
-
succeeded
public boolean succeeded(int index) Description copied from interface:CompositeFuture
Returns true if a wrapped future is succeeded- Specified by:
succeeded
in interfaceCompositeFuture
- Parameters:
index
- the wrapped future index
-
failed
public boolean failed(int index) Description copied from interface:CompositeFuture
Returns true if a wrapped future is failed- Specified by:
failed
in interfaceCompositeFuture
- Parameters:
index
- the wrapped future index
-
isComplete
public boolean isComplete(int index) Description copied from interface:CompositeFuture
Returns true if a wrapped future is completed- Specified by:
isComplete
in interfaceCompositeFuture
- Parameters:
index
- the wrapped future index
-
resultAt
public <T> T resultAt(int index) Description copied from interface:CompositeFuture
Returns the result of a wrapped future- Specified by:
resultAt
in interfaceCompositeFuture
- Parameters:
index
- the wrapped future index
-
size
public int size()- Specified by:
size
in interfaceCompositeFuture
- Returns:
- the number of wrapped future
-
onComplete
Description copied from interface:Future
Add a handler to be notified of the 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:
onComplete
in interfaceCompositeFuture
- Specified by:
onComplete
in interfaceFuture<CompositeFuture>
- Overrides:
onComplete
in classFutureImpl<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 interfaceCompositeFuture
- Specified by:
onSuccess
in interfaceFuture<CompositeFuture>
- Overrides:
onSuccess
in classFutureImpl<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 interfaceCompositeFuture
- Specified by:
onFailure
in interfaceFuture<CompositeFuture>
- Overrides:
onFailure
in classFutureImpl<CompositeFuture>
- Parameters:
handler
- the handler that will be called with the failed result- Returns:
- a reference to this, so it can be used fluently
-
formatValue
- Overrides:
formatValue
in classFutureImpl<CompositeFuture>
-
emitSuccess
Create a future that hasn't completed yet -
emitFailure
-
compose
public <U> Future<U> compose(Function<CompositeFuture, Future<U>> successMapper, Function<Throwable, Future<U>> failureMapper) Description copied from interface:Future
Compose this future with asuccessMapper
andfailureMapper
functions.When this future (the one on which
compose
is called) succeeds, thesuccessMapper
will be called with the completed value and this mapper returns another future object. This returned future completion will complete the future returned by this method call.When this future (the one on which
compose
is called) fails, thefailureMapper
will be called with the failure and this mapper returns another future object. This returned future completion will complete the future returned by this method call.If any mapper function throws an exception, the returned future will be failed with this exception.
-
transform
Description copied from interface:Future
Transform this future with amapper
functions.When this future (the one on which
transform
is called) completes, themapper
will be called with the async result and this mapper returns another future object. This returned future completion will complete the future returned by this method call.If any mapper function throws an exception, the returned future will be failed with this exception.
-
eventually
Description copied from interface:Future
Compose this future with afunction
that will be always be called.When this future (the one on which
eventually
is called) completes, thefunction
will be called and this mapper returns another future object. This returned future completion will complete the future returned by this method call with the original result of the future.The outcome of the future returned by the
function
will not influence the nature of the returned future.- Specified by:
eventually
in interfaceFuture<T>
- Parameters:
mapper
- the function returning the future.- Returns:
- the composed future
-
map
Description copied from interface:Future
Apply amapper
function on this future.When this future succeeds, the
mapper
will be called with the completed value and this mapper returns a value. This value will complete the future returned by this method call.If the
mapper
throws an exception, the returned future will be failed with this exception.When this future fails, the failure will be propagated to the returned future and the
mapper
will not be called.- Specified by:
map
in interfaceAsyncResult<T>
- Specified by:
map
in interfaceFuture<T>
- Parameters:
mapper
- the mapper function- Returns:
- the mapped future
-
map
Description copied from interface:Future
Map the result of a future to a specificvalue
.When this future succeeds, this
value
will complete the future returned by this method call.When this future fails, the failure will be propagated to the returned future.
- Specified by:
map
in interfaceAsyncResult<T>
- Specified by:
map
in interfaceFuture<T>
- Parameters:
value
- the value that eventually completes the mapped future- Returns:
- the mapped future
-
otherwise
Description copied from interface:Future
Apply amapper
function on this future.When this future fails, the
mapper
will be called with the completed value and this mapper returns a value. This value will complete the future returned by this method call.If the
mapper
throws an exception, the returned future will be failed with this exception.When this future succeeds, the result will be propagated to the returned future and the
mapper
will not be called.- Specified by:
otherwise
in interfaceAsyncResult<T>
- Specified by:
otherwise
in interfaceFuture<T>
- Parameters:
mapper
- the mapper function- Returns:
- the mapped future
-
otherwise
Description copied from interface:Future
Map the failure of a future to a specificvalue
.When this future fails, this
value
will complete the future returned by this method call.When this future succeeds, the result will be propagated to the returned future.
- Specified by:
otherwise
in interfaceAsyncResult<T>
- Specified by:
otherwise
in interfaceFuture<T>
- Parameters:
value
- the value that eventually completes the mapped future- Returns:
- the mapped future
-