diff --git a/src/java/com/samskivert/util/Callables.java b/src/java/com/samskivert/util/Callables.java new file mode 100644 index 00000000..06aa18a4 --- /dev/null +++ b/src/java/com/samskivert/util/Callables.java @@ -0,0 +1,25 @@ +// +// $Id$ + +package com.samskivert.util; + +import java.util.concurrent.Callable; + +/** + * Utilities for Callables. + */ +public class Callables +{ + /** + * Return a {@link Callable} that merely returns the specified value. + * No exception will ever be thrown. + */ + public static Callable asCallable (final V value) + { + return new Callable() { + public V call () { + return value; + } + }; + } +} diff --git a/src/java/com/samskivert/util/ValueCallable.java b/src/java/com/samskivert/util/ValueCallable.java deleted file mode 100644 index ca30d29f..00000000 --- a/src/java/com/samskivert/util/ValueCallable.java +++ /dev/null @@ -1,39 +0,0 @@ -// -// $Id$ - -package com.samskivert.util; - -import java.util.concurrent.Callable; - -/** - * A Callable that just returns a predefined value. - */ -public class ValueCallable - implements Callable -{ - /** - * Factory to create a ValueCallable from a value while avoiding having to specify the type. - * TODO: I think I want in the return value, not sure how to make it. - */ - public static ValueCallable create (V value) - { - return new ValueCallable(value); - } - - /** - * Construct a ValueCallable. - */ - public ValueCallable (V value) - { - _value = value; - } - - // from interface Callable - public V call () - { - return _value; - } - - /** The value we'll be returning. */ - protected V _value; -}