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
A specialized
Future
implementation which wraps a constant value.-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionConstantFuture
(T value) Creates a new instance ofConstantFuture
and initializes it with the constant value. -
Method Summary
Modifier and TypeMethodDescriptionboolean
cancel
(boolean mayInterruptIfRunning) The cancel operation is not supported.get()
This implementation just returns the constant value.This implementation just returns the constant value; it does not block, therefore the timeout has no meaning.boolean
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 thisFuture
implementation is always available.
-
Field Details
-
value
The constant value.
-
-
Constructor Details
-
ConstantFuture
ConstantFuture(T value) Creates a new instance ofConstantFuture
and initializes it with the constant value.- Parameters:
value
- the value (may be null)
-
-
Method Details
-
isDone
public boolean isDone()This implementation always returns true because the constant object managed by thisFuture
implementation is always available. -
get
This implementation just returns the constant value. -
get
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:
isCancelled
in interfaceFuture<T>
-
cancel
public boolean cancel(boolean mayInterruptIfRunning) The cancel operation is not supported. This implementation always returns false.
-