Class CompositeFutureImpl
- All Implemented Interfaces:
AsyncResult<CompositeFuture>,CompositeFuture,Future<CompositeFuture>,FutureInternal<CompositeFuture>,Listener<Object>
- Author:
- Julien Viet
-
Method Summary
Modifier and TypeMethodDescriptionstatic CompositeFuturestatic CompositeFuturecause(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 asuccessMapperandfailureMapperfunctions.protected final voidemitFailure(Throwable cause, Listener<CompositeFuture> listener) protected final voidemitSuccess(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 afunctionthat will be always be called.booleanfailed(int index) Returns true if a wrapped future is failedprotected voidformatValue(Object value, StringBuilder sb) booleanisComplete(int index) Returns true if a wrapped future is completedstatic CompositeFuture<U> Future<U>map(Function<CompositeFuture, U> mapper) Apply amapperfunction 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.voidSignal the failureonSuccess(Handler<CompositeFuture> handler) Add a handler to be notified of the succeeded result.voidSignal the success.otherwise(Function<Throwable, CompositeFuture> mapper) Apply amapperfunction on this future.otherwise(CompositeFuture value) Map the failure of a future to a specificvalue.<T> TresultAt(int index) Returns the result of a wrapped futureintsize()booleansucceeded(int index) Returns true if a wrapped future is succeeded<U> Future<U>transform(Function<AsyncResult<CompositeFuture>, Future<U>> mapper) Transform this future with amapperfunctions.Methods inherited from class dev.webfx.platform.async.impl.FutureImpl
addListener, cause, failed, isComplete, onComplete, removeListener, result, succeeded, toString, tryComplete, tryFailMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface dev.webfx.platform.async.CompositeFuture
causes, listMethods 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:ListenerSignal the success. -
onFailure
Description copied from interface:ListenerSignal the failure -
cause
Description copied from interface:CompositeFutureReturns a cause of a wrapped future- Specified by:
causein interfaceCompositeFuture- Parameters:
index- the wrapped future index
-
succeeded
public boolean succeeded(int index) Description copied from interface:CompositeFutureReturns true if a wrapped future is succeeded- Specified by:
succeededin interfaceCompositeFuture- Parameters:
index- the wrapped future index
-
failed
public boolean failed(int index) Description copied from interface:CompositeFutureReturns true if a wrapped future is failed- Specified by:
failedin interfaceCompositeFuture- Parameters:
index- the wrapped future index
-
isComplete
public boolean isComplete(int index) Description copied from interface:CompositeFutureReturns true if a wrapped future is completed- Specified by:
isCompletein interfaceCompositeFuture- Parameters:
index- the wrapped future index
-
resultAt
public <T> T resultAt(int index) Description copied from interface:CompositeFutureReturns the result of a wrapped future- Specified by:
resultAtin interfaceCompositeFuture- Parameters:
index- the wrapped future index
-
size
public int size()- Specified by:
sizein interfaceCompositeFuture- Returns:
- the number of wrapped future
-
onComplete
Description copied from interface:FutureAdd a handler to be notified of the result.WARNING: this is a terminal operation. If several
handlers are registered, there is no guarantee that they will be invoked in order of registration.- Specified by:
onCompletein interfaceCompositeFuture- Specified by:
onCompletein interfaceFuture<CompositeFuture>- Overrides:
onCompletein 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:FutureAdd a handler to be notified of the succeeded result.WARNING: this is a terminal operation. If several
handlers are registered, there is no guarantee that they will be invoked in order of registration.- Specified by:
onSuccessin interfaceCompositeFuture- Specified by:
onSuccessin interfaceFuture<CompositeFuture>- Overrides:
onSuccessin 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:FutureAdd a handler to be notified of the failed result.WARNING: this is a terminal operation. If several
handlers are registered, there is no guarantee that they will be invoked in order of registration.- Specified by:
onFailurein interfaceCompositeFuture- Specified by:
onFailurein interfaceFuture<CompositeFuture>- Overrides:
onFailurein 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:
formatValuein 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:FutureCompose this future with asuccessMapperandfailureMapperfunctions.When this future (the one on which
composeis called) succeeds, thesuccessMapperwill 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
composeis called) fails, thefailureMapperwill 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:FutureTransform this future with amapperfunctions.When this future (the one on which
transformis called) completes, themapperwill 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:FutureCompose this future with afunctionthat will be always be called.When this future (the one on which
eventuallyis called) completes, thefunctionwill 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
functionwill not influence the nature of the returned future.- Specified by:
eventuallyin interfaceFuture<T>- Parameters:
mapper- the function returning the future.- Returns:
- the composed future
-
map
Description copied from interface:FutureApply amapperfunction on this future.When this future succeeds, the
mapperwill 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
mapperthrows 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
mapperwill not be called.- Specified by:
mapin interfaceAsyncResult<T>- Specified by:
mapin interfaceFuture<T>- Parameters:
mapper- the mapper function- Returns:
- the mapped future
-
map
Description copied from interface:FutureMap the result of a future to a specificvalue.When this future succeeds, this
valuewill complete the future returned by this method call.When this future fails, the failure will be propagated to the returned future.
- Specified by:
mapin interfaceAsyncResult<T>- Specified by:
mapin interfaceFuture<T>- Parameters:
value- the value that eventually completes the mapped future- Returns:
- the mapped future
-
otherwise
Description copied from interface:FutureApply amapperfunction on this future.When this future fails, the
mapperwill 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
mapperthrows 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
mapperwill not be called.- Specified by:
otherwisein interfaceAsyncResult<T>- Specified by:
otherwisein interfaceFuture<T>- Parameters:
mapper- the mapper function- Returns:
- the mapped future
-
otherwise
Description copied from interface:FutureMap the failure of a future to a specificvalue.When this future fails, this
valuewill complete the future returned by this method call.When this future succeeds, the result will be propagated to the returned future.
- Specified by:
otherwisein interfaceAsyncResult<T>- Specified by:
otherwisein interfaceFuture<T>- Parameters:
value- the value that eventually completes the mapped future- Returns:
- the mapped future
-