mondrian.util
Class CompletedFuture<V>

java.lang.Object
  extended by mondrian.util.CompletedFuture<V>
All Implemented Interfaces:
Future<V>

public class CompletedFuture<V>
extends Object
implements Future<V>

Implementation of Future that has already completed.


Constructor Summary
CompletedFuture(V value, ExecutionException exception)
          Creates a CompletedFuture.
 
Method Summary
 boolean cancel(boolean mayInterruptIfRunning)
           
static
<T> CompletedFuture<T>
fail(Throwable e)
          Creates a completed future indicating failure.
 V get()
           
 V get(long timeout, TimeUnit unit)
           
 boolean isCancelled()
           
 boolean isDone()
           
static
<T> CompletedFuture<T>
success(T t)
          Creates a completed future indicating success.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CompletedFuture

public CompletedFuture(V value,
                       ExecutionException exception)
Creates a CompletedFuture.

If throwable is not null, the computation is deemed to have failed. The exception will be thrown (wrapped in a ExecutionException) when get() or get(long, java.util.concurrent.TimeUnit) are invoked.

If exception is null, the computation is deemed to have succeeded. In this case, a null value in value just means that the computation yielded a null result.

Parameters:
value - Value (may be null)
exception - Exception that occurred while computing result
Method Detail

success

public static <T> CompletedFuture<T> success(T t)
Creates a completed future indicating success.

Parameters:
t - Result of computation
Returns:
Completed future that will yield the result

fail

public static <T> CompletedFuture<T> fail(Throwable e)
Creates a completed future indicating failure.

Parameters:
e - Exception
Returns:
Completed future that will throw

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 boolean isDone()
Specified by:
isDone in interface Future<V>

get

public V get()
      throws ExecutionException
Specified by:
get in interface Future<V>
Throws:
ExecutionException

get

public V get(long timeout,
             TimeUnit unit)
      throws ExecutionException
Specified by:
get in interface Future<V>
Throws:
ExecutionException

Get Mondrian at SourceForge.net. Fast, secure and free Open Source software downloads