Class FutureAdapter<T,S>
- java.lang.Object
- org.springframework.util.concurrent.FutureAdapter<T,S>
- Type Parameters:
T- the type of thisFutureS- the type of the adaptee'sFuture
- All Implemented Interfaces:
Future<T>
- Direct Known Subclasses:
ListenableFutureAdapter
public abstract class FutureAdapter<T,S> extends Object implements Future<T>
Abstract class that adapts aFutureparameterized over S into aFutureparameterized over T. All methods are delegated to the adaptee, whereget()andget(long, TimeUnit)calladapt(Object)on the adaptee's result.- Since:
- 4.0
- Author:
- Arjen Poutsma
Constructor Summary
Constructors Modifier Constructor Description protectedFutureAdapter(Future<S> adaptee)Constructs a newFutureAdapterwith the given adaptee.
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract Tadapt(S adapteeResult)Adapts the given adaptee's result into T.booleancancel(boolean mayInterruptIfRunning)Tget()Tget(long timeout, TimeUnit unit)protected Future<S>getAdaptee()Returns the adaptee.booleanisCancelled()booleanisDone()
Constructor Detail
FutureAdapter
protected FutureAdapter(Future<S> adaptee)
Constructs a newFutureAdapterwith the given adaptee.- Parameters:
adaptee- the future to delegate to
Method Detail
getAdaptee
protected Future<S> getAdaptee()
Returns the adaptee.
cancel
public boolean cancel(boolean mayInterruptIfRunning)
isCancelled
public boolean isCancelled()
- Specified by:
isCancelledin interfaceFuture<T>
get
public T get() throws InterruptedException, ExecutionException
- Specified by:
getin interfaceFuture<T>- Throws:
InterruptedExceptionExecutionException
get
public T get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException
- Specified by:
getin interfaceFuture<T>- Throws:
InterruptedExceptionExecutionExceptionTimeoutException
adapt
protected abstract T adapt(S adapteeResult) throws ExecutionException
Adapts the given adaptee's result into T.- Returns:
- the adapted result
- Throws:
ExecutionException