org.apache.ignite.internal.util.lang

## Class GridPlainFutureAdapter<R>

- java.lang.Object
- - org.apache.ignite.internal.util.lang.GridPlainFutureAdapter<R>

All Implemented Interfaces:
  GridPlainFuture<R>

    public class GridPlainFutureAdapter<R>
    extends Object
    implements GridPlainFuture<R>

Plain future adapter.

### Constructor Summary

Constructors
Constructor and Description
`GridPlainFutureAdapter()` Creates not-finished future without any result.
`GridPlainFutureAdapter(R res)` Creates succeeded finished future with given result.
`GridPlainFutureAdapter(Throwable err)` Creates failed finished future with given error.

### Method Summary

Methods
`<T> GridPlainFutureAdapter<T>` `chain(GridPlainClosure<GridPlainFuture<R>,T> cb)` Creates future's chain and completes chained future, when this future finishes.
`R` `get()` Synchronously waits for completion and returns result.
`R` `get(long timeout, TimeUnit unit)` Synchronously waits for completion and returns result.
`boolean` `isDone()` Checks if future is done.
`void` `listenAsync(GridPlainInClosure<GridPlainFuture<R>>... lsnrs)` Register new listeners for notification when future completes.
`void` `onDone(R res)` Callback to notify that future is finished successfully.
`void` `onDone(Throwable err)` Callback to notify that future is finished with error.
`void` `stopListenAsync(GridPlainInClosure<GridPlainFuture<R>>... lsnrs)` Removes listeners registered before.

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

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

### Constructor Detail

#### GridPlainFutureAdapter

    public GridPlainFutureAdapter()

Creates not-finished future without any result.

#### GridPlainFutureAdapter

    public GridPlainFutureAdapter(R res)

Creates succeeded finished future with given result.

Parameters:
  `res` - Future result.

#### GridPlainFutureAdapter

    public GridPlainFutureAdapter(Throwable err)

Creates failed finished future with given error.

Parameters:
  `err` - Future error.

### Method Detail

#### get

    public R get()
          throws IgniteCheckedException

Synchronously waits for completion and returns result.

Specified by:
  `get` in interface `GridPlainFuture<R>`
Returns:
  Completed future result.
Throws:
  `IgniteCheckedException` - In case of error.

#### get

    public R get(long timeout,
        TimeUnit unit)
          throws IgniteCheckedException

Synchronously waits for completion and returns result.

Specified by:
  `get` in interface `GridPlainFuture<R>`
Parameters:
  `timeout` - Timeout interval to wait future completes.
  `unit` - Timeout interval unit to wait future completes.
Returns:
  Completed future result.
Throws:
  `IgniteCheckedException` - In case of error.
  `IgniteFutureTimeoutCheckedException` - If timed out before future finishes.

#### isDone

    public boolean isDone()

Checks if future is done.

Specified by:
  `isDone` in interface `GridPlainFuture<R>`
Returns:
  Whether future is done.

#### onDone

    public void onDone(R res)

Callback to notify that future is finished successfully.

Parameters:
  `res` - Result (can be `null`).

#### onDone

    public void onDone(Throwable err)

Callback to notify that future is finished with error.

Parameters:
  `err` - Error (can't be `null`).

#### listenAsync

    public void listenAsync(GridPlainInClosure<GridPlainFuture<R>>... lsnrs)

Register new listeners for notification when future completes. Note that current implementations are calling listeners in the completing thread.

Specified by:
  `listenAsync` in interface `GridPlainFuture<R>`
Parameters:
  `lsnrs` - Listeners to be registered.

#### stopListenAsync

    public void stopListenAsync(GridPlainInClosure<GridPlainFuture<R>>... lsnrs)

Removes listeners registered before.

Specified by:
  `stopListenAsync` in interface `GridPlainFuture<R>`
Parameters:
  `lsnrs` - Listeners to be removed.

#### chain

    public <T> GridPlainFutureAdapter<T> chain(GridPlainClosure<GridPlainFuture<R>,T> cb)

Creates future's chain and completes chained future, when this future finishes.

Specified by:
  `chain` in interface `GridPlainFuture<R>`
Type Parameters:
  `T` - New future format to convert this finished future to.
Parameters:
  `cb` - Future callback to convert this future result into expected format.
Returns:
  Chained future with new format.

2015 Copyright © Apache Software Foundation

Follow @ApacheIgnite

Ignite Fabric | : ver. 1.0.0-RC1
Release Date | : February 17 2015