Class 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 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> 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.

    • Constructor Detail

      • Promise

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

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

      • getDelegate

        public io.vertx.core.Promise getDelegate()
      • 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)