public class DelegatingFuture<T> extends Object implements Future<T>
Future
that delegates all operations to another future. The delegate future does not need to be
specified when the FutureFuture
is created.
In the event that this Future
is cancelled before the delegate is assigned, the delegate will be cancelled at the time
of assignment.Constructor and Description |
---|
DelegatingFuture() |
Modifier and Type | Method and Description |
---|---|
boolean |
cancel(boolean mayInterruptIfRunning) |
T |
get() |
T |
get(long timeout,
TimeUnit unit) |
boolean |
isCancelled() |
boolean |
isDone() |
void |
setDelegate(Future<T> delegate)
Set the delegate, throwing an exception if it has already been set.
|
void |
setDelegateIfUnset(Future<T> delegate)
Set the delegate, if it hasn't been set already.
|
public void setDelegateIfUnset(Future<T> delegate)
public void setDelegate(Future<T> delegate)
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