Class SettableFuture<V>
- java.lang.Object
-
- com.google.common.util.concurrent.AbstractFuture<V>
-
- com.google.common.util.concurrent.SettableFuture<V>
-
- All Implemented Interfaces:
ListenableFuture<V>,java.util.concurrent.Future<V>
public final class SettableFuture<V> extends AbstractFuture<V>
AListenableFuturewhose result may be set by aset(Object)orsetException(Throwable)call. It may also be cancelled.- Since:
- 9.0 (in 1.0 as
ValueFuture)
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static <V> SettableFuture<V>create()Creates a newSettableFuturein the default state.booleanset(V value)Sets the value of this future.booleansetException(java.lang.Throwable throwable)Sets the future to having failed with the given exception.-
Methods inherited from class com.google.common.util.concurrent.AbstractFuture
addListener, cancel, get, get, isCancelled, isDone
-
-
-
-
Method Detail
-
create
public static <V> SettableFuture<V> create()
Creates a newSettableFuturein the default state.
-
set
public boolean set(@Nullable V value)Sets the value of this future. This method will returntrueif the value was successfully set, orfalseif the future has already been set or cancelled.- Parameters:
value- the value the future should hold.- Returns:
- true if the value was successfully set.
-
setException
public boolean setException(java.lang.Throwable throwable)
Sets the future to having failed with the given exception. This exception will be wrapped in anExecutionExceptionand thrown from thegetmethods. This method will returntrueif the exception was successfully set, orfalseif the future has already been set or cancelled.- Parameters:
throwable- the exception the future should hold.- Returns:
- true if the exception was successfully set.
-
-