public interface AsyncResult<T>
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()
Modifier and Type | Method and Description |
---|---|
Throwable |
cause()
A Throwable describing failure.
|
boolean |
failed()
Did it fail?
|
default <U> AsyncResult<U> |
map(java.util.function.Function<T,U> mapper)
Apply a
mapper function on this async result. |
default <V> AsyncResult<V> |
map(V value)
Map the result of this async result to a specific
value . |
default <V> AsyncResult<V> |
mapEmpty()
Map the result of this async result to
null . |
default AsyncResult<T> |
otherwise(java.util.function.Function<Throwable,T> mapper)
Apply a
mapper function on this async result. |
default AsyncResult<T> |
otherwise(T value)
Map the failure of this async result to a specific
value . |
default AsyncResult<T> |
otherwiseEmpty()
Map the failure of this async result to
null . |
T |
result()
The result of the operation.
|
boolean |
succeeded()
Did it succeed?
|
T result()
Throwable cause()
boolean succeeded()
boolean failed()
default <U> AsyncResult<U> map(java.util.function.Function<T,U> mapper)
mapper
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.
mapper
- the mapper functiondefault <V> AsyncResult<V> map(V value)
value
.
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.
value
- the value that eventually completes the mapped async resultdefault <V> AsyncResult<V> mapEmpty()
null
.
This is a convenience for asyncResult.map((T) null)
or asyncResult.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.
default AsyncResult<T> otherwise(java.util.function.Function<Throwable,T> mapper)
mapper
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.
mapper
- the mapper functiondefault AsyncResult<T> otherwise(T value)
value
.
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.
value
- the value that eventually completes the mapped async resultdefault AsyncResult<T> otherwiseEmpty()
null
.
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.
Copyright © 2021 Eclipse. All rights reserved.