org.springframework.util.concurrent

## 类 CompletableToListenableFutureAdapter<T>

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

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

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

  Adapts a `CompletableFuture` or `CompletionStage` into a Spring `ListenableFuture`.
  从以下版本开始:
    4.2
  作者:
    Sebastien Deleuze, Juergen Hoeller

- - ### 构造器概要

    构造器
    构造器和说明
    `CompletableToListenableFutureAdapter(CompletableFuture<T> completableFuture)` Create a new adapter for the given `CompletableFuture`.
    `CompletableToListenableFutureAdapter(CompletionStage<T> completionStage)` Create a new adapter for the given `CompletionStage`.

  - ### 方法概要

    所有方法 实例方法 具体方法
    限定符和类型 | 方法和说明
    --- | ---
    `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()`
    `T` | `get(long timeout, TimeUnit unit)`
    `boolean` | `isCancelled()`
    `boolean` | `isDone()`

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

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

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

    - #### CompletableToListenableFutureAdapter

          public CompletableToListenableFutureAdapter(CompletionStage<T> completionStage)

      Create a new adapter for the given `CompletionStage`.
      从以下版本开始:
        4.3.7

    - #### CompletableToListenableFutureAdapter

          public CompletableToListenableFutureAdapter(CompletableFuture<T> completableFuture)

      Create a new adapter for the given `CompletableFuture`.

  - ### 方法详细资料

    - #### 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

      指定者:
        `get` 在接口中 `Future<T>`
      抛出:
        `InterruptedException`
        `ExecutionException`

    - #### get

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

      指定者:
        `get` 在接口中 `Future<T>`
      抛出:
        `InterruptedException`
        `ExecutionException`
        `TimeoutException`