From 1ba33b7e5d43594d2387f9d9220de7806264a3ba Mon Sep 17 00:00:00 2001 From: "ray.j.greenwell" Date: Wed, 22 Apr 2009 22:05:13 +0000 Subject: [PATCH] mdb suggests this approach. Seems fine, even if this is the only method ever in this class. git-svn-id: https://samskivert.googlecode.com/svn/trunk@2548 6335cc39-0255-0410-8fd6-9bcaacd3b74c --- src/java/com/samskivert/util/Callables.java | 25 ++++++++++++ .../com/samskivert/util/ValueCallable.java | 39 ------------------- 2 files changed, 25 insertions(+), 39 deletions(-) create mode 100644 src/java/com/samskivert/util/Callables.java delete mode 100644 src/java/com/samskivert/util/ValueCallable.java 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; -}