Class ForwardingFuture<V>
- java.lang.Object
-
- com.google.common.collect.ForwardingObject
-
- com.google.common.util.concurrent.ForwardingFuture<V>
-
- All Implemented Interfaces:
java.util.concurrent.Future<V>
- Direct Known Subclasses:
AbstractScheduledService.CustomScheduler.ReschedulableCallable,ForwardingFuture.SimpleForwardingFuture,ForwardingListenableFuture,JdkFutureAdapters.ListenableFutureAdapter
@GwtCompatible public abstract class ForwardingFuture<V> extends ForwardingObject implements java.util.concurrent.Future<V>
AFuturewhich forwards all its method calls to another future. Subclasses should override one or more methods to modify the behavior of the backing future as desired per the decorator pattern.Most subclasses can just use
ForwardingFuture.SimpleForwardingFuture.- Since:
- 1.0
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classForwardingFuture.SimpleForwardingFuture<V>A simplified version ofForwardingFuturewhere subclasses can pass in an already constructedFutureas the delegate.
-
Constructor Summary
Constructors Modifier Constructor Description protectedForwardingFuture()Constructor for use by subclasses.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description booleancancel(boolean mayInterruptIfRunning)protected abstract java.util.concurrent.Future<? extends V>delegate()Returns the backing delegate instance that methods are forwarded to.Vget()Vget(long timeout, java.util.concurrent.TimeUnit unit)booleanisCancelled()booleanisDone()-
Methods inherited from class com.google.common.collect.ForwardingObject
toString
-
-
-
-
Method Detail
-
delegate
protected abstract java.util.concurrent.Future<? extends V> delegate()
Description copied from class:ForwardingObjectReturns the backing delegate instance that methods are forwarded to. Abstract subclasses generally override this method with an abstract method that has a more specific return type, such asForwardingSet.delegate(). Concrete subclasses override this method to supply the instance being decorated.- Specified by:
delegatein classForwardingObject
-
cancel
public boolean cancel(boolean mayInterruptIfRunning)
- Specified by:
cancelin interfacejava.util.concurrent.Future<V>
-
isCancelled
public boolean isCancelled()
- Specified by:
isCancelledin interfacejava.util.concurrent.Future<V>
-
isDone
public boolean isDone()
- Specified by:
isDonein interfacejava.util.concurrent.Future<V>
-
get
public V get() throws java.lang.InterruptedException, java.util.concurrent.ExecutionException
- Specified by:
getin interfacejava.util.concurrent.Future<V>- Throws:
java.lang.InterruptedExceptionjava.util.concurrent.ExecutionException
-
get
public V get(long timeout, java.util.concurrent.TimeUnit unit) throws java.lang.InterruptedException, java.util.concurrent.ExecutionException, java.util.concurrent.TimeoutException
- Specified by:
getin interfacejava.util.concurrent.Future<V>- Throws:
java.lang.InterruptedExceptionjava.util.concurrent.ExecutionExceptionjava.util.concurrent.TimeoutException
-
-