Package mondrian.util
Class CompletedFuture<V>
- java.lang.Object
-
- mondrian.util.CompletedFuture<V>
-
- All Implemented Interfaces:
java.util.concurrent.Future<V>
public class CompletedFuture<V> extends java.lang.Object implements java.util.concurrent.Future<V>
Implementation ofFuture
that has already completed.
-
-
Constructor Summary
Constructors Constructor Description CompletedFuture(V value, java.util.concurrent.ExecutionException exception)
Creates a CompletedFuture.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
cancel(boolean mayInterruptIfRunning)
static <T> CompletedFuture<T>
fail(java.lang.Throwable e)
Creates a completed future indicating failure.V
get()
V
get(long timeout, java.util.concurrent.TimeUnit unit)
boolean
isCancelled()
boolean
isDone()
static <T> CompletedFuture<T>
success(T t)
Creates a completed future indicating success.
-
-
-
Constructor Detail
-
CompletedFuture
public CompletedFuture(V value, java.util.concurrent.ExecutionException exception)
Creates a CompletedFuture.If
throwable
is not null, the computation is deemed to have failed. The exception will be thrown (wrapped in aExecutionException
) whenget()
orget(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(java.lang.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 interfacejava.util.concurrent.Future<V>
-
isCancelled
public boolean isCancelled()
- Specified by:
isCancelled
in interfacejava.util.concurrent.Future<V>
-
isDone
public boolean isDone()
- Specified by:
isDone
in interfacejava.util.concurrent.Future<V>
-
get
public V get() throws java.util.concurrent.ExecutionException
- Specified by:
get
in interfacejava.util.concurrent.Future<V>
- Throws:
java.util.concurrent.ExecutionException
-
-