Class AbstractCheckedFuture<V, X extends Exception>
- All Implemented Interfaces:
CheckedFuture<V,X>, ListenableFuture<V>, Future<V>
ListenableFuture that adds support for the checkedGet() and checkedGet(long, TimeUnit) methods.- Since:
- 1.0
-
Nested Class Summary
Nested classes/interfaces inherited from class ForwardingListenableFuture
ForwardingListenableFuture.SimpleForwardingListenableFuture<V>Nested classes/interfaces inherited from class ForwardingFuture
ForwardingFuture.SimpleForwardingFuture<V>Nested classes/interfaces inherited from interface Future
Future.State -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractCheckedFuture(ListenableFuture<V> delegate) Constructs anAbstractCheckedFuturethat wraps a delegate. -
Method Summary
Modifier and TypeMethodDescriptionException checking version ofFuture.get()that will translateInterruptedException,CancellationExceptionandExecutionExceptioninto application-specific exceptions.checkedGet(long timeout, TimeUnit unit) Exception checking version ofFuture.get(long, TimeUnit)that will translateInterruptedException,CancellationExceptionandExecutionExceptioninto application-specific exceptions.protected abstract XTranslates from anInterruptedException,CancellationExceptionorExecutionExceptionthrown bygetto an exception of typeXto be thrown bycheckedGet.Methods inherited from class ForwardingListenableFuture.SimpleForwardingListenableFuture
delegateMethods inherited from class ForwardingListenableFuture
addListenerMethods inherited from class ForwardingFuture
cancel, get, get, isCancelled, isDoneMethods inherited from class ForwardingObject
toStringMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface Future
cancel, exceptionNow, get, get, isCancelled, isDone, resultNow, stateMethods inherited from interface ListenableFuture
addListener
-
Constructor Details
-
AbstractCheckedFuture
Constructs anAbstractCheckedFuturethat wraps a delegate.
-
-
Method Details
-
mapException
Translates from anInterruptedException,CancellationExceptionorExecutionExceptionthrown bygetto an exception of typeXto be thrown bycheckedGet. Subclasses must implement this method.If
eis anInterruptedException, the callingcheckedGetmethod has already restored the interrupt after catching the exception. If an implementation ofmapException(Exception)wishes to swallow the interrupt, it can do so by callingThread.interrupted().Subclasses may choose to throw, rather than return, a subclass of
RuntimeExceptionto allow creating a CheckedFuture that throws both checked and unchecked exceptions. -
checkedGet
Exception checking version ofFuture.get()that will translateInterruptedException,CancellationExceptionandExecutionExceptioninto application-specific exceptions.This implementation calls
ForwardingFuture.get()and maps that method's standard exceptions to instances of typeXusingmapException(Exception).In addition, if
getthrows anInterruptedException, this implementation will set the current thread's interrupt status before callingmapException.- Specified by:
checkedGetin interfaceCheckedFuture<V, X extends Exception>- Returns:
- the result of executing the future.
- Throws:
X- ifForwardingFuture.get()throws anInterruptedException,CancellationException, orExecutionException
-
checkedGet
Exception checking version ofFuture.get(long, TimeUnit)that will translateInterruptedException,CancellationExceptionandExecutionExceptioninto application-specific exceptions. On timeout this method throws a normalTimeoutException.This implementation calls
ForwardingFuture.get(long, TimeUnit)and maps that method's standard exceptions (excludingTimeoutException, which is propagated) to instances of typeXusingmapException(Exception).In addition, if
getthrows anInterruptedException, this implementation will set the current thread's interrupt status before callingmapException.- Specified by:
checkedGetin interfaceCheckedFuture<V, X extends Exception>- Returns:
- the result of executing the future.
- Throws:
X- ifForwardingFuture.get()throws anInterruptedException,CancellationException, orExecutionExceptionTimeoutException- if retrieving the result timed out.
-