Package io.vertx.mutiny.core
Class Promise<T>
- java.lang.Object
-
- io.vertx.mutiny.core.Promise<T>
-
- Direct Known Subclasses:
ApolloWSConnectionInitEvent
,BaseBridgeEvent
public class Promise<T> extends Object
Represents the writable side of an action that may, or may not, have occurred yet.The
future()
method returns theFuture
associated with a promise, the future can be used for getting notified of the promise completion and retrieve its value.A promise extends
NOTE: This class has been automatically generated from theHandler
so it can be used as a callback.> original
non Mutiny-ified interface using Vert.x codegen.
-
-
Field Summary
Fields Modifier and Type Field Description static TypeArg<Promise>
__TYPE_ARG
TypeArg<T>
__typeArg_0
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
complete()
void
complete(T result)
boolean
equals(Object o)
void
fail(String message)
void
fail(Throwable cause)
io.smallrye.mutiny.Uni<T>
future()
Unlike the bare Vert.x variant, this method returns aUni
.T
futureAndAwait()
Blocking variant offuture()
.void
futureAndForget()
Variant offuture()
that ignores the result of the operation.io.vertx.core.Promise
getDelegate()
int
hashCode()
static <T> Promise<T>
newInstance(io.vertx.core.Promise arg)
static <T> Promise<T>
newInstance(io.vertx.core.Promise arg, TypeArg<T> __typeArg_T)
static <T> Promise<T>
promise()
String
toString()
boolean
tryComplete()
boolean
tryComplete(T result)
boolean
tryFail(String message)
boolean
tryFail(Throwable cause)
-
-
-
Method Detail
-
getDelegate
public io.vertx.core.Promise getDelegate()
-
promise
public static <T> Promise<T> promise()
- Returns:
- the promise
-
complete
public void complete(T result)
- Parameters:
result
- the result
-
complete
public void complete()
-
fail
public void fail(Throwable cause)
- Parameters:
cause
- the failure cause
-
fail
public void fail(String message)
- Parameters:
message
- the failure message
-
tryComplete
public boolean tryComplete(T result)
- Parameters:
result
- the result- Returns:
false
when the future is already completed
-
tryComplete
public boolean tryComplete()
- Returns:
false
when the future is already completed
-
tryFail
public boolean tryFail(Throwable cause)
- Parameters:
cause
- the failure cause- Returns:
false
when the future is already completed
-
tryFail
public boolean tryFail(String message)
- Parameters:
message
- the failure message- Returns:
- false when the future is already completed
-
future
public io.smallrye.mutiny.Uni<T> future()
Unlike the bare Vert.x variant, this method returns a
Uni
. Don't forget to subscribe on it to trigger the operation.- Returns:
- the
uni
firing the result of the operation when completed, or a failure if the operation failed.
-
futureAndAwait
public T futureAndAwait()
Blocking variant offuture()
.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.
-
futureAndForget
public void futureAndForget()
-
newInstance
public static <T> Promise<T> newInstance(io.vertx.core.Promise arg)
-
-