Top Description Methods
io.vertx.core

public Interface AsyncResult<T>

Known Direct Subinterfaces
io.vertx.core.Future
Imports
java.util.function.Function

Encapsulates the result of an asynchronous operation.

Many operations in Vert.x APIs provide results back by passing an instance of this in a io.vertx.core.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 TypeMethod and Description
public Throwable

Returns:

the cause or null if the operation succeeded.
cause
()

A Throwable describing failure.

public boolean

Returns:

true if it failed or false otherwise
failed
()

Did it fail?

public default <U> AsyncResult<U>

Returns:

the mapped async result
map
(Function<T, U>
the mapper function
mapper
)

Apply a mapper function on this async result.

public default <V> AsyncResult<V>

Returns:

the mapped async result
map
(V
the value that eventually completes the mapped async result
value
)

Map the result of this async result to a specific value.

public default <V> AsyncResult<V>

Returns:

the mapped async result
mapEmpty
()

Map the result of this async result to null.

public default AsyncResult<T>

Returns:

the mapped async result
otherwise
(Function<Throwable, T>
the mapper function
mapper
)

Apply a mapper function on this async result.

public default AsyncResult<T>

Returns:

the mapped async result
otherwise
(T
the value that eventually completes the mapped async result
value
)

Map the failure of this async result to a specific value.

public default AsyncResult<T>

Returns:

the mapped async result
otherwiseEmpty
()

Map the failure of this async result to null.

public T

Returns:

the result or null if the operation failed.
result
()

The result of the operation.

public boolean

Returns:

true if it succeded or false otherwise
succeeded
()

Did it succeed?

Method Detail

causeback to summary
public Throwable cause()

A Throwable describing failure. This will be null if the operation succeeded.

Returns:Throwable

the cause or null if the operation succeeded.

failedback to summary
public boolean failed()

Did it fail?

Returns:boolean

true if it failed or false otherwise

mapback to summary
public default <U> AsyncResult<U> map(Function<T, U> mapper)

Apply a 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.

Parameters
mapper:Function<T, U>

the mapper function

Returns:AsyncResult<U>

the mapped async result

mapback to summary
public default <V> AsyncResult<V> map(V value)

Map the result of this async result to a specific 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.

Parameters
value:V

the value that eventually completes the mapped async result

Returns:AsyncResult<V>

the mapped async result

mapEmptyback to summary
public default <V> AsyncResult<V> mapEmpty()

Map the result of this async result to 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.

Returns:AsyncResult<V>

the mapped async result

otherwiseback to summary
public default AsyncResult<T> otherwise(Function<Throwable, T> mapper)

Apply a 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.

Parameters
mapper:Function<Throwable, T>

the mapper function

Returns:AsyncResult<T>

the mapped async result

otherwiseback to summary
public default AsyncResult<T> otherwise(T value)

Map the failure of this async result to a specific 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.

Parameters
value:T

the value that eventually completes the mapped async result

Returns:AsyncResult<T>

the mapped async result

otherwiseEmptyback to summary
public default AsyncResult<T> otherwiseEmpty()

Map the failure of this async result to 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.

Returns:AsyncResult<T>

the mapped async result

resultback to summary
public T result()

The result of the operation. This will be null if the operation failed.

Returns:T

the result or null if the operation failed.

succeededback to summary
public boolean succeeded()

Did it succeed?

Returns:boolean

true if it succeded or false otherwise