public class CompositeFutureImpl extends Object implements CompositeFuture
| Modifier and Type | Field and Description |
|---|---|
protected ContextInternal |
context |
| Modifier and Type | Method and Description |
|---|---|
void |
addListener(Listener<T> listener)
Add a listener to the future result.
|
static CompositeFuture |
all(Future<?>... results) |
static CompositeFuture |
any(Future<?>... results) |
Throwable |
cause()
An exception describing failure.
|
Throwable |
cause(int index)
Returns a cause of a wrapped future
|
<U> Future<U> |
compose(Function<T,Future<U>> successMapper,
Function<Throwable,Future<U>> failureMapper)
Compose this future with a
successMapper and failureMapper functions. |
ContextInternal |
context() |
protected <U> void |
emit(U value,
Handler<U> handler) |
protected void |
emitFailure(Throwable cause,
Listener<T> listener) |
protected void |
emitSuccess(T value,
Listener<T> listener) |
<U> Future<T> |
eventually(Function<Void,Future<U>> mapper)
Compose this future with a
mapper that will be always be called. |
boolean |
failed()
Did it fail?
|
boolean |
failed(int index)
Returns true if a wrapped future is failed
|
protected void |
formatValue(Object value,
StringBuilder sb) |
boolean |
isComplete()
Has it completed?
|
boolean |
isComplete(int index)
Returns true if a wrapped future is completed
|
static CompositeFuture |
join(Future<?>... results) |
<U> Future<U> |
map(Function<T,U> mapper)
Apply a
mapper function on this future. |
<V> Future<V> |
map(V value)
Map the result of a future to a specific
value. |
CompositeFuture |
onComplete(Handler<AsyncResult<CompositeFuture>> handler)
Add a handler to be notified of the result.
|
CompositeFuture |
onFailure(Handler<Throwable> handler)
Add a handler to be notified of the failed result.
|
CompositeFuture |
onSuccess(Handler<CompositeFuture> handler)
Add a handler to be notified of the succeeded result.
|
Future<T> |
otherwise(Function<Throwable,T> mapper)
Apply a
mapper function on this future. |
Future<T> |
otherwise(T value)
Map the failure of a future to a specific
value. |
T |
result()
The result of the operation.
|
<T> T |
resultAt(int index)
Returns the result of a wrapped future
|
int |
size() |
boolean |
succeeded()
Did it succeed?
|
boolean |
succeeded(int index)
Returns true if a wrapped future is succeeded
|
String |
toString() |
<U> Future<U> |
transform(Function<AsyncResult<T>,Future<U>> mapper)
Transform this future with a
mapper functions. |
boolean |
tryComplete(T result) |
boolean |
tryFail(Throwable cause) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitall, all, all, all, all, all, any, any, any, any, any, any, causes, join, join, join, join, join, join, listcause, compose, compose, eventually, failed, failedFuture, failedFuture, flatMap, fromCompletionStage, fromCompletionStage, future, isComplete, map, map, mapEmpty, otherwise, otherwise, otherwiseEmpty, recover, result, succeeded, succeededFuture, succeededFuture, toCompletionStage, transformprotected final ContextInternal context
public static CompositeFuture all(Future<?>... results)
public static CompositeFuture any(Future<?>... results)
public static CompositeFuture join(Future<?>... results)
public Throwable cause(int index)
CompositeFuturecause in interface CompositeFutureindex - the wrapped future indexpublic boolean succeeded(int index)
CompositeFuturesucceeded in interface CompositeFutureindex - the wrapped future indexpublic boolean failed(int index)
CompositeFuturefailed in interface CompositeFutureindex - the wrapped future indexpublic boolean isComplete(int index)
CompositeFutureisComplete in interface CompositeFutureindex - the wrapped future indexpublic <T> T resultAt(int index)
CompositeFutureresultAt in interface CompositeFutureindex - the wrapped future indexpublic int size()
size in interface CompositeFuturepublic CompositeFuture onComplete(Handler<AsyncResult<CompositeFuture>> handler)
FutureonComplete in interface CompositeFutureonComplete in interface Future<CompositeFuture>handler - the handler that will be called with the resultpublic CompositeFuture onSuccess(Handler<CompositeFuture> handler)
FutureonSuccess in interface CompositeFutureonSuccess in interface Future<CompositeFuture>handler - the handler that will be called with the succeeded resultpublic CompositeFuture onFailure(Handler<Throwable> handler)
FutureonFailure in interface CompositeFutureonFailure in interface Future<CompositeFuture>handler - the handler that will be called with the failed resultprotected void formatValue(Object value, StringBuilder sb)
public T result()
public Throwable cause()
public boolean succeeded()
public boolean failed()
public boolean isComplete()
public void addListener(Listener<T> listener)
FutureInternallistener - the listenerpublic boolean tryComplete(T result)
public boolean tryFail(Throwable cause)
public final ContextInternal context()
context in interface FutureInternal<T>null when there is noneprotected final void emitSuccess(T value,
Listener<T> listener)
protected final <U> void emit(U value,
Handler<U> handler)
public <U> Future<U> compose(Function<T,Future<U>> successMapper, Function<Throwable,Future<U>> failureMapper)
FuturesuccessMapper and failureMapper functions.
When this future (the one on which compose is called) succeeds, the successMapper 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, the failureMapper 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.
public <U> Future<U> transform(Function<AsyncResult<T>,Future<U>> mapper)
Futuremapper functions.
When this future (the one on which transform is called) completes, the mapper 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.
public <U> Future<T> eventually(Function<Void,Future<U>> mapper)
Futuremapper that will be always be called.
When this future (the one on which eventually is called) completes, the mapper 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 mapper will not influence the the nature
of the returned future.
eventually in interface Future<T>mapper - the function returning the future.public <U> Future<U> map(Function<T,U> mapper)
Futuremapper 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.
map in interface AsyncResult<T>map in interface Future<T>mapper - the mapper functionpublic <V> Future<V> map(V value)
Futurevalue.
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.
map in interface AsyncResult<T>map in interface Future<T>value - the value that eventually completes the mapped futurepublic Future<T> otherwise(Function<Throwable,T> mapper)
Futuremapper 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.
otherwise in interface AsyncResult<T>otherwise in interface Future<T>mapper - the mapper functionpublic Future<T> otherwise(T value)
Futurevalue.
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.
otherwise in interface AsyncResult<T>otherwise in interface Future<T>value - the value that eventually completes the mapped futureCopyright © 2021. All rights reserved.