Package io.vertx.mutiny.core
Class Future<T>
- java.lang.Object
-
- io.vertx.mutiny.core.Future<T>
-
- Direct Known Subclasses:
CompositeFuture
public class Future<T> extends Object
Represents the result of an action that may, or may not, have occurred yet.
NOTE: This class has been automatically generated from theoriginalnon Mutiny-ified interface using Vert.x codegen.
-
-
Field Summary
Fields Modifier and Type Field Description static TypeArg<Future>__TYPE_ARGTypeArg<T>__typeArg_0
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description Throwablecause()voidcomplete()Deprecated.voidcomplete(T result)Deprecated.io.vertx.core.Handler<io.vertx.core.AsyncResult<T>>completer()Deprecated.<U> Future<U>compose(Function<T,Future<U>> mapper)<U> Future<U>compose(Function<T,Future<U>> successMapper, Function<Throwable,Future<U>> failureMapper)booleanequals(Object o)voidfail(String failureMessage)Deprecated.voidfail(Throwable cause)Deprecated.booleanfailed()static <T> Future<T>failedFuture(String failureMessage)static <T> Future<T>failedFuture(Throwable t)<U> Future<U>flatMap(Function<T,Future<U>> mapper)static <T> Future<T>future()Deprecated.static <T> Future<T>future(Consumer<Promise<T>> handler)io.vertx.core.FuturegetDelegate()inthashCode()booleanisComplete()<U> Future<U>map(Function<T,U> mapper)<V> Future<V>map(V value)<V> Future<V>mapEmpty()static <T> Future<T>newInstance(io.vertx.core.Future arg)static <T> Future<T>newInstance(io.vertx.core.Future arg, TypeArg<T> __typeArg_T)io.smallrye.mutiny.Uni<T>onComplete()Add a handler to be notified of the result.TonCompleteAndAwait()Blocking variant ofonComplete().Future<T>onFailure(Consumer<Throwable> handler)Future<T>onSuccess(Consumer<T> handler)Future<T>otherwise(Function<Throwable,T> mapper)Future<T>otherwise(T value)Future<T>otherwiseEmpty()Future<T>recover(Function<Throwable,Future<T>> mapper)Tresult()io.smallrye.mutiny.Uni<T>setHandler()Deprecated.TsetHandlerAndAwait()Deprecated.booleansucceeded()static <T> Future<T>succeededFuture()static <T> Future<T>succeededFuture(T result)StringtoString()booleantryComplete()Deprecated.booleantryComplete(T result)Deprecated.booleantryFail(String failureMessage)Deprecated.booleantryFail(Throwable cause)Deprecated.
-
-
-
Method Detail
-
getDelegate
public io.vertx.core.Future getDelegate()
-
future
public static <T> Future<T> future(Consumer<Promise<T>> handler)
- Parameters:
handler- the handler- Returns:
- the future.
-
future
@Deprecated public static <T> Future<T> future()
Deprecated.- Returns:
- the future
-
succeededFuture
public static <T> Future<T> succeededFuture()
- Returns:
- the future
-
succeededFuture
public static <T> Future<T> succeededFuture(T result)
- Parameters:
result- the result- Returns:
- the future
-
failedFuture
public static <T> Future<T> failedFuture(Throwable t)
- Parameters:
t- the failure cause as a Throwable- Returns:
- the future
-
failedFuture
public static <T> Future<T> failedFuture(String failureMessage)
- Parameters:
failureMessage- the failure message- Returns:
- the future
-
isComplete
public boolean isComplete()
- Returns:
- true if completed, false if not
-
setHandler
@Deprecated public io.smallrye.mutiny.Uni<T> setHandler()
Deprecated.LikeonComplete().Unlike the bare Vert.x variant, this method returns a
Uni. Don't forget to subscribe on it to trigger the operation.- Returns:
- the
unifiring the result of the operation when completed, or a failure if the operation failed.
-
setHandlerAndAwait
@Deprecated public T setHandlerAndAwait()
Deprecated.Blocking variant ofsetHandler().This method waits for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).
- Returns:
- the T instance produced by the operation
-
onComplete
public io.smallrye.mutiny.Uni<T> onComplete()
Add a handler to be notified of the result.
Unlike the bare Vert.x variant, this method returns a
Uni. Don't forget to subscribe on it to trigger the operation.- Returns:
- a reference to this, so it can be used fluently
-
onCompleteAndAwait
public T onCompleteAndAwait()
Blocking variant ofonComplete().This method waits for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).
- Returns:
- a reference to this, so it can be used fluently
-
onSuccess
public Future<T> onSuccess(Consumer<T> handler)
- Parameters:
handler- the handler that will be called with the succeeded result- Returns:
- a reference to this, so it can be used fluently
-
onFailure
public Future<T> onFailure(Consumer<Throwable> handler)
- Parameters:
handler- the handler that will be called with the failed result- Returns:
- a reference to this, so it can be used fluently
-
complete
@Deprecated public void complete(T result)
Deprecated.- Parameters:
result- the result
-
complete
@Deprecated public void complete()
Deprecated.
-
fail
@Deprecated public void fail(Throwable cause)
Deprecated.- Parameters:
cause- the failure cause
-
fail
@Deprecated public void fail(String failureMessage)
Deprecated.- Parameters:
failureMessage- the failure message
-
tryComplete
@Deprecated public boolean tryComplete(T result)
Deprecated.- Parameters:
result- the result- Returns:
- false when the future is already completed
-
tryComplete
@Deprecated public boolean tryComplete()
Deprecated.- Returns:
- false when the future is already completed
-
tryFail
@Deprecated public boolean tryFail(Throwable cause)
Deprecated.- Parameters:
cause- the failure cause- Returns:
- false when the future is already completed
-
tryFail
@Deprecated public boolean tryFail(String failureMessage)
Deprecated.- Parameters:
failureMessage- the failure message- Returns:
- false when the future is already completed
-
result
public T result()
- Returns:
- the result or null if the operation failed.
-
cause
public Throwable cause()
- Returns:
- the cause or null if the operation succeeded.
-
succeeded
public boolean succeeded()
- Returns:
- true if it succeded or false otherwise
-
failed
public boolean failed()
- Returns:
- true if it failed or false otherwise
-
compose
public <U> Future<U> compose(Function<T,Future<U>> mapper)
- Parameters:
mapper- the mapper function- Returns:
- the composed future
-
compose
public <U> Future<U> compose(Function<T,Future<U>> successMapper, Function<Throwable,Future<U>> failureMapper)
- Parameters:
successMapper- the function mapping the successfailureMapper- the function mapping the failure- Returns:
- the composed future
-
map
public <U> Future<U> map(Function<T,U> mapper)
- Parameters:
mapper- the mapper function- Returns:
- the mapped future
-
map
public <V> Future<V> map(V value)
- Parameters:
value- the value that eventually completes the mapped future- Returns:
- the mapped future
-
mapEmpty
public <V> Future<V> mapEmpty()
- Returns:
- the mapped future
-
completer
@Deprecated public io.vertx.core.Handler<io.vertx.core.AsyncResult<T>> completer()
Deprecated.- Returns:
- an handler completing this future
-
recover
public Future<T> recover(Function<Throwable,Future<T>> mapper)
- Parameters:
mapper- A function which takes the exception of a failure and returns a new future.- Returns:
- A recovered future
-
otherwise
public Future<T> otherwise(Function<Throwable,T> mapper)
- Parameters:
mapper- the mapper function- Returns:
- the mapped future
-
otherwise
public Future<T> otherwise(T value)
- Parameters:
value- the value that eventually completes the mapped future- Returns:
- the mapped future
-
newInstance
public static <T> Future<T> newInstance(io.vertx.core.Future arg)
-
-