diff --git a/src/java/com/samskivert/util/ValueCallable.java b/src/java/com/samskivert/util/ValueCallable.java new file mode 100644 index 00000000..ca30d29f --- /dev/null +++ b/src/java/com/samskivert/util/ValueCallable.java @@ -0,0 +1,39 @@ +// +// $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; +}