Package org.openrefine.process
Class CompletedFuture<T>
- java.lang.Object
-
- org.openrefine.process.CompletedFuture<T>
-
- All Implemented Interfaces:
com.google.common.util.concurrent.ListenableFuture<T>
,Future<T>
,ProgressingFuture<T>
public class CompletedFuture<T> extends Object implements ProgressingFuture<T>
An implementation ofProgressingFuture
which is already supplied with its final value. Therefore, there is nothing to compute and methods provided to manage the computation process do nothing.
-
-
Constructor Summary
Constructors Constructor Description CompletedFuture(T value)
Constructs a future whose value is already computed.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addListener(Runnable listener, Executor executor)
boolean
cancel(boolean b)
T
get()
T
get(long l, TimeUnit timeUnit)
int
getProgress()
boolean
isCancelled()
boolean
isDone()
boolean
isPaused()
void
onProgress(ProgressReporter reporter)
Registers a callback to be called every time the progress of this task changes.void
pause()
Pauses the process that is computing the value to be returned in this future.void
resume()
Resumes the process that is computing the value to be returned in this future.boolean
supportsProgress()
-
-
-
Constructor Detail
-
CompletedFuture
public CompletedFuture(T value)
Constructs a future whose value is already computed.
-
-
Method Detail
-
pause
public void pause()
Description copied from interface:ProgressingFuture
Pauses the process that is computing the value to be returned in this future. If this process is not running, this action has no effect.- Specified by:
pause
in interfaceProgressingFuture<T>
-
resume
public void resume()
Description copied from interface:ProgressingFuture
Resumes the process that is computing the value to be returned in this future. If this process had not been paused before, this action has no effect.- Specified by:
resume
in interfaceProgressingFuture<T>
-
isPaused
public boolean isPaused()
- Specified by:
isPaused
in interfaceProgressingFuture<T>
- Returns:
- whether the process is currently paused
-
supportsProgress
public boolean supportsProgress()
- Specified by:
supportsProgress
in interfaceProgressingFuture<T>
- Returns:
- whether the underlying process supports reporting progress beyond a boolean status, that is to say whether it can be in progress states strictly between 0 and 100.
-
getProgress
public int getProgress()
- Specified by:
getProgress
in interfaceProgressingFuture<T>
- Returns:
- the current progress percentage of the task, between 0 and 100. If the task does not support reporting progress, this returns 0 until the task is successful, after which it returns 100. If the task results in an error, the progress might not reach 100.
-
onProgress
public void onProgress(ProgressReporter reporter)
Description copied from interface:ProgressingFuture
Registers a callback to be called every time the progress of this task changes. The callback will be called at least once, on registration, with the current value of the progress.- Specified by:
onProgress
in interfaceProgressingFuture<T>
- Parameters:
reporter
- the callback to call.
-
isCancelled
public boolean isCancelled()
- Specified by:
isCancelled
in interfaceFuture<T>
-
get
public T get() throws InterruptedException, ExecutionException
- Specified by:
get
in interfaceFuture<T>
- Throws:
InterruptedException
ExecutionException
-
get
public T get(long l, TimeUnit timeUnit) throws InterruptedException, ExecutionException, TimeoutException
- Specified by:
get
in interfaceFuture<T>
- Throws:
InterruptedException
ExecutionException
TimeoutException
-
-