Class ConcurrentUtils.ConstantFuture<T>
- java.lang.Object
-
- org.apache.commons.lang3.concurrent.ConcurrentUtils.ConstantFuture<T>
-
- Type Parameters:
T- the type of the value wrapped by this class
- All Implemented Interfaces:
Future<T>
- Enclosing class:
- ConcurrentUtils
static final class ConcurrentUtils.ConstantFuture<T> extends Object implements Future<T>
A specializedFutureimplementation which wraps a constant value.
-
-
Constructor Summary
Constructors Constructor Description ConstantFuture(T value)Creates a new instance ofConstantFutureand initializes it with the constant value.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancancel(boolean mayInterruptIfRunning)The cancel operation is not supported.Tget()This implementation just returns the constant value.Tget(long timeout, TimeUnit unit)This implementation just returns the constant value; it does not block, therefore the timeout has no meaning.booleanisCancelled()This implementation always returns false; there is no background process which could be cancelled.booleanisDone()This implementation always returns true because the constant object managed by thisFutureimplementation is always available.
-
-
-
Constructor Detail
-
ConstantFuture
ConstantFuture(T value)
Creates a new instance ofConstantFutureand 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 thisFutureimplementation is always available.
-
get
public T get()
This implementation just returns the constant value.
-
get
public T get(long timeout, TimeUnit unit)
This implementation just returns the constant value; it does not block, therefore the timeout has no meaning.
-
isCancelled
public boolean isCancelled()
This implementation always returns false; there is no background process which could be cancelled.- Specified by:
isCancelledin interfaceFuture<T>
-
-