Fixed checkstyle warnings.

git-svn-id: https://svn.apache.org/repos/asf/commons/proper/lang/trunk@1082299 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Oliver Heger 2011-03-16 20:58:38 +00:00
parent eef3ffe0e2
commit a8c12eaa1d
1 changed files with 31 additions and 0 deletions

View File

@ -317,6 +317,7 @@ public class ConcurrentUtils {
* A constant future can also be useful in testing.
* </p>
*
* @param <T> the type of the value used by this {@code Future} object
* @param value the constant value to return, may be null
* @return an instance of Future that will return the value, never null
*/
@ -324,30 +325,60 @@ public class ConcurrentUtils {
return new ConstantFuture<T>(value);
}
/**
* A specialized {@code Future} implementation which wraps a constant value.
* @param <T> the type of the value wrapped by this class
*/
static final class ConstantFuture<T> implements Future<T> {
/** The constant value. */
private final T value;
/**
* Creates a new instance of {@code ConstantFuture} and initializes it
* with the constant value.
*
* @param value the value (may be <b>null</b>)
*/
ConstantFuture(T value) {
this.value = value;
}
/**
* {@inheritDoc} This implementation always returns <b>true</b> because
* the constant object managed by this {@code Future} implementation is
* always available.
*/
public boolean isDone() {
return true;
}
/**
* {@inheritDoc} This implementation just returns the constant value.
*/
public T get() {
return value;
}
/**
* {@inheritDoc} This implementation just returns the constant value; it
* does not block, therefore the timeout has no meaning.
*/
public T get(long timeout, TimeUnit unit) {
return value;
}
/**
* {@inheritDoc} This implementation always returns <b>false</b>; there
* is no background process which could be cancelled.
*/
public boolean isCancelled() {
return false;
}
/**
* {@inheritDoc} The cancel operation is not supported. This
* implementation always returns <b>false</b>.
*/
public boolean cancel(boolean mayInterruptIfRunning) {
return false;
}