Class Promise<T>
- All Implemented Interfaces:
MutinyDelegate
- Direct Known Subclasses:
ConnectionInitEvent
The future() method returns the Future associated with a promise, the future
can be used for getting notified of the promise completion and retrieve its value.
A promise extends Completable so it can be used with Future.onComplete(Completable).
NOTE: This class has been automatically generated from the original non Mutiny-ified interface.
- Author:
- Julien Viet
- See Also:
-
Promise
-
Field Summary
FieldsModifier and TypeFieldDescription -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidcomplete()Callscomplete(null)voidSet the result.voidbooleanvoidvoidio.smallrye.mutiny.Uni<T>future()Unlike the bare Vert.x variant, this method returns aUni.Unlike the bare Vert.x variant, this method returns aPromise.Unlike the bare Vert.x variant, this method ignores thePromiseresult or any failure.io.vertx.core.Promise<T>Get the delegate instance.voidSucceed or fail this promise with theAsyncResultevent.inthashCode()static <T> Promise<T>newInstance(io.vertx.core.Promise<T> delegate) Creates a new instance of thePromise.static <T> Promise<T>newInstance(io.vertx.core.Promise<T> delegate, TypeArg<T> typeArg_0) Creates a new instance of thePromise.static <T> Promise<T>promise()Create a promise that hasn't completed yetvoidsucceed()voidtoString()booleanCallstryComplete(null).booleantryComplete(T result) Likecomplete(Object)but returnsfalsewhen the promise is already completed instead of throwing anIllegalStateException, it returnstrueotherwise.booleanCallsfail(Throwable)with themessage.booleanLikefail(Throwable)but returnsfalsewhen the promise is already completed instead of throwing anIllegalStateException, it returnstrueotherwise.
-
Field Details
-
__TYPE_ARG
-
__typeArg_0
-
-
Constructor Details
-
Promise
Create a new instance ofPromisedelegating to the given (non-null) instance ofPromise. -
Promise
-
Promise
-
-
Method Details
-
getDelegate
Get the delegate instance.This method returns the instance on which this shim is delegating the calls. And so, give you access to the bare API.
- Specified by:
getDelegatein interfaceMutinyDelegate- Returns:
- the delegate instance
-
future
Unlike the bare Vert.x variant, this method returns a
Uni. The uni emits the result of the operation as item. If the operation fails, the uni emits the failure.Don't forget to subscribe on it to trigger the operation.
- Returns:
- A
Unirepresenting the asynchronous result of this operation. - See Also:
-
Promise.future()
-
futureAndAwait
Unlike the bare Vert.x variant, this method returns a
Promise. This method awaits indefinitely 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 aRuntimeException).- Returns:
- The operation result
- See Also:
-
Promise.future()
-
futureAndForget
Unlike the bare Vert.x variant, this method ignores the
Promiseresult or any failure.- Returns:
- The current instance to chain operations if needed.
- See Also:
-
Promise.future()
-
promise
Create a promise that hasn't completed yet- Type Parameters:
T- the result type- Returns:
- the promise
-
handle
Succeed or fail this promise with theAsyncResultevent.- Parameters:
asyncResult- the async result to handle
-
complete
-
complete
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- Throws:
when- the promise is already completed
-
complete
public void complete()Callscomplete(null)- Throws:
when- the promise is already completed
-
succeed
-
succeed
public void succeed() -
fail
-
fail
-
tryComplete
Likecomplete(Object)but returnsfalsewhen the promise is already completed instead of throwing anIllegalStateException, it returnstrueotherwise.- Parameters:
result- the result- Returns:
falsewhen the future is already completed
-
tryComplete
public boolean tryComplete()CallstryComplete(null).- Returns:
falsewhen the future is already completed
-
tryFail
Likefail(Throwable)but returnsfalsewhen the promise is already completed instead of throwing anIllegalStateException, it returnstrueotherwise.- Parameters:
cause- the failure cause- Returns:
falsewhen the future is already completed
-
tryFail
Callsfail(Throwable)with themessage.- Parameters:
message- the failure message- Returns:
- false when the future is already completed
-
newInstance
Creates a new instance of thePromise. -
newInstance
Creates a new instance of thePromise. -
hashCode
public int hashCode() -
equals
-
toString
-