Class DelegatingFuture<V>
- java.lang.Object
-
- nl.talsmasoftware.context.delegation.Wrapper<Future<V>>
-
- nl.talsmasoftware.context.delegation.DelegatingFuture<V>
-
- All Implemented Interfaces:
Future<V>
public abstract class DelegatingFuture<V> extends Wrapper<Future<V>> implements Future<V>
Abstract baseclass that simplifies wrapping an existingFutureby forwarding all required methods to adelegate futureobject.
The class also provides overridable wrapper methods forresultandexceptionoutcomes.Although this class does implement all required methods of
Futureit is still declared as an abstract class.
This is because it does not provide any value in itself.- Author:
- Sjoerd Talsma
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedDelegatingFuture(Future<V> delegate)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancancel(boolean mayInterruptIfRunning)Vget()Vget(long timeout, TimeUnit unit)booleanisCancelled()booleanisDone()protected ExecutionExceptionwrapException(ExecutionException exception)Overridable method to wrap theExecutionExceptionafter it has been thrown from the delegate future.protected VwrapResult(V result)Overridable method to wrap the result after it has been obtained from the delegate future.
-
-
-
Method Detail
-
wrapResult
protected V wrapResult(V result)
Overridable method to wrap the result after it has been obtained from the delegate future.- Parameters:
result- The original result from the delegate.- Returns:
- The wrapped result.
-
wrapException
protected ExecutionException wrapException(ExecutionException exception)
Overridable method to wrap theExecutionExceptionafter it has been thrown from the delegate future.- Parameters:
exception- The original execution exception from the delegate.- Returns:
- The wrapped exception.
-
cancel
public boolean cancel(boolean mayInterruptIfRunning)
-
isCancelled
public boolean isCancelled()
- Specified by:
isCancelledin interfaceFuture<V>
-
get
public V get() throws InterruptedException, ExecutionException
- Specified by:
getin interfaceFuture<V>- Throws:
InterruptedExceptionExecutionException
-
get
public V get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException
- Specified by:
getin interfaceFuture<V>- Throws:
InterruptedExceptionExecutionExceptionTimeoutException
-
-