public final class FutureConjunction extends Object implements com.google.common.util.concurrent.ListenableFuture<Boolean>
This class implements a Future<Boolean> that is conjunction of zero or more other Future<Boolean>s,
i.e. it evaluates to true if, and only if, all its operands evaluate to true. To use this class,
simply create an instance of it and add operands to it using the addOperand(ListenableFuture)
method.
Modifier and Type | Field and Description |
---|---|
private List<com.google.common.util.concurrent.ListenableFuture<Boolean>> |
operands |
Constructor and Description |
---|
FutureConjunction() |
Modifier and Type | Method and Description |
---|---|
void |
addListener(Runnable listener,
Executor executor) |
void |
addOperand(com.google.common.util.concurrent.ListenableFuture<Boolean> operand)
Adds a ListenableFuture<Boolean> to this conjunction.
|
boolean |
cancel(boolean mayInterruptIfRunning) |
Boolean |
get() |
Boolean |
get(long timeout,
TimeUnit unit) |
boolean |
isCancelled() |
boolean |
isDone() |
public void addOperand(com.google.common.util.concurrent.ListenableFuture<Boolean> operand)
Adds a ListenableFuture<Boolean> to this conjunction. This can be called at any time, even after having called
get()
previously.
operand
- The operand to add to this conjunction.public void addListener(Runnable listener, Executor executor)
addListener
in interface com.google.common.util.concurrent.ListenableFuture<Boolean>
public final boolean cancel(boolean mayInterruptIfRunning)
public final boolean isCancelled()
isCancelled
in interface Future<Boolean>
public final Boolean get() throws InterruptedException, ExecutionException
get
in interface Future<Boolean>
InterruptedException
ExecutionException
public final Boolean get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException
get
in interface Future<Boolean>
InterruptedException
ExecutionException
TimeoutException
Copyright © 2018. All rights reserved.