Class Future<T>

  • Direct Known Subclasses:
    CompositeFuture

    public class Future<T>
    extends Object
    Represents the result of an action that may, or may not, have occurred yet.

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

    • Field Detail

      • __typeArg_0

        public final TypeArg<T> __typeArg_0
    • Constructor Detail

      • Future

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

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

      • getDelegate

        public io.vertx.core.Future getDelegate()
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object
      • future

        public static <T> Future<T> future​(Consumer<Promise<T>> handler)
        Parameters:
        handler - the handler
        Returns:
        the future.
      • future

        @Deprecated
        public static <T> Future<T> future()
        Deprecated.
        Returns:
        the future
      • succeededFuture

        public static <T> Future<T> succeededFuture()
        Returns:
        the future
      • succeededFuture

        public static <T> Future<T> succeededFuture​(T result)
        Parameters:
        result - the result
        Returns:
        the future
      • failedFuture

        public static <T> Future<T> failedFuture​(Throwable t)
        Parameters:
        t - the failure cause as a Throwable
        Returns:
        the future
      • failedFuture

        public static <T> Future<T> failedFuture​(String failureMessage)
        Parameters:
        failureMessage - the failure message
        Returns:
        the future
      • isComplete

        public boolean isComplete()
        Returns:
        true if completed, false if not
      • setHandler

        @Deprecated
        public io.smallrye.mutiny.Uni<T> setHandler()
        Deprecated.
        Like onComplete().

        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.
      • setHandlerAndAwait

        @Deprecated
        public T setHandlerAndAwait()
        Deprecated.
        Blocking variant of setHandler().

        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
      • onComplete

        public io.smallrye.mutiny.Uni<T> onComplete()
        Add a handler to be notified of the result.

        Unlike the bare Vert.x variant, this method returns a Uni. Don't forget to subscribe on it to trigger the operation.

        Returns:
        a reference to this, so it can be used fluently
      • onCompleteAndAwait

        public T onCompleteAndAwait()
        Blocking variant of onComplete().

        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:
        a reference to this, so it can be used fluently
      • onSuccess

        public Future<T> onSuccess​(Consumer<T> handler)
        Parameters:
        handler - the handler that will be called with the succeeded result
        Returns:
        a reference to this, so it can be used fluently
      • onFailure

        public Future<T> onFailure​(Consumer<Throwable> handler)
        Parameters:
        handler - the handler that will be called with the failed result
        Returns:
        a reference to this, so it can be used fluently
      • complete

        @Deprecated
        public void complete​(T result)
        Deprecated.
        Parameters:
        result - the result
      • complete

        @Deprecated
        public void complete()
        Deprecated.
      • fail

        @Deprecated
        public void fail​(Throwable cause)
        Deprecated.
        Parameters:
        cause - the failure cause
      • fail

        @Deprecated
        public void fail​(String failureMessage)
        Deprecated.
        Parameters:
        failureMessage - the failure message
      • tryComplete

        @Deprecated
        public boolean tryComplete​(T result)
        Deprecated.
        Parameters:
        result - the result
        Returns:
        false when the future is already completed
      • tryComplete

        @Deprecated
        public boolean tryComplete()
        Deprecated.
        Returns:
        false when the future is already completed
      • tryFail

        @Deprecated
        public boolean tryFail​(Throwable cause)
        Deprecated.
        Parameters:
        cause - the failure cause
        Returns:
        false when the future is already completed
      • tryFail

        @Deprecated
        public boolean tryFail​(String failureMessage)
        Deprecated.
        Parameters:
        failureMessage - the failure message
        Returns:
        false when the future is already completed
      • result

        public T result()
        Returns:
        the result or null if the operation failed.
      • cause

        public Throwable cause()
        Returns:
        the cause or null if the operation succeeded.
      • succeeded

        public boolean succeeded()
        Returns:
        true if it succeded or false otherwise
      • failed

        public boolean failed()
        Returns:
        true if it failed or false otherwise
      • flatMap

        public <U> Future<U> flatMap​(Function<T,​Future<U>> mapper)
        Parameters:
        mapper -
        Returns:
      • compose

        public <U> Future<U> compose​(Function<T,​Future<U>> mapper)
        Parameters:
        mapper - the mapper function
        Returns:
        the composed future
      • compose

        public <U> Future<U> compose​(Function<T,​Future<U>> successMapper,
                                     Function<Throwable,​Future<U>> failureMapper)
        Parameters:
        successMapper - the function mapping the success
        failureMapper - the function mapping the failure
        Returns:
        the composed future
      • map

        public <U> Future<U> map​(Function<T,​U> mapper)
        Parameters:
        mapper - the mapper function
        Returns:
        the mapped future
      • map

        public <V> Future<V> map​(V value)
        Parameters:
        value - the value that eventually completes the mapped future
        Returns:
        the mapped future
      • mapEmpty

        public <V> Future<V> mapEmpty()
        Returns:
        the mapped future
      • completer

        @Deprecated
        public io.vertx.core.Handler<io.vertx.core.AsyncResult<T>> completer()
        Deprecated.
        Returns:
        an handler completing this future
      • recover

        public Future<T> recover​(Function<Throwable,​Future<T>> mapper)
        Parameters:
        mapper - A function which takes the exception of a failure and returns a new future.
        Returns:
        A recovered future
      • otherwise

        public Future<T> otherwise​(Function<Throwable,​T> mapper)
        Parameters:
        mapper - the mapper function
        Returns:
        the mapped future
      • otherwise

        public Future<T> otherwise​(T value)
        Parameters:
        value - the value that eventually completes the mapped future
        Returns:
        the mapped future
      • otherwiseEmpty

        public Future<T> otherwiseEmpty()
        Returns:
        the mapped future
      • newInstance

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

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