com.hazelcast.util.executor

## Class DelegatingFuture<V>

- java.lang.Object
- - com.hazelcast.util.executor.DelegatingFuture<V>

- Type Parameters:
    `V` -
  All Implemented Interfaces:
    ICompletableFuture<V>, InternalCompletableFuture<V>, Future<V>

      public class DelegatingFuture<V>
      extends Object
      implements InternalCompletableFuture<V>

  A `InternalCompletableFuture` implementation that delegates the real logic to an underlying `InternalCompletableFuture` and decorates it with additional behavior:
  1. change the returned value by setting the result
  2. always deserializing the content
  3. caching the deserialized content so that a deserialization only happens once. This should be used with care since this could lead to unexpected sharing of object instances if the same future is shared between threads.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `DelegatingFuture(InternalCompletableFuture future, SerializationService serializationService)`
    `DelegatingFuture(InternalCompletableFuture future, SerializationService serializationService, V result)` Creates a DelegatingFuture

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `andThen(ExecutionCallback<V> callback)` Registers a callback that will run after this future is completed.
    `void` | `andThen(ExecutionCallback<V> callback, Executor executor)` Registers a callback that will run with the provided executor after this future is completed.
    `boolean` | `cancel(boolean mayInterruptIfRunning)`
    `boolean` | `complete(Object value)` Completes this future.
    `V` | `get()`
    `V` | `get(long timeout, TimeUnit unit)`
    `protected ICompletableFuture` | `getFuture()`
    `boolean` | `isCancelled()`
    `boolean` | `isDone()`
    `V` | `join()` Waits for this future to complete.
    `protected void` | `setError(Throwable error)`

    - ### Methods inherited from class java.lang.Object

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

- - ### Constructor Detail

    - #### DelegatingFuture

          public DelegatingFuture(InternalCompletableFuture future,
                                  SerializationService serializationService)

    - #### DelegatingFuture

          public DelegatingFuture(InternalCompletableFuture future,
                                  SerializationService serializationService,
                                  V result)

      Creates a DelegatingFuture
      Parameters:
        `future` - the underlying future to delegate to.
        `serializationService` - the `SerializationService`
        `result` - the resuling value to be used when the underlying future completes. So no matter the return value of that future, the result will be returned by the DelegatingFuture. A null value means that the value of the underlying future should be used.

  - ### Method Detail

    - #### get

          public final V get()
                      throws InterruptedException,
                             ExecutionException

      Specified by:
        `get` in interface `Future<V>`
      Throws:
        `InterruptedException`
        `ExecutionException`

    - #### get

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

      Specified by:
        `get` in interface `Future<V>`
      Throws:
        `InterruptedException`
        `ExecutionException`
        `TimeoutException`

    - #### cancel

          public boolean cancel(boolean mayInterruptIfRunning)

      Specified by:
        `cancel` in interface `Future<V>`

    - #### isCancelled

          public boolean isCancelled()

      Specified by:
        `isCancelled` in interface `Future<V>`

    - #### isDone

          public final boolean isDone()

      Specified by:
        `isDone` in interface `Future<V>`

    - #### complete

          public boolean complete(Object value)

      Description copied from interface: `InternalCompletableFuture`
      Completes this future.
      Specified by:
        `complete` in interface `InternalCompletableFuture<V>`
      Parameters:
        `value` - the value to complete this future with.
      Returns:
        `true` if this invocation caused this InternalCompletableFuture to complete, else `false`

    - #### setError

          protected void setError(Throwable error)

    - #### getFuture

          protected ICompletableFuture getFuture()

    - #### join

          public V join()

      Description copied from interface: `InternalCompletableFuture`
      Waits for this future to complete.
      Specified by:
        `join` in interface `InternalCompletableFuture<V>`
      Returns:
        the result.

    - #### andThen

          public void andThen(ExecutionCallback<V> callback)

      Description copied from interface: `ICompletableFuture`
      Registers a callback that will run after this future is completed. If this future is already completed, it runs immediately.

      Please note that there is no ordering guarantee for running multiple callbacks. It is also not guaranteed that the callback will run within the same thread that completes the future.

      Specified by:
        `andThen` in interface `ICompletableFuture<V>`
      Parameters:
        `callback` - the callback to execute

    - #### andThen

          public void andThen(ExecutionCallback<V> callback,
                              Executor executor)

      Description copied from interface: `ICompletableFuture`
      Registers a callback that will run with the provided executor after this future is completed. If this future is already completed, it runs immediately. The callback is called using the given `executor`. Please note that there is no ordering guarantee for executing multiple callbacks.
      Specified by:
        `andThen` in interface `ICompletableFuture<V>`
      Parameters:
        `callback` - the callback to execute
        `executor` - the executor in which the callback will be run

Copyright © 2019. All rights reserved.