Class 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 of ProgressingFuture 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 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 interface ProgressingFuture<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 interface ProgressingFuture<T>
      • isPaused

        public boolean isPaused()
        Specified by:
        isPaused in interface ProgressingFuture<T>
        Returns:
        whether the process is currently paused
      • supportsProgress

        public boolean supportsProgress()
        Specified by:
        supportsProgress in interface ProgressingFuture<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 interface ProgressingFuture<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 interface ProgressingFuture<T>
        Parameters:
        reporter - the callback to call.
      • cancel

        public boolean cancel​(boolean b)
        Specified by:
        cancel in interface Future<T>
      • isCancelled

        public boolean isCancelled()
        Specified by:
        isCancelled in interface Future<T>
      • isDone

        public boolean isDone()
        Specified by:
        isDone in interface Future<T>
      • addListener

        public void addListener​(Runnable listener,
                                Executor executor)
        Specified by:
        addListener in interface com.google.common.util.concurrent.ListenableFuture<T>