Interface AsyncResult<T>
- All Known Subinterfaces:
CompositeFuture
,Future<T>
,FutureInternal<T>
,PromiseInternal<T>
- All Known Implementing Classes:
CompositeFutureImpl
,FailedFuture
,FutureImpl
,PromiseImpl
,SucceededFuture
Many operations in Vert.x APIs provide results back by passing an instance of this in a Handler
.
The result can either have failed or succeeded.
If it failed then the cause of the failure is available with cause()
.
If it succeeded then the actual result is available with result()
- Author:
- Tim Fox
-
Method Summary
Modifier and TypeMethodDescriptioncause()
A Throwable describing failure.boolean
failed()
Did it fail?default <U> AsyncResult<U>
Apply amapper
function on this async result.default <V> AsyncResult<V>
map
(V value) Map the result of this async result to a specificvalue
.default <V> AsyncResult<V>
mapEmpty()
Map the result of this async result tonull
.default AsyncResult<T>
Apply amapper
function on this async result.default AsyncResult<T>
Map the failure of this async result to a specificvalue
.default AsyncResult<T>
Map the failure of this async result tonull
.result()
The result of the operation.boolean
Did it succeed?
-
Method Details
-
result
T result()The result of the operation. This will be null if the operation failed.- Returns:
- the result or null if the operation failed.
-
cause
Throwable cause()A Throwable describing failure. This will be null if the operation succeeded.- Returns:
- the cause or null if the operation succeeded.
-
succeeded
boolean succeeded()Did it succeed?- Returns:
- true if it succeded or false otherwise
-
failed
boolean failed()Did it fail?- Returns:
- true if it failed or false otherwise
-
map
Apply amapper
function on this async result.The
mapper
is called with the completed value and this mapper returns a value. This value will complete the result returned by this method call.When this async result is failed, the failure will be propagated to the returned async result and the
mapper
will not be called.- Parameters:
mapper
- the mapper function- Returns:
- the mapped async result
-
map
Map the result of this async result to a specificvalue
.When this async result succeeds, this
value
will succeeed the async result returned by this method call.When this async result fails, the failure will be propagated to the returned async result.
- Parameters:
value
- the value that eventually completes the mapped async result- Returns:
- the mapped async result
-
mapEmpty
Map the result of this async result tonull
.This is a convenience for
asyncResult.map((T) null)
orasyncResult.map((Void) null)
.When this async result succeeds,
null
will succeeed the async result returned by this method call.When this async result fails, the failure will be propagated to the returned async result.
- Returns:
- the mapped async result
-
otherwise
Apply amapper
function on this async result.The
mapper
is called with the failure and this mapper returns a value. This value will complete the result returned by this method call.When this async result is succeeded, the value will be propagated to the returned async result and the
mapper
will not be called.- Parameters:
mapper
- the mapper function- Returns:
- the mapped async result
-
otherwise
Map the failure of this async result to a specificvalue
.When this async result fails, this
value
will succeeed the async result returned by this method call.When this async succeeds, the result will be propagated to the returned async result.
- Parameters:
value
- the value that eventually completes the mapped async result- Returns:
- the mapped async result
-
otherwiseEmpty
Map the failure of this async result tonull
.This is a convenience for
asyncResult.otherwise((T) null)
.When this async result fails, the
null
will succeeed the async result returned by this method call.When this async succeeds, the result will be propagated to the returned async result.
- Returns:
- the mapped async result
-