Package: io.vertx.groovy.core

## [Groovy] Class Future<T>

- io.vertx.groovy.core.Future

- Represents the result of an action that may, or may not, have occurred yet.

- - ### Constructor Summary

    Constructors
    Constructor and description
    `Future (java.lang.Object delegate)`

  - ### Methods Summary

    Methods
    Type | Name and description
    --- | ---
    `java.lang.Throwable` | `cause()` A Throwable describing failure.
    `void` | `complete(T result)` Set the result.
    `void` | `complete()` Set a null result.
    `io.vertx.core.Handler<io.vertx.core.AsyncResult<T>>` | `completer()` @return Returns: an handler completing this future
    `Future<U>` | `compose(io.vertx.core.Handler<T> handler, Future<U> composed)` Compose this future with a provided `next` future.
    `Future<U>` | `compose(java.util.function.Function<T, Future<U>> mapper)` Compose this future with a `mapper` function.
    `void` | `fail(java.lang.Throwable throwable)` Set the failure.
    `void` | `fail(java.lang.String failureMessage)` Set the failure.
    `boolean` | `failed()` Did it fail?
    `static Future<T>` | `failedFuture(java.lang.String failureMessage)` Create a failed future with the specified failure message.
    `static Future<T>` | `future()` Create a future that hasn't completed yet
    `java.lang.Object` | `getDelegate()`
    `boolean` | `isComplete()` Has the future completed?
    `Future<U>` | `map(java.util.function.Function<T, U> mapper)` Apply a `mapper` function on this future.
    `Future<V>` | `map(V value)` Map the result of a future to a specific `value`.
    `T` | `result()` The result of the operation.
    `Future<T>` | `setHandler(io.vertx.core.Handler<io.vertx.core.AsyncResult<T>> handler)` Set a handler for the result.
    `boolean` | `succeeded()` Did it succeed?
    `static Future<T>` | `succeededFuture()` Create a succeeded future with a null result
    `static Future<T>` | `succeededFuture(T result)` Created a succeeded future with the specified result.

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `class java.lang.Object` | `java.lang.Object#wait(long, int), java.lang.Object#wait(long), java.lang.Object#wait(), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll()`

- - ### Constructor Detail

    - #### Future(java.lang.Object delegate)

  - ### Method Detail

    - #### java.lang.Throwable cause()

      A Throwable describing failure. This will be null if the operation succeeded.

      Returns:
        the cause or null if the operation succeeded.

    - #### void complete(T result)

      Set the result. Any handler will be called, if there is one, and the future will be marked as completed.

      Parameters:
        `result` - the result

    - #### void complete()

      Set a null result. Any handler will be called, if there is one, and the future will be marked as completed.

    - #### io.vertx.core.Handler<io.vertx.core.AsyncResult<T>> completer()

      Returns:
        an handler completing this future

    - #### Future<U> compose(io.vertx.core.Handler<T> handler, Future<U> composed)

      Compose this future with a provided `next` future.

      When this future succeeds, the `handler` will be called with the completed value, this handler should complete the next future.

      If the `handler` throws an exception, the returned future will be failed with this exception.

      When this future fails, the failure will be propagated to the `next` future and the `handler` will not be called.

      Returns:
        the composed future, used for chaining
      Parameters:
        `handler` - the handler
        `composed` - the composed future

    - #### Future<U> compose(java.util.function.Function<T, Future<U>> mapper)

      Compose this future with a `mapper` function.

      When this future succeeds, the `mapper` will be called with the completed value and this mapper returns a future. This returned future completion will trigger the future returned by this method call.

      If the `mapper` throws an exception, the returned future will be failed with this exception.

      When this future fails, the failure will be propagated to the returned future and the `mapper` will not be called.

      Returns:
        the composed future
      Parameters:
        `mapper` - the mapper function

    - #### void fail(java.lang.Throwable throwable)

      Set the failure. Any handler will be called, if there is one, and the future will be marked as completed.

      Parameters:
        `throwable` - the failure cause

    - #### void fail(java.lang.String failureMessage)

      Set the failure. Any handler will be called, if there is one, and the future will be marked as completed.

      Parameters:
        `failureMessage` - the failure message

    - #### boolean failed()

      Did it fail?

      Returns:
        true if it failed or false otherwise

    - #### static Future<T> failedFuture(java.lang.String failureMessage)

      Create a failed future with the specified failure message.

      Returns:
        the future
      Parameters:
        `failureMessage` - the failure message

    - #### static Future<T> future()

      Create a future that hasn't completed yet

      Returns:
        the future

    - #### java.lang.Object getDelegate()

    - #### boolean isComplete()

      Has the future completed?

      It's completed if it's either succeeded or failed.

      Returns:
        true if completed, false if not

    - #### Future<U> map(java.util.function.Function<T, U> mapper)

      Apply a `mapper` function on this future.

      When this future succeeds, the `mapper` will be called with the completed value and this mapper returns a value. This value will complete the future returned by this method call.

      If the `mapper` throws an exception, the returned future will be failed with this exception.

      When this future fails, the failure will be propagated to the returned future and the `mapper` will not be called.

      Returns:
        the mapped future
      Parameters:
        `mapper` - the mapper function

    - #### Future<V> map(V value)

      Map the result of a future to a specific `value`.

      When this future succeeds, this `value` will complete the future returned by this method call.

      When this future fails, the failure will be propagated to the returned future.

      Returns:
        the mapped future
      Parameters:
        `value` - the value that eventually completes the mapped future

    - #### T result()

      The result of the operation. This will be null if the operation failed.

      Returns:
        the result or null if the operation failed.

    - #### Future<T> setHandler(io.vertx.core.Handler<io.vertx.core.AsyncResult<T>> handler)

      Set a handler for the result.

      If the future has already been completed it will be called immediately. Otherwise it will be called when the future is completed.

      Returns:
        a reference to this, so it can be used fluently
      Parameters:
        `handler` - the Handler that will be called with the result

    - #### boolean succeeded()

      Did it succeed?

      Returns:
        true if it succeded or false otherwise

    - #### static Future<T> succeededFuture()

      Create a succeeded future with a null result

      Returns:
        the future

    - #### static Future<T> succeededFuture(T result)

      Created a succeeded future with the specified result.

      Returns:
        the future
      Parameters:
        `result` - the result