public final class SucceededFuture<T> extends Object
| Modifier and Type | Field and Description |
|---|---|
protected ContextInternal |
context |
static SucceededFuture |
EMPTY
Stateless instance of empty results that can be shared safely.
|
| Constructor and Description |
|---|
SucceededFuture(ContextInternal context,
T result)
Create a future that has already succeeded
|
SucceededFuture(T result)
Create a future that has already succeeded
|
| Modifier and Type | Method and Description |
|---|---|
void |
addListener(Listener<T> listener)
Add a listener to the future result.
|
Throwable |
cause()
A Throwable describing failure.
|
<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 |
isComplete()
Has the future completed?
|
<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. |
Future<T> |
onComplete(Handler<AsyncResult<T>> handler)
Add a handler to be notified of the result.
|
Future<T> |
onFailure(Handler<Throwable> handler)
Add a handler to be notified of the failed result.
|
Future<T> |
onSuccess(Handler<T> 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.
|
boolean |
succeeded()
Did it succeed?
|
String |
toString() |
<U> Future<U> |
transform(Function<AsyncResult<T>,Future<U>> mapper)
Transform this future with a
mapper functions. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitcompose, failedFuture, failedFuture, flatMap, fromCompletionStage, fromCompletionStage, future, mapEmpty, otherwiseEmpty, recover, succeededFuture, succeededFuture, toCompletionStagepublic static final SucceededFuture EMPTY
protected final ContextInternal context
public SucceededFuture(T result)
result - the resultpublic SucceededFuture(ContextInternal context, T result)
context - the contextresult - the resultpublic boolean isComplete()
FutureIt's completed if it's either succeeded or failed.
public Future<T> onSuccess(Handler<T> handler)
Futurehandler - the handler that will be called with the succeeded resultpublic Future<T> onFailure(Handler<Throwable> handler)
Futurehandler - the handler that will be called with the failed resultpublic Future<T> onComplete(Handler<AsyncResult<T>> handler)
Futurehandler - the handler that will be called with the resultpublic void addListener(Listener<T> listener)
FutureInternallistener - the listenerpublic T result()
AsyncResultpublic Throwable cause()
AsyncResultpublic boolean succeeded()
AsyncResultpublic boolean failed()
AsyncResultpublic <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.
public 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.
public 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.
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 functionCopyright © 2021. All rights reserved.