org.springframework.util.concurrent

## 类 SettableListenableFuture<T>

- java.lang.Object
- - org.springframework.util.concurrent.SettableListenableFuture<T>

- 所有已实现的接口:
    Future<T>, ListenableFuture<T>

      public class SettableListenableFuture<T>
      extends Object
      implements ListenableFuture<T>

  A `ListenableFuture` whose value can be set via `set(Object)` or `setException(Throwable)`. It may also get cancelled.

  Inspired by `com.google.common.util.concurrent.SettableFuture`.

  从以下版本开始:
    4.1
  作者:
    Mattias Severson, Rossen Stoyanchev, Juergen Hoeller

- - ### 构造器概要

    构造器
    构造器和说明
    `SettableListenableFuture()`

  - ### 方法概要

    所有方法 实例方法 具体方法
    限定符和类型 | 方法和说明
    --- | ---
    `void` | `addCallback(ListenableFutureCallback<? super T> callback)` Register the given `ListenableFutureCallback`.
    `void` | `addCallback(SuccessCallback<? super T> successCallback, FailureCallback failureCallback)` Java 8 lambda-friendly alternative with success and failure callbacks.
    `boolean` | `cancel(boolean mayInterruptIfRunning)`
    `CompletableFuture<T>` | `completable()` Expose this `ListenableFuture` as a JDK `CompletableFuture`.
    `T` | `get()` Retrieve the value.
    `T` | `get(long timeout, TimeUnit unit)` Retrieve the value.
    `protected void` | `interruptTask()` Subclasses can override this method to implement interruption of the future's computation.
    `boolean` | `isCancelled()`
    `boolean` | `isDone()`
    `boolean` | `set(T value)` Set the value of this future.
    `boolean` | `setException(Throwable exception)` Set the exception of this future.

    - ### 从类继承的方法 java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### 构造器详细资料

    - #### SettableListenableFuture

          public SettableListenableFuture()

  - ### 方法详细资料

    - #### set

          public boolean set(@Nullable
                             T value)

      Set the value of this future. This method will return `true` if the value was set successfully, or `false` if the future has already been set or cancelled.
      参数:
        `value` - the value that will be set
      返回:
        `true` if the value was successfully set, else `false`

    - #### setException

          public boolean setException(Throwable exception)

      Set the exception of this future. This method will return `true` if the exception was set successfully, or `false` if the future has already been set or cancelled.
      参数:
        `exception` - the value that will be set
      返回:
        `true` if the exception was successfully set, else `false`

    - #### addCallback

          public void addCallback(ListenableFutureCallback<? super T> callback)

      从接口复制的说明: `ListenableFuture`
      Register the given `ListenableFutureCallback`.
      指定者:
        `addCallback` 在接口中 `ListenableFuture<T>`
      参数:
        `callback` - the callback to register

    - #### addCallback

          public void addCallback(SuccessCallback<? super T> successCallback,
                                  FailureCallback failureCallback)

      从接口复制的说明: `ListenableFuture`
      Java 8 lambda-friendly alternative with success and failure callbacks.
      指定者:
        `addCallback` 在接口中 `ListenableFuture<T>`
      参数:
        `successCallback` - the success callback
        `failureCallback` - the failure callback

    - #### completable

          public CompletableFuture<T> completable()

      从接口复制的说明: `ListenableFuture`
      Expose this `ListenableFuture` as a JDK `CompletableFuture`.
      指定者:
        `completable` 在接口中 `ListenableFuture<T>`

    - #### cancel

          public boolean cancel(boolean mayInterruptIfRunning)

      指定者:
        `cancel` 在接口中 `Future<T>`

    - #### isCancelled

          public boolean isCancelled()

      指定者:
        `isCancelled` 在接口中 `Future<T>`

    - #### isDone

          public boolean isDone()

      指定者:
        `isDone` 在接口中 `Future<T>`

    - #### get

          public T get()
                throws InterruptedException,
                       ExecutionException

      Retrieve the value.

      This method returns the value if it has been set via `set(Object)`, throws an `ExecutionException` if an exception has been set via `setException(Throwable)`, or throws a `CancellationException` if the future has been cancelled.

      指定者:
        `get` 在接口中 `Future<T>`
      返回:
        the value associated with this future
      抛出:
        `InterruptedException`
        `ExecutionException`

    - #### get

          public T get(long timeout,
                       TimeUnit unit)
                throws InterruptedException,
                       ExecutionException,
                       TimeoutException

      Retrieve the value.

      This method returns the value if it has been set via `set(Object)`, throws an `ExecutionException` if an exception has been set via `setException(Throwable)`, or throws a `CancellationException` if the future has been cancelled.

      指定者:
        `get` 在接口中 `Future<T>`
      参数:
        `timeout` - the maximum time to wait
        `unit` - the unit of the timeout argument
      返回:
        the value associated with this future
      抛出:
        `InterruptedException`
        `ExecutionException`
        `TimeoutException`

    - #### interruptTask

          protected void interruptTask()

      Subclasses can override this method to implement interruption of the future's computation. The method is invoked automatically by a successful call to `cancel(true)`.

      The default implementation is empty.