T
- the type of this Future
S
- the type of the adaptee's Future
public abstract class FutureAdapter<T,S> extends Object implements Future<T>
Future
parameterized over S into a Future
parameterized over T. All methods are delegated to the adaptee, where get()
and get(long, TimeUnit)
call adapt(Object)
on the adaptee's result.Modifier | Constructor and Description |
---|---|
protected |
FutureAdapter(Future<S> adaptee)
Constructs a new
FutureAdapter with the given adaptee. |
Modifier and Type | Method and Description |
---|---|
protected abstract T |
adapt(S adapteeResult)
Adapts the given adaptee's result into T.
|
boolean |
cancel(boolean mayInterruptIfRunning) |
T |
get() |
T |
get(long timeout,
TimeUnit unit) |
protected Future<S> |
getAdaptee()
Returns the adaptee.
|
boolean |
isCancelled() |
boolean |
isDone() |
public boolean cancel(boolean mayInterruptIfRunning)
public boolean isCancelled()
isCancelled
in interface Future<T>
public T get() throws InterruptedException, ExecutionException
get
in interface Future<T>
InterruptedException
ExecutionException
public T get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException
get
in interface Future<T>
InterruptedException
ExecutionException
TimeoutException
protected abstract T adapt(S adapteeResult) throws ExecutionException
ExecutionException