Class CompletedFuture<T>

  • Type Parameters:
    T - the future result type of an asynchronous operation.
    All Implemented Interfaces:
    java.util.concurrent.Future<T>, Cancellable

    @Contract(threading=IMMUTABLE)
    public class CompletedFuture<T>
    extends java.lang.Object
    implements java.util.concurrent.Future<T>, Cancellable
    Immutable, completed future.
    Since:
    5.0
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private T result  
    • Constructor Summary

      Constructors 
      Constructor Description
      CompletedFuture​(T result)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean cancel()
      Cancels the ongoing operation or process.
      boolean cancel​(boolean mayInterruptIfRunning)  
      T get()  
      T get​(long timeout, java.util.concurrent.TimeUnit unit)  
      boolean isCancelled()  
      boolean isDone()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • result

        private final T result
    • Constructor Detail

      • CompletedFuture

        public CompletedFuture​(T result)
    • Method Detail

      • isCancelled

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

        public boolean isDone()
        Specified by:
        isDone in interface java.util.concurrent.Future<T>
      • get

        public T get()
        Specified by:
        get in interface java.util.concurrent.Future<T>
      • get

        public T get​(long timeout,
                     java.util.concurrent.TimeUnit unit)
        Specified by:
        get in interface java.util.concurrent.Future<T>
      • cancel

        public boolean cancel​(boolean mayInterruptIfRunning)
        Specified by:
        cancel in interface java.util.concurrent.Future<T>
      • cancel

        public boolean cancel()
        Description copied from interface: Cancellable
        Cancels the ongoing operation or process.
        Specified by:
        cancel in interface Cancellable
        Returns:
        true if the operation or process has been cancelled as a result of this method call or false if it has already been cancelled or not started.