io.vertx.core

## Interface Future<T>

- All Superinterfaces:
    AsyncResult<T>
  All Known Subinterfaces:
    BridgeEvent

      public interface Future<T>
      extends AsyncResult<T>

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

  Author:
    Tim Fox

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static FutureFactory` | `factory`

  - ### Method Summary

    All Methods Static Methods Instance Methods Abstract Methods Default Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `complete()` Set a null result.
    `void` | `complete(T result)` Set the result.
    `void` | `fail(String failureMessage)` Set the failure.
    `void` | `fail(Throwable throwable)` Set the failure.
    `static <T> Future<T>` | `failedFuture(String failureMessage)` Create a failed future with the specified failure message.
    `static <T> Future<T>` | `failedFuture(Throwable t)` Create a failed future with the specified failure cause.
    `static <T> Future<T>` | `future()` Create a future that hasn't completed yet
    `boolean` | `isComplete()` Has the future completed?
    `void` | `setHandler(Handler<AsyncResult<T>> handler)` Set a handler for the result.
    `static <T> Future<T>` | `succeededFuture()` Create a succeeded future with a null result
    `static <T> Future<T>` | `succeededFuture(T result)` Created a succeeded future with the specified result.

    - ### Methods inherited from interface io.vertx.core.AsyncResult

      `cause, failed, result, succeeded`

- - ### Field Detail

    - #### factory

          static final FutureFactory factory

  - ### Method Detail

    - #### future

          static <T> Future<T> future()

      Create a future that hasn't completed yet
      Type Parameters:
        `T` - the result type
      Returns:
        the future

    - #### succeededFuture

          static <T> Future<T> succeededFuture()

      Create a succeeded future with a null result
      Type Parameters:
        `T` - the result type
      Returns:
        the future

    - #### succeededFuture

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

      Created a succeeded future with the specified result.
      Type Parameters:
        `T` - the result type
      Parameters:
        `result` - the result
      Returns:
        the future

    - #### failedFuture

          static <T> Future<T> failedFuture(Throwable t)

      Create a failed future with the specified failure cause.
      Type Parameters:
        `T` - the result type
      Parameters:
        `t` - the failure cause as a Throwable
      Returns:
        the future

    - #### failedFuture

          static <T> Future<T> failedFuture(String failureMessage)

      Create a failed future with the specified failure message.
      Type Parameters:
        `T` - the result type
      Parameters:
        `failureMessage` - the failure message
      Returns:
        the future

    - #### isComplete

          boolean isComplete()

      Has the future completed?

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

      Returns:
        true if completed, false if not

    - #### setHandler

          void setHandler(Handler<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.

      Parameters:
        `handler` - the Handler that will be called with the result

    - #### complete

          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
      Throws:
        `IllegalStateException` - when the future is already completed

    - #### complete

          void complete()

      Set a null result. Any handler will be called, if there is one, and the future will be marked as completed.
      Throws:
        `IllegalStateException` - when the future is already completed

    - #### fail

          void fail(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

    - #### fail

          void fail(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

Copyright © 2015. All Rights Reserved.