Class ConcurrentUtils.ConstantFuture<T>

  • Type Parameters:
    T - the type of the value wrapped by this class
    All Implemented Interfaces:
    java.util.concurrent.Future<T>
    Enclosing class:
    ConcurrentUtils

    static final class ConcurrentUtils.ConstantFuture<T>
    extends java.lang.Object
    implements java.util.concurrent.Future<T>
    A specialized Future implementation which wraps a constant value.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private T value
      The constant value.
    • Constructor Summary

      Constructors 
      Constructor Description
      ConstantFuture​(T value)
      Creates a new instance of ConstantFuture and initializes it with the constant value.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean cancel​(boolean mayInterruptIfRunning)
      The cancel operation is not supported.
      T get()
      This implementation just returns the constant value.
      T get​(long timeout, java.util.concurrent.TimeUnit unit)
      This implementation just returns the constant value; it does not block, therefore the timeout has no meaning.
      boolean isCancelled()
      This implementation always returns false; there is no background process which could be cancelled.
      boolean isDone()
      This implementation always returns true because the constant object managed by this Future implementation is always available.
      • Methods inherited from class java.lang.Object

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

      • value

        private final T value
        The constant value.
    • Constructor Detail

      • ConstantFuture

        ConstantFuture​(T value)
        Creates a new instance of ConstantFuture and initializes it with the constant value.
        Parameters:
        value - the value (may be null)
    • Method Detail

      • isDone

        public boolean isDone()
        This implementation always returns true because the constant object managed by this Future implementation is always available.
        Specified by:
        isDone in interface java.util.concurrent.Future<T>
      • get

        public T get()
        This implementation just returns the constant value.
        Specified by:
        get in interface java.util.concurrent.Future<T>
      • get

        public T get​(long timeout,
                     java.util.concurrent.TimeUnit unit)
        This implementation just returns the constant value; it does not block, therefore the timeout has no meaning.
        Specified by:
        get in interface java.util.concurrent.Future<T>
      • isCancelled

        public boolean isCancelled()
        This implementation always returns false; there is no background process which could be cancelled.
        Specified by:
        isCancelled in interface java.util.concurrent.Future<T>
      • cancel

        public boolean cancel​(boolean mayInterruptIfRunning)
        The cancel operation is not supported. This implementation always returns false.
        Specified by:
        cancel in interface java.util.concurrent.Future<T>