Package io.vertx.reactivex.core
Class Promise<T>
- java.lang.Object
-
- io.vertx.reactivex.core.Promise<T>
-
- Direct Known Subclasses:
ApolloWSConnectionInitEvent
,BaseBridgeEvent
,ConnectionInitEvent
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 RX-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()
Callscomplete(null)
void
complete(T result)
Set the result.boolean
equals(Object o)
void
fail(String message)
Callsfail(java.lang.Throwable)
with themessage
.void
fail(Throwable cause)
Set the failure.Future<T>
future()
Promise
getDelegate()
int
hashCode()
static <T> Promise<T>
newInstance(Promise arg)
static <T> Promise<T>
newInstance(Promise arg, TypeArg<T> __typeArg_T)
static <T> Promise<T>
promise()
Create a promise that hasn't completed yetString
toString()
boolean
tryComplete()
CallstryComplete(null)
.boolean
tryComplete(T result)
Likecomplete(T)
but returnsfalse
when the promise is already completed instead of throwing anIllegalStateException
, it returnstrue
otherwise.boolean
tryFail(String message)
Callsfail(java.lang.Throwable)
with themessage
.boolean
tryFail(Throwable cause)
Likefail(java.lang.Throwable)
but returnsfalse
when the promise is already completed instead of throwing anIllegalStateException
, it returnstrue
otherwise.
-
-
-
Method Detail
-
getDelegate
public Promise getDelegate()
-
promise
public static <T> Promise<T> promise()
Create a promise that hasn't completed yet- Returns:
- the promise
-
complete
public void complete(T result)
Set the result. Any handler will be called, if there is one, and the promise will be marked as completed. Any handler set on the associated promise will be called.- Parameters:
result
- the result
-
complete
public void complete()
Callscomplete(null)
-
fail
public void fail(Throwable cause)
Set the failure. Any handler will be called, if there is one, and the future will be marked as completed.- Parameters:
cause
- the failure cause
-
fail
public void fail(String message)
Callsfail(java.lang.Throwable)
with themessage
.- Parameters:
message
- the failure message
-
tryComplete
public boolean tryComplete(T result)
Likecomplete(T)
but returnsfalse
when the promise is already completed instead of throwing anIllegalStateException
, it returnstrue
otherwise.- Parameters:
result
- the result- Returns:
false
when the future is already completed
-
tryComplete
public boolean tryComplete()
CallstryComplete(null)
.- Returns:
false
when the future is already completed
-
tryFail
public boolean tryFail(Throwable cause)
Likefail(java.lang.Throwable)
but returnsfalse
when the promise is already completed instead of throwing anIllegalStateException
, it returnstrue
otherwise.- Parameters:
cause
- the failure cause- Returns:
false
when the future is already completed
-
tryFail
public boolean tryFail(String message)
Callsfail(java.lang.Throwable)
with themessage
.- Parameters:
message
- the failure message- Returns:
- false when the future is already completed
-
future
public Future<T> future()
- Returns:
- the
Future
associated with this promise, it can be used to be aware of the promise completion
-
-