Class Promise<T>

java.lang.Object
io.vertx.mutiny.core.Promise<T>
All Implemented Interfaces:
MutinyDelegate
Direct Known Subclasses:
ApolloWSConnectionInitEvent, BaseBridgeEvent, ConnectionInitEvent

public class Promise<T> extends Object implements MutinyDelegate
Represents the writable side of an action that may, or may not, have occurred yet.

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 Handler<AsyncResult> so it can be used as a callback.

NOTE: This class has been automatically generated from the original non Mutiny-ified interface using Vert.x codegen.

  • Field Details

    • __TYPE_ARG

      public static final TypeArg<Promise> __TYPE_ARG
    • __typeArg_0

      public final TypeArg<T> __typeArg_0
  • Constructor Details

    • Promise

      public Promise(io.vertx.core.Promise delegate)
    • Promise

      public Promise(Object delegate, TypeArg<T> typeArg_0)
    • Promise

      public Promise(io.vertx.core.Promise delegate, TypeArg<T> typeArg_0)
  • Method Details

    • getDelegate

      public io.vertx.core.Promise getDelegate()
      Specified by:
      getDelegate in interface MutinyDelegate
      Returns:
      the delegate used by this Mutiny object of generated type
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • 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

      @CheckReturnValue 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 of future().

      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()
      Variant of future() that ignores the result of the operation.

      This method subscribes on the result of future(), but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation from future() but you don't need to compose it with other operations.

    • newInstance

      public static <T> Promise<T> newInstance(io.vertx.core.Promise arg)
    • newInstance

      public static <T> Promise<T> newInstance(io.vertx.core.Promise arg, TypeArg<T> __typeArg_T)