Package org.xnio

# Class FinishedIoFuture<T>

java.lang.Object
org.xnio.FinishedIoFuture<T>

Type Parameters:
  `T` - the type of result that this operation produces

All Implemented Interfaces:
  `Cancellable`, `IoFuture<T>`

public class FinishedIoFuture<T> extends Object implements IoFuture<T>
An implementation of `IoFuture` that represents an immediately-successful operation.

## Nested Class Summary

## Nested classes/interfaces inherited from interface org.xnio.IoFuture

`IoFuture.HandlingNotifier<T,A>, IoFuture.Notifier<T,A>, IoFuture.Status`

## Constructor Summary

Constructors
Constructor
Description
`FinishedIoFuture(T result)`
Create an instance.

## Method Summary

Modifier and Type
Method
Description
`<A> IoFuture<T>`
`addNotifier(IoFuture.Notifier<? super T,A> notifier, A attachment)`
Add a notifier to be called when this operation is complete.
`IoFuture.Status`
`await()`
Wait for the operation to complete.
`IoFuture.Status`
`await(long time, TimeUnit timeUnit)`
Wait for the operation to complete, with a timeout.
`IoFuture.Status`
`awaitInterruptibly()`
Wait for the operation to complete.
`IoFuture.Status`
`awaitInterruptibly(long time, TimeUnit timeUnit)`
Wait for the operation to complete, with a timeout.
`IoFuture<T>`
`cancel()`
Cancel the operation.
`T`
`get()`
Get the result of the operation.
`IOException`
`getException()`
Get the failure reason.
`T`
`getInterruptibly()`
Get the result of the operation.
`IoFuture.Status`
`getStatus()`
Get the current status.

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

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

## Constructor Details

### FinishedIoFuture

public FinishedIoFuture(T result)
Create an instance.

Parameters:
  `result` - the operation result

## Method Details

### cancel

public IoFuture<T> cancel()
Cancel the operation. Since this operation is always complete, this is a no-op.

Specified by:
  `cancel` in interface `Cancellable`
Specified by:
  `cancel` in interface `IoFuture<T>`
Returns:
  this instance

### getStatus

public IoFuture.Status getStatus()
Description copied from interface: `IoFuture`
Get the current status.

Specified by:
  `getStatus` in interface `IoFuture<T>`
Returns:
  the current status

### await

public IoFuture.Status await()
Description copied from interface: `IoFuture`
Wait for the operation to complete. This method will block until the status changes from `IoFuture.Status.WAITING`.

Specified by:
  `await` in interface `IoFuture<T>`
Returns:
  the new status

### await

public IoFuture.Status await(long time, TimeUnit timeUnit)
Description copied from interface: `IoFuture`
Wait for the operation to complete, with a timeout. This method will block until the status changes from `IoFuture.Status.WAITING`, or the given time elapses. If the time elapses before the operation is complete, `IoFuture.Status.WAITING` is returned.

Specified by:
  `await` in interface `IoFuture<T>`
Parameters:
  `time` - the amount of time to wait
  `timeUnit` - the time unit
Returns:
  the new status, or `IoFuture.Status.WAITING` if the timeout expired

### awaitInterruptibly

public IoFuture.Status awaitInterruptibly() throws InterruptedException
Description copied from interface: `IoFuture`
Wait for the operation to complete. This method will block until the status changes from `IoFuture.Status.WAITING`, or the current thread is interrupted.

Specified by:
  `awaitInterruptibly` in interface `IoFuture<T>`
Returns:
  the new status
Throws:
  `InterruptedException` - if the operation is interrupted

### awaitInterruptibly

public IoFuture.Status awaitInterruptibly(long time, TimeUnit timeUnit) throws InterruptedException
Description copied from interface: `IoFuture`
Wait for the operation to complete, with a timeout. This method will block until the status changes from `IoFuture.Status.WAITING`, the given time elapses, or the current thread is interrupted. If the time elapses before the operation is complete, `IoFuture.Status.WAITING` is returned.

Specified by:
  `awaitInterruptibly` in interface `IoFuture<T>`
Parameters:
  `time` - the amount of time to wait
  `timeUnit` - the time unit
Returns:
  the new status, or `IoFuture.Status.WAITING` if the timeout expired
Throws:
  `InterruptedException` - if the operation is interrupted

### get

public T get() throws IOException, CancellationException
Description copied from interface: `IoFuture`
Get the result of the operation. If the operation is not complete, blocks until the operation completes. If the operation fails, or has already failed at the time this method is called, the failure reason is thrown.

Specified by:
  `get` in interface `IoFuture<T>`
Returns:
  the result of the operation
Throws:
  `IOException` - if the operation failed
  `CancellationException` - if the operation was cancelled

### getInterruptibly

public T getInterruptibly() throws IOException, InterruptedException, CancellationException
Description copied from interface: `IoFuture`
Get the result of the operation. If the operation is not complete, blocks until the operation completes. If the operation fails, or has already failed at the time this method is called, the failure reason is thrown. If the current thread is interrupted while waiting, an exception is thrown.

Specified by:
  `getInterruptibly` in interface `IoFuture<T>`
Returns:
  the result of the operation
Throws:
  `IOException` - if the operation failed
  `InterruptedException` - if the operation is interrupted
  `CancellationException` - if the operation was cancelled

### getException

public IOException getException() throws IllegalStateException
Description copied from interface: `IoFuture`
Get the failure reason.

Specified by:
  `getException` in interface `IoFuture<T>`
Returns:
  the failure reason
Throws:
  `IllegalStateException` - if the operation did not fail

### addNotifier

public <A> IoFuture<T> addNotifier(IoFuture.Notifier<? super T,A> notifier, A attachment)
Description copied from interface: `IoFuture`
Add a notifier to be called when this operation is complete. If the operation is already complete, the notifier is called immediately, possibly in the caller's thread. The given attachment is provided to the notifier.

Specified by:
  `addNotifier` in interface `IoFuture<T>`
Type Parameters:
  `A` - the attachment type
Parameters:
  `notifier` - the notifier to be called
  `attachment` - the attachment to pass in to the notifier
Returns:
  this instance