public interface Future<T> extends AsyncResult<T>
Modifier and Type | Field and Description |
---|---|
static FutureFactory |
factory |
Modifier and Type | Method and Description |
---|---|
void |
complete()
Set a null result.
|
void |
complete(T result)
Set the result.
|
void |
fail(String failureMessage)
Set the failure.
|
void |
fail(Throwable throwable)
Set the failure.
|
static <T> Future<T> |
failedFuture(String failureMessage)
Create a failed future with the specified failure message.
|
static <T> Future<T> |
failedFuture(Throwable t)
Create a failed future with the specified failure cause.
|
static <T> Future<T> |
future()
Create a future that hasn't completed yet
|
boolean |
isComplete()
Has the future completed?
|
void |
setHandler(Handler<AsyncResult<T>> handler)
Set a handler for the result.
|
static <T> Future<T> |
succeededFuture()
Create a succeeded future with a null result
|
static <T> Future<T> |
succeededFuture(T result)
Created a succeeded future with the specified result.
|
cause, failed, result, succeeded
static final FutureFactory factory
static <T> Future<T> future()
T
- the result typestatic <T> Future<T> succeededFuture()
T
- the result typestatic <T> Future<T> succeededFuture(T result)
T
- the result typeresult
- the resultstatic <T> Future<T> failedFuture(Throwable t)
T
- the result typet
- the failure cause as a Throwablestatic <T> Future<T> failedFuture(String failureMessage)
T
- the result typefailureMessage
- the failure messageboolean isComplete()
It's completed if it's either succeeded or failed.
void setHandler(Handler<AsyncResult<T>> handler)
If the future has already been completed it will be called immediately. Otherwise it will be called when the future is completed.
handler
- the Handler that will be called with the resultvoid complete(T result)
result
- the resultIllegalStateException
- when the future is already completedvoid complete()
IllegalStateException
- when the future is already completedvoid fail(Throwable throwable)
throwable
- the failure causevoid fail(String failureMessage)
failureMessage
- the failure messageCopyright © 2015. All Rights Reserved.