You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by mb...@apache.org on 2008/06/09 19:17:43 UTC

svn commit: r665786 [5/6] - in /commons/sandbox/functor/trunk/src: main/java/org/apache/commons/functor/adapter/ main/java/org/apache/commons/functor/core/ main/java/org/apache/commons/functor/core/algorithm/ main/java/org/apache/commons/functor/core/c...

Modified: commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/generator/util/LongRange.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/generator/util/LongRange.java?rev=665786&r1=665785&r2=665786&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/generator/util/LongRange.java (original)
+++ commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/generator/util/LongRange.java Mon Jun  9 10:17:39 2008
@@ -25,7 +25,7 @@
  * @author Jason Horman (jason@jhorman.org)
  * @author Rodney Waldhoff
  */
-public final class LongRange extends BaseGenerator {
+public final class LongRange extends BaseGenerator<Long> {
     // attributes
     //---------------------------------------------------------------
 
@@ -72,11 +72,10 @@
     public LongRange(long from, long to, long step) {
         if (from != to && signOf(step) != signOf(to - from)) {
             throw new IllegalArgumentException("Will never reach " + to + " from " + from + " using step " + step);
-        } else {
-            this.from = from;
-            this.to = to;
-            this.step = step;
         }
+        this.from = from;
+        this.to = to;
+        this.step = step;
     }
 
     // methods
@@ -84,14 +83,14 @@
     /**
      * {@inheritDoc}
      */
-    public void run(UnaryProcedure proc) {
+    public void run(UnaryProcedure<? super Long> proc) {
         if (signOf(step) == -1L) {
             for (long i = from; i > to; i += step) {
-                proc.run(new Long(i));
+                proc.run(i);
             }
         } else {
             for (long i = from; i < to; i += step) {
-                proc.run(new Long(i));
+                proc.run(i);
             }
         }
     }
@@ -139,13 +138,7 @@
      * @return long
      */
     private static long signOf(long value) {
-        if (value < 0L) {
-            return -1L;
-        } else if (value > 0L) {
-            return 1L;
-        } else {
-            return 0L;
-        }
+        return value < 0L ? -1L : value > 0L ? 1L : 0L;
     }
 
     /**
@@ -155,11 +148,7 @@
      * @return long
      */
     private static long defaultStep(long from, long to) {
-        if (from > to) {
-            return -1L;
-        } else {
-            return 1L;
-        }
+        return from > to ? -1L : 1L;
     }
 
 }
\ No newline at end of file

Modified: commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/TestAlgorithms.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/TestAlgorithms.java?rev=665786&r1=665785&r2=665786&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/TestAlgorithms.java (original)
+++ commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/TestAlgorithms.java Mon Jun  9 10:17:39 2008
@@ -56,6 +56,7 @@
  * @version $Revision$ $Date$
  * @author Rodney Waldhoff
  */
+@SuppressWarnings("unchecked")
 public class TestAlgorithms extends TestCase {
 
     // Conventional

Modified: commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/adapter/TestBinaryFunctionBinaryProcedure.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/adapter/TestBinaryFunctionBinaryProcedure.java?rev=665786&r1=665785&r2=665786&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/adapter/TestBinaryFunctionBinaryProcedure.java (original)
+++ commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/adapter/TestBinaryFunctionBinaryProcedure.java Mon Jun  9 10:17:39 2008
@@ -46,7 +46,7 @@
     // ------------------------------------------------------------------------
 
     protected Object makeFunctor() {
-        return new BinaryFunctionBinaryProcedure(new Constant("K"));
+        return new BinaryFunctionBinaryProcedure<Object, Object>(Constant.of("K"));
     }
 
     // Lifecycle
@@ -64,12 +64,12 @@
     // ------------------------------------------------------------------------
 
     public void testRun() throws Exception {
-        class EvaluateCounter implements BinaryFunction {
+        class EvaluateCounter implements BinaryFunction<Object, Object, Integer> {
             int count = 0;
-            public Object evaluate(Object a, Object b) { return new Integer(count++); }
+            public Integer evaluate(Object a, Object b) { return new Integer(count++); }
         }
         EvaluateCounter counter = new EvaluateCounter();
-        BinaryProcedure p = new BinaryFunctionBinaryProcedure(counter);
+        BinaryProcedure<Object, Object> p = new BinaryFunctionBinaryProcedure<Object, Object>(counter);
         assertEquals(0,counter.count);
         p.run(null,null);
         assertEquals(1,counter.count);
@@ -78,13 +78,11 @@
     }
 
     public void testEquals() throws Exception {
-        BinaryProcedure p = new BinaryFunctionBinaryProcedure(new Constant("K"));
+        BinaryProcedure<Object, Object> p = new BinaryFunctionBinaryProcedure<Object, Object>(Constant.of("K"));
         assertEquals(p,p);
-        assertObjectsAreEqual(p,new BinaryFunctionBinaryProcedure(new Constant("K")));
+        assertObjectsAreEqual(p,new BinaryFunctionBinaryProcedure<Object, Object>(Constant.of("K")));
         assertObjectsAreNotEqual(p,new NoOp());
-        assertObjectsAreNotEqual(p,new BinaryFunctionBinaryProcedure(null));
-        assertObjectsAreNotEqual(p,new BinaryFunctionBinaryProcedure(new Constant("J")));
-        assertObjectsAreEqual(new BinaryFunctionBinaryProcedure(null),new BinaryFunctionBinaryProcedure(null));
+        assertObjectsAreNotEqual(p,new BinaryFunctionBinaryProcedure<Object, Object>(Constant.of("J")));
     }
 
     public void testAdaptNull() throws Exception {
@@ -92,6 +90,6 @@
     }
 
     public void testAdapt() throws Exception {
-        assertNotNull(BinaryFunctionBinaryProcedure.adapt(new Constant("K")));
+        assertNotNull(BinaryFunctionBinaryProcedure.adapt(Constant.of("K")));
     }
 }

Modified: commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/adapter/TestBinaryPredicateBinaryFunction.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/adapter/TestBinaryPredicateBinaryFunction.java?rev=665786&r1=665785&r2=665786&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/adapter/TestBinaryPredicateBinaryFunction.java (original)
+++ commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/adapter/TestBinaryPredicateBinaryFunction.java Mon Jun  9 10:17:39 2008
@@ -62,23 +62,21 @@
     // ------------------------------------------------------------------------
 
     public void testTestWhenTrue() throws Exception {
-        BinaryFunction f = new BinaryPredicateBinaryFunction(new Constant(true));
-        assertEquals(Boolean.TRUE,f.evaluate(null,null));
+        BinaryFunction<Object, Object, Boolean> f = new BinaryPredicateBinaryFunction<Object, Object>(Constant.TRUE);
+        assertTrue(f.evaluate(null,null));
     }
 
     public void testTestWhenFalse() throws Exception {
-        BinaryFunction f = new BinaryPredicateBinaryFunction(new Constant(false));
-        assertEquals(Boolean.FALSE,f.evaluate(null,null));
+        BinaryFunction<Object, Object, Boolean> f = new BinaryPredicateBinaryFunction<Object, Object>(Constant.FALSE);
+        assertFalse(f.evaluate(null,null));
     }
 
     public void testEquals() throws Exception {
-        BinaryFunction f = new BinaryPredicateBinaryFunction(new Constant(true));
+        BinaryFunction<Object, Object, Boolean> f = new BinaryPredicateBinaryFunction<Object, Object>(Constant.TRUE);
         assertEquals(f,f);
-        assertObjectsAreEqual(f,new BinaryPredicateBinaryFunction(new Constant(true)));
-        assertObjectsAreNotEqual(f,new Constant("x"));
-        assertObjectsAreNotEqual(f,new BinaryPredicateBinaryFunction(new Constant(false)));
-        assertObjectsAreNotEqual(f,new BinaryPredicateBinaryFunction(null));
-        assertObjectsAreEqual(new BinaryPredicateBinaryFunction(null),new BinaryPredicateBinaryFunction(null));
+        assertObjectsAreEqual(f,new BinaryPredicateBinaryFunction<Object, Object>(Constant.TRUE));
+        assertObjectsAreNotEqual(f,Constant.of("x"));
+        assertObjectsAreNotEqual(f,new BinaryPredicateBinaryFunction<Object, Object>(Constant.FALSE));
     }
 
     public void testAdaptNull() throws Exception {
@@ -86,6 +84,6 @@
     }
 
     public void testAdapt() throws Exception {
-        assertNotNull(BinaryPredicateBinaryFunction.adapt(new Constant(true)));
+        assertNotNull(BinaryPredicateBinaryFunction.adapt(Constant.TRUE));
     }
 }

Modified: commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/adapter/TestBinaryProcedureBinaryFunction.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/adapter/TestBinaryProcedureBinaryFunction.java?rev=665786&r1=665785&r2=665786&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/adapter/TestBinaryProcedureBinaryFunction.java (original)
+++ commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/adapter/TestBinaryProcedureBinaryFunction.java Mon Jun  9 10:17:39 2008
@@ -46,7 +46,7 @@
     // ------------------------------------------------------------------------
 
     protected Object makeFunctor() {
-        return new BinaryProcedureBinaryFunction(new NoOp());
+        return new BinaryProcedureBinaryFunction<Object, Object, Object>(NoOp.instance());
     }
 
     // Lifecycle
@@ -64,19 +64,21 @@
     // ------------------------------------------------------------------------
 
     public void testEvaluate() throws Exception {
-        BinaryFunction f = new BinaryProcedureBinaryFunction(new NoOp());
+        BinaryFunction<Object, Object, Object> f = new BinaryProcedureBinaryFunction<Object, Object, Object>(NoOp.instance());
         assertNull(f.evaluate(null,null));
     }
 
     public void testEquals() throws Exception {
-        BinaryFunction f = new BinaryProcedureBinaryFunction(new NoOp());
+        BinaryFunction<Object, Object, Object> f = new BinaryProcedureBinaryFunction<Object, Object, Object>(new NoOp());
         assertEquals(f,f);
-        assertObjectsAreEqual(f,new BinaryProcedureBinaryFunction(new NoOp()));
-        assertObjectsAreNotEqual(f,new Constant("x"));
-        assertObjectsAreNotEqual(f,new BinaryProcedureBinaryFunction(new BinaryProcedure() { public void run(Object a, Object b) { } }));
-        assertObjectsAreNotEqual(f,new Constant(null));
-        assertObjectsAreNotEqual(f,new BinaryProcedureBinaryFunction(null));
-        assertObjectsAreEqual(new BinaryProcedureBinaryFunction(null),new BinaryProcedureBinaryFunction(null));
+        assertObjectsAreEqual(f,new BinaryProcedureBinaryFunction<Object, Object, Object>(new NoOp()));
+        assertObjectsAreNotEqual(f,Constant.of("x"));
+        assertObjectsAreNotEqual(f, new BinaryProcedureBinaryFunction<Object, Object, Object>(
+                new BinaryProcedure<Object, Object>() {
+                    public void run(Object a, Object b) {
+                    }
+                }));
+        assertObjectsAreNotEqual(f,Constant.of(null));
     }
 
     public void testAdaptNull() throws Exception {
@@ -84,6 +86,6 @@
     }
 
     public void testAdapt() throws Exception {
-        assertNotNull(BinaryProcedureBinaryFunction.adapt(new NoOp()));
+        assertNotNull(BinaryProcedureBinaryFunction.adapt(NoOp.instance()));
     }
 }

Modified: commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/adapter/TestIgnoreLeftFunction.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/adapter/TestIgnoreLeftFunction.java?rev=665786&r1=665785&r2=665786&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/adapter/TestIgnoreLeftFunction.java (original)
+++ commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/adapter/TestIgnoreLeftFunction.java Mon Jun  9 10:17:39 2008
@@ -63,7 +63,7 @@
     // ------------------------------------------------------------------------
 
     public void testEvaluate() throws Exception {
-        BinaryFunction f = new IgnoreLeftFunction(new Identity());
+        BinaryFunction<String, String, String> f = new IgnoreLeftFunction<String, String, String>(new Identity<String>());
         assertNull(f.evaluate(null,null));
         assertNull(f.evaluate("xyzzy",null));
         assertEquals("xyzzy",f.evaluate(null,"xyzzy"));
@@ -71,14 +71,12 @@
     }
 
     public void testEquals() throws Exception {
-        BinaryFunction f = new IgnoreLeftFunction(new Constant("xyzzy"));
+        BinaryFunction<Object, Object, String> f = new IgnoreLeftFunction<Object, Object, String>(Constant.of("xyzzy"));
         assertEquals(f,f);
-        assertObjectsAreEqual(f,new IgnoreLeftFunction(new Constant("xyzzy")));
-        assertObjectsAreNotEqual(f,new Constant("x"));
-        assertObjectsAreNotEqual(f,new IgnoreLeftFunction(new Constant(null)));
-        assertObjectsAreNotEqual(f,new Constant(null));
-        assertObjectsAreNotEqual(f,new IgnoreLeftFunction(null));
-        assertObjectsAreEqual(new IgnoreLeftFunction(null),new IgnoreLeftFunction(null));
+        assertObjectsAreEqual(f,new IgnoreLeftFunction<Object, Object, String>(Constant.of("xyzzy")));
+        assertObjectsAreNotEqual(f,Constant.of("x"));
+        assertObjectsAreNotEqual(f,new IgnoreLeftFunction<Object, Object, String>(Constant.<String>of(null)));
+        assertObjectsAreNotEqual(f,Constant.of(null));
     }
 
     public void testAdaptNull() throws Exception {
@@ -86,6 +84,6 @@
     }
 
     public void testAdapt() throws Exception {
-        assertNotNull(IgnoreLeftFunction.adapt(new Constant("xyzzy")));
+        assertNotNull(IgnoreLeftFunction.adapt(Constant.of("xyzzy")));
     }
 }

Modified: commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/adapter/TestIgnoreRightFunction.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/adapter/TestIgnoreRightFunction.java?rev=665786&r1=665785&r2=665786&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/adapter/TestIgnoreRightFunction.java (original)
+++ commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/adapter/TestIgnoreRightFunction.java Mon Jun  9 10:17:39 2008
@@ -63,7 +63,7 @@
     // ------------------------------------------------------------------------
 
     public void testEvaluate() throws Exception {
-        BinaryFunction f = new IgnoreRightFunction(new Identity());
+        BinaryFunction<String, String, String> f = new IgnoreRightFunction<String, String, String>(new Identity<String>());
         assertNull(f.evaluate(null,null));
         assertNull(f.evaluate(null,"xyzzy"));
         assertEquals("xyzzy",f.evaluate("xyzzy",null));
@@ -71,14 +71,12 @@
     }
 
     public void testEquals() throws Exception {
-        BinaryFunction f = new IgnoreRightFunction(new Constant("xyzzy"));
+        BinaryFunction<String, String, String> f = new IgnoreRightFunction<String, String, String>(Constant.of("xyzzy"));
         assertEquals(f,f);
-        assertObjectsAreEqual(f,new IgnoreRightFunction(new Constant("xyzzy")));
-        assertObjectsAreNotEqual(f,new Constant("x"));
-        assertObjectsAreNotEqual(f,new IgnoreRightFunction(new Constant(null)));
-        assertObjectsAreNotEqual(f,new Constant(null));
-        assertObjectsAreNotEqual(f,new IgnoreRightFunction(null));
-        assertObjectsAreEqual(new IgnoreRightFunction(null),new IgnoreRightFunction(null));
+        assertObjectsAreEqual(f,new IgnoreRightFunction<String, String, String>(Constant.of("xyzzy")));
+        assertObjectsAreNotEqual(f,Constant.of("x"));
+        assertObjectsAreNotEqual(f,new IgnoreRightFunction<String, String, String>(Constant.<String>of(null)));
+        assertObjectsAreNotEqual(f,Constant.of(null));
     }
 
     public void testAdaptNull() throws Exception {
@@ -86,6 +84,6 @@
     }
 
     public void testAdapt() throws Exception {
-        assertNotNull(IgnoreRightFunction.adapt(new Constant("xyzzy")));
+        assertNotNull(IgnoreRightFunction.adapt(Constant.of("xyzzy")));
     }
 }

Modified: commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/adapter/TestLeftBoundFunction.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/adapter/TestLeftBoundFunction.java?rev=665786&r1=665785&r2=665786&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/adapter/TestLeftBoundFunction.java (original)
+++ commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/adapter/TestLeftBoundFunction.java Mon Jun  9 10:17:39 2008
@@ -46,7 +46,7 @@
     // ------------------------------------------------------------------------
 
     protected Object makeFunctor() {
-        return new LeftBoundFunction(new RightIdentity(),"xyzzy");
+        return new LeftBoundFunction<Object, Object, Object>(RightIdentity.FUNCTION,"xyzzy");
     }
 
     // Lifecycle
@@ -64,20 +64,17 @@
     // ------------------------------------------------------------------------
 
     public void testEvaluate() throws Exception {
-        UnaryFunction f = new LeftBoundFunction(new RightIdentity(),"foo");
+        UnaryFunction<Object, Object> f = new LeftBoundFunction<String, Object, Object>(RightIdentity.FUNCTION,"foo");
         assertEquals("xyzzy",f.evaluate("xyzzy"));
     }
 
     public void testEquals() throws Exception {
-        UnaryFunction f = new LeftBoundFunction(new RightIdentity(),"xyzzy");
+        UnaryFunction<Object, Object> f = new LeftBoundFunction<Object, Object, Object>(RightIdentity.FUNCTION,"xyzzy");
         assertEquals(f,f);
-        assertObjectsAreEqual(f,new LeftBoundFunction(new RightIdentity(),"xyzzy"));
-        assertObjectsAreNotEqual(f,new Constant("xyzzy"));
-        assertObjectsAreNotEqual(f,new LeftBoundFunction(new LeftIdentity(),"xyzzy"));
-        assertObjectsAreNotEqual(f,new LeftBoundFunction(new RightIdentity(),"bar"));
-        assertObjectsAreNotEqual(f,new LeftBoundFunction(null,"xyzzy"));
-        assertObjectsAreNotEqual(f,new LeftBoundFunction(new RightIdentity(),null));
-        assertObjectsAreEqual(new LeftBoundFunction(null,null),new LeftBoundFunction(null,null));
+        assertObjectsAreEqual(f,new LeftBoundFunction<Object, Object, Object>(RightIdentity.FUNCTION,"xyzzy"));
+        assertObjectsAreNotEqual(f,Constant.of("xyzzy"));
+        assertObjectsAreNotEqual(f,new LeftBoundFunction<Object, Object, Object>(LeftIdentity.FUNCTION,"xyzzy"));
+        assertObjectsAreNotEqual(f,new LeftBoundFunction<Object, Object, Object>(RightIdentity.FUNCTION,"bar"));
     }
 
     public void testAdaptNull() throws Exception {
@@ -85,7 +82,7 @@
     }
 
     public void testAdapt() throws Exception {
-        assertNotNull(LeftBoundFunction.bind(new RightIdentity(),"xyzzy"));
-        assertNotNull(LeftBoundFunction.bind(new RightIdentity(),null));
+        assertNotNull(LeftBoundFunction.bind(RightIdentity.FUNCTION,"xyzzy"));
+        assertNotNull(LeftBoundFunction.bind(RightIdentity.FUNCTION,null));
     }
 }

Modified: commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/adapter/TestLeftBoundPredicate.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/adapter/TestLeftBoundPredicate.java?rev=665786&r1=665785&r2=665786&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/adapter/TestLeftBoundPredicate.java (original)
+++ commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/adapter/TestLeftBoundPredicate.java Mon Jun  9 10:17:39 2008
@@ -63,7 +63,7 @@
     // ------------------------------------------------------------------------
 
     public void testTest() throws Exception {
-        UnaryPredicate p = new LeftBoundPredicate(new BinaryFunctionBinaryPredicate(new RightIdentity()),"foo");
+        UnaryPredicate p = new LeftBoundPredicate(new BinaryFunctionBinaryPredicate(RightIdentity.FUNCTION),"foo");
         assertEquals(true,p.test(Boolean.TRUE));
         assertEquals(false,p.test(Boolean.FALSE));
     }

Modified: commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/adapter/TestLeftBoundProcedure.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/adapter/TestLeftBoundProcedure.java?rev=665786&r1=665785&r2=665786&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/adapter/TestLeftBoundProcedure.java (original)
+++ commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/adapter/TestLeftBoundProcedure.java Mon Jun  9 10:17:39 2008
@@ -63,7 +63,7 @@
     // ------------------------------------------------------------------------
 
     public void testRun() throws Exception {
-        UnaryProcedure p = new LeftBoundProcedure(new BinaryFunctionBinaryProcedure(new RightIdentity()),"foo");
+        UnaryProcedure p = new LeftBoundProcedure(new BinaryFunctionBinaryProcedure(RightIdentity.FUNCTION),"foo");
         p.run(Boolean.TRUE);
         p.run(Boolean.FALSE);
     }
@@ -73,7 +73,7 @@
         assertEquals(f,f);
         assertObjectsAreEqual(f,new LeftBoundProcedure(new NoOp(),"xyzzy"));
         assertObjectsAreNotEqual(f,new NoOp());
-        assertObjectsAreNotEqual(f,new LeftBoundProcedure(new BinaryFunctionBinaryProcedure(new RightIdentity()),"xyzzy"));
+        assertObjectsAreNotEqual(f,new LeftBoundProcedure(new BinaryFunctionBinaryProcedure(RightIdentity.FUNCTION),"xyzzy"));
         assertObjectsAreNotEqual(f,new LeftBoundProcedure(new NoOp(),"foo"));
         assertObjectsAreNotEqual(f,new LeftBoundProcedure(null,"xyzzy"));
         assertObjectsAreNotEqual(f,new LeftBoundProcedure(new NoOp(),null));

Modified: commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/adapter/TestRightBoundFunction.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/adapter/TestRightBoundFunction.java?rev=665786&r1=665785&r2=665786&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/adapter/TestRightBoundFunction.java (original)
+++ commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/adapter/TestRightBoundFunction.java Mon Jun  9 10:17:39 2008
@@ -46,7 +46,7 @@
     // ------------------------------------------------------------------------
 
     protected Object makeFunctor() {
-        return new RightBoundFunction(new LeftIdentity(),"xyzzy");
+        return new RightBoundFunction<Object, Object, Object>(LeftIdentity.FUNCTION,"xyzzy");
     }
 
     // Lifecycle
@@ -64,20 +64,17 @@
     // ------------------------------------------------------------------------
 
     public void testEvaluate() throws Exception {
-        UnaryFunction f = new RightBoundFunction(new LeftIdentity(),"foo");
+        UnaryFunction<String, String> f = RightBoundFunction.bind(LeftIdentity.<String, String>function(),"foo");
         assertEquals("xyzzy",f.evaluate("xyzzy"));
     }
 
     public void testEquals() throws Exception {
-        UnaryFunction f = new RightBoundFunction(new LeftIdentity(),"xyzzy");
+        UnaryFunction<Object, Object> f = RightBoundFunction.bind(LeftIdentity.FUNCTION,"xyzzy");
         assertEquals(f,f);
-        assertObjectsAreEqual(f,new RightBoundFunction(new LeftIdentity(),"xyzzy"));
-        assertObjectsAreNotEqual(f,new Constant("xyzzy"));
-        assertObjectsAreNotEqual(f,new RightBoundFunction(new RightIdentity(),"xyzzy"));
-        assertObjectsAreNotEqual(f,new RightBoundFunction(new LeftIdentity(),"bar"));
-        assertObjectsAreNotEqual(f,new RightBoundFunction(null,"xyzzy"));
-        assertObjectsAreNotEqual(f,new RightBoundFunction(new LeftIdentity(),null));
-        assertObjectsAreEqual(new RightBoundFunction(null,null),new RightBoundFunction(null,null));
+        assertObjectsAreEqual(f,new RightBoundFunction<Object, Object, Object>(LeftIdentity.FUNCTION,"xyzzy"));
+        assertObjectsAreNotEqual(f,Constant.of("xyzzy"));
+        assertObjectsAreNotEqual(f,new RightBoundFunction<Object, Object, Object>(RightIdentity.FUNCTION,"xyzzy"));
+        assertObjectsAreNotEqual(f,new RightBoundFunction<Object, Object, Object>(LeftIdentity.FUNCTION,"bar"));
     }
 
     public void testAdaptNull() throws Exception {
@@ -85,7 +82,7 @@
     }
 
     public void testAdapt() throws Exception {
-        assertNotNull(RightBoundFunction.bind(new LeftIdentity(),"xyzzy"));
-        assertNotNull(RightBoundFunction.bind(new LeftIdentity(),null));
+        assertNotNull(RightBoundFunction.bind(LeftIdentity.FUNCTION,"xyzzy"));
+        assertNotNull(RightBoundFunction.bind(LeftIdentity.FUNCTION,null));
     }
 }

Modified: commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/adapter/TestRightBoundPredicate.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/adapter/TestRightBoundPredicate.java?rev=665786&r1=665785&r2=665786&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/adapter/TestRightBoundPredicate.java (original)
+++ commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/adapter/TestRightBoundPredicate.java Mon Jun  9 10:17:39 2008
@@ -63,7 +63,7 @@
     // ------------------------------------------------------------------------
 
     public void testTest() throws Exception {
-        UnaryPredicate f = new RightBoundPredicate(new BinaryFunctionBinaryPredicate(new LeftIdentity()),"foo");
+        UnaryPredicate f = new RightBoundPredicate(new BinaryFunctionBinaryPredicate(LeftIdentity.FUNCTION),"foo");
         assertEquals(true,f.test(Boolean.TRUE));
         assertEquals(false,f.test(Boolean.FALSE));
     }

Modified: commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/adapter/TestRightBoundProcedure.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/adapter/TestRightBoundProcedure.java?rev=665786&r1=665785&r2=665786&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/adapter/TestRightBoundProcedure.java (original)
+++ commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/adapter/TestRightBoundProcedure.java Mon Jun  9 10:17:39 2008
@@ -63,7 +63,7 @@
     // ------------------------------------------------------------------------
 
     public void testRun() throws Exception {
-        UnaryProcedure p = new RightBoundProcedure(new BinaryFunctionBinaryProcedure(new LeftIdentity()),"foo");
+        UnaryProcedure p = new RightBoundProcedure(new BinaryFunctionBinaryProcedure(LeftIdentity.FUNCTION),"foo");
         p.run(Boolean.TRUE);
         p.run(Boolean.FALSE);
     }
@@ -73,7 +73,7 @@
         assertEquals(f,f);
         assertObjectsAreEqual(f,new RightBoundProcedure(new NoOp(),"xyzzy"));
         assertObjectsAreNotEqual(f,new NoOp());
-        assertObjectsAreNotEqual(f,new RightBoundProcedure(new BinaryFunctionBinaryProcedure(new LeftIdentity()),"xyzzy"));
+        assertObjectsAreNotEqual(f,new RightBoundProcedure(new BinaryFunctionBinaryProcedure(LeftIdentity.FUNCTION),"xyzzy"));
         assertObjectsAreNotEqual(f,new RightBoundProcedure(new NoOp(),"foo"));
         assertObjectsAreNotEqual(f,new RightBoundProcedure(null,"xyzzy"));
         assertObjectsAreNotEqual(f,new RightBoundProcedure(new NoOp(),null));

Modified: commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/TestAll.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/TestAll.java?rev=665786&r1=665785&r2=665786&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/TestAll.java (original)
+++ commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/TestAll.java Mon Jun  9 10:17:39 2008
@@ -38,7 +38,7 @@
         suite.addTest(TestLeftIdentity.suite());
         suite.addTest(TestRightIdentity.suite());
 
-        suite.addTest(TestIsInstanceOf.suite());
+        suite.addTest(TestIsInstance.suite());
         suite.addTest(TestIsNull.suite());
         suite.addTest(TestIsNotNull.suite());
         suite.addTest(TestIsEqual.suite());

Modified: commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/TestConstant.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/TestConstant.java?rev=665786&r1=665785&r2=665786&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/TestConstant.java (original)
+++ commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/TestConstant.java Mon Jun  9 10:17:39 2008
@@ -111,7 +111,7 @@
     }
 
     public void testConstants() throws Exception {
-        assertEquals(Constant.predicate(true),Constant.instance(Boolean.TRUE));
+        assertEquals(Constant.predicate(true),Constant.of(Boolean.TRUE));
 
         assertEquals(Constant.truePredicate(),Constant.truePredicate());
         assertSame(Constant.truePredicate(),Constant.truePredicate());

Modified: commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/TestIdentity.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/TestIdentity.java?rev=665786&r1=665785&r2=665786&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/TestIdentity.java (original)
+++ commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/TestIdentity.java Mon Jun  9 10:17:39 2008
@@ -97,6 +97,5 @@
 
     public void testConstant() throws Exception {
         assertEquals(Identity.instance(),Identity.instance());
-        assertSame(Identity.instance(),Identity.instance());
     }
 }

Modified: commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/TestIsEqual.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/TestIsEqual.java?rev=665786&r1=665785&r2=665786&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/TestIsEqual.java (original)
+++ commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/TestIsEqual.java Mon Jun  9 10:17:39 2008
@@ -87,6 +87,5 @@
 
     public void testConstant() throws Exception {
         assertEquals(IsEqual.instance(),IsEqual.instance());
-        assertSame(IsEqual.instance(),IsEqual.instance());
     }
 }

Modified: commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/TestIsNotEqual.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/TestIsNotEqual.java?rev=665786&r1=665785&r2=665786&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/TestIsNotEqual.java (original)
+++ commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/TestIsNotEqual.java Mon Jun  9 10:17:39 2008
@@ -86,6 +86,5 @@
 
     public void testConstant() throws Exception {
         assertEquals(IsNotEqual.instance(),IsNotEqual.instance());
-        assertSame(IsNotEqual.instance(),IsNotEqual.instance());
     }
 }

Modified: commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/TestIsNotNull.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/TestIsNotNull.java?rev=665786&r1=665785&r2=665786&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/TestIsNotNull.java (original)
+++ commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/TestIsNotNull.java Mon Jun  9 10:17:39 2008
@@ -77,6 +77,5 @@
 
     public void testConstant() throws Exception {
         assertEquals(IsNotNull.instance(),IsNotNull.instance());
-        assertSame(IsNotNull.instance(),IsNotNull.instance());
     }
 }

Modified: commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/TestIsNull.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/TestIsNull.java?rev=665786&r1=665785&r2=665786&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/TestIsNull.java (original)
+++ commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/TestIsNull.java Mon Jun  9 10:17:39 2008
@@ -84,6 +84,5 @@
 
     public void testConstant() throws Exception {
         assertEquals(IsNull.instance(),IsNull.instance());
-        assertSame(IsNull.instance(),IsNull.instance());
     }
 }

Modified: commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/TestLeftIdentity.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/TestLeftIdentity.java?rev=665786&r1=665785&r2=665786&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/TestLeftIdentity.java (original)
+++ commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/TestLeftIdentity.java Mon Jun  9 10:17:39 2008
@@ -44,7 +44,7 @@
     // ------------------------------------------------------------------------
 
     protected Object makeFunctor() {
-        return new LeftIdentity();
+        return LeftIdentity.FUNCTION;
     }
 
     // Lifecycle
@@ -62,7 +62,7 @@
     // ------------------------------------------------------------------------
 
     public void testEvaluate() throws Exception {
-        BinaryFunction f = new LeftIdentity();
+        BinaryFunction<Object, Object, Object> f = LeftIdentity.FUNCTION;
         assertNull(f.evaluate(null,null));
         assertNull(f.evaluate(null,"xyzzy"));
         assertEquals("xyzzy",f.evaluate("xyzzy","abcdefg"));
@@ -74,35 +74,27 @@
     }
 
     public void testTest() throws Exception {
-        BinaryPredicate p = new LeftIdentity();
+        BinaryPredicate<Boolean, Object> p = LeftIdentity.PREDICATE;
         assertTrue(p.test(Boolean.TRUE,null));
         assertTrue(!p.test(Boolean.FALSE,null));
         try {
-            p.test("true",null);
-            fail("Expected ClassCastException");
-        } catch(ClassCastException e) {
-            // expected
-        }
-        try {
-            p.test(null,null);
+            p.test(null, null);
             fail("Expected NullPointerException");
-        } catch(NullPointerException e) {
-            // expected
+        } catch (NullPointerException npe) {
         }
     }
 
     public void testEquals() throws Exception {
-        BinaryFunction f = new LeftIdentity();
+        BinaryFunction<Object, Object, Object> f = LeftIdentity.<Object, Object>function();
         assertEquals(f,f);
-        assertObjectsAreEqual(f,new LeftIdentity());
-        assertObjectsAreEqual(f,LeftIdentity.instance());
-        assertObjectsAreNotEqual(f,new RightIdentity());
-        assertObjectsAreNotEqual(f,new Constant("abcde"));
-        assertObjectsAreNotEqual(f,new Constant(true));
+        assertObjectsAreEqual(f,LeftIdentity.FUNCTION);
+        assertObjectsAreEqual(f,LeftIdentity.FUNCTION);
+        assertObjectsAreNotEqual(f,RightIdentity.FUNCTION);
+        assertObjectsAreNotEqual(f,Constant.of("abcde"));
+        assertObjectsAreNotEqual(f,Constant.of(true));
     }
 
     public void testConstant() throws Exception {
-        assertEquals(LeftIdentity.instance(),LeftIdentity.instance());
-        assertSame(LeftIdentity.instance(),LeftIdentity.instance());
+        assertEquals(LeftIdentity.function(),LeftIdentity.function());
     }
 }

Modified: commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/TestRightIdentity.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/TestRightIdentity.java?rev=665786&r1=665785&r2=665786&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/TestRightIdentity.java (original)
+++ commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/TestRightIdentity.java Mon Jun  9 10:17:39 2008
@@ -44,7 +44,7 @@
     // ------------------------------------------------------------------------
 
     protected Object makeFunctor() {
-        return new RightIdentity();
+        return RightIdentity.FUNCTION;
     }
 
     // Lifecycle
@@ -62,7 +62,7 @@
     // ------------------------------------------------------------------------
 
     public void testEvaluate() throws Exception {
-        BinaryFunction f = new RightIdentity();
+        BinaryFunction<Object, Object, Object> f = RightIdentity.FUNCTION;
         assertNull(f.evaluate(null,null));
         assertNull(f.evaluate("xyzzy",null));
         assertEquals("xyzzy",f.evaluate("abcdefg","xyzzy"));
@@ -74,16 +74,10 @@
     }
 
     public void testTest() throws Exception {
-        BinaryPredicate p = new RightIdentity();
+        BinaryPredicate<Object, Boolean> p = RightIdentity.PREDICATE;
         assertTrue(p.test(null,Boolean.TRUE));
         assertTrue(!p.test(null,Boolean.FALSE));
         try {
-            p.test(null,"true");
-            fail("Expected ClassCastException");
-        } catch(ClassCastException e) {
-            // expected
-        }
-        try {
             p.test(null,null);
             fail("Expected NullPointerException");
         } catch(NullPointerException e) {
@@ -92,18 +86,16 @@
     }
 
     public void testEquals() throws Exception {
-        BinaryFunction f = new RightIdentity();
+        BinaryFunction<Object, Object, Object> f = RightIdentity.FUNCTION;
         assertEquals(f,f);
-        assertObjectsAreEqual(f,new RightIdentity());
-        assertObjectsAreEqual(f,RightIdentity.instance());
-        assertObjectsAreNotEqual(f,new Identity());
-        assertObjectsAreNotEqual(f,new LeftIdentity());
-        assertObjectsAreNotEqual(f,new Constant(true));
-        assertObjectsAreNotEqual(f,new Constant("abcde"));
+        assertObjectsAreEqual(f,RightIdentity.function());
+        assertObjectsAreNotEqual(f,new Identity<Object>());
+        assertObjectsAreNotEqual(f,LeftIdentity.function());
+        assertObjectsAreNotEqual(f,Constant.TRUE);
+        assertObjectsAreNotEqual(f,Constant.of("abcde"));
     }
 
     public void testConstant() throws Exception {
-        assertEquals(RightIdentity.instance(),RightIdentity.instance());
-        assertSame(RightIdentity.instance(),RightIdentity.instance());
+        assertEquals(RightIdentity.function(),RightIdentity.function());
     }
 }

Modified: commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/collection/TestFilteredIterator.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/collection/TestFilteredIterator.java?rev=665786&r1=665785&r2=665786&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/collection/TestFilteredIterator.java (original)
+++ commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/collection/TestFilteredIterator.java Mon Jun  9 10:17:39 2008
@@ -33,6 +33,7 @@
  * @version $Revision$ $Date$
  * @author Rodney Waldhoff
  */
+@SuppressWarnings("unchecked")
 public class TestFilteredIterator extends BaseFunctorTest {
 
     // Conventional

Modified: commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/collection/TestIsElementOf.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/collection/TestIsElementOf.java?rev=665786&r1=665785&r2=665786&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/collection/TestIsElementOf.java (original)
+++ commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/collection/TestIsElementOf.java Mon Jun  9 10:17:39 2008
@@ -30,6 +30,7 @@
  * @author Rodney Waldhoff
  * @author Jason Horman
  */
+@SuppressWarnings("unchecked")
 public class TestIsElementOf extends BaseFunctorTest {
 
     // Conventional
@@ -111,8 +112,8 @@
     public void testTestNull() {
         try {
             IsElementOf.instance().test(new Integer(5),null);
-            fail("expected NullPointerException");
-        } catch (NullPointerException e) {
+            fail("expected IllegalArgumentException");
+        } catch (IllegalArgumentException e) {
             // expected
         }
     }

Modified: commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/collection/TestIsEmpty.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/collection/TestIsEmpty.java?rev=665786&r1=665785&r2=665786&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/collection/TestIsEmpty.java (original)
+++ commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/collection/TestIsEmpty.java Mon Jun  9 10:17:39 2008
@@ -36,6 +36,7 @@
  * @version $Revision$ $Date$
  * @author Rodney Waldhoff
  */
+@SuppressWarnings("unchecked")
 public class TestIsEmpty extends BaseFunctorTest {
 
     // Conventional
@@ -90,8 +91,8 @@
     public void testTestNull() throws Exception {
         try {
             IsEmpty.instance().test(null);
-            fail("Expected NullPointerException");
-        } catch(NullPointerException e) {
+            fail("Expected IllegalArgumentException");
+        } catch(IllegalArgumentException e) {
             // expected
         }
     }

Modified: commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/collection/TestSize.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/collection/TestSize.java?rev=665786&r1=665785&r2=665786&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/collection/TestSize.java (original)
+++ commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/collection/TestSize.java Mon Jun  9 10:17:39 2008
@@ -33,6 +33,7 @@
  * @version $Revision$ $Date$
  * @author Rodney Waldhoff
  */
+@SuppressWarnings("unchecked")
 public class TestSize extends BaseFunctorTest {
 
     // Conventional
@@ -93,8 +94,8 @@
     public void testEvaluateNull() throws Exception {
         try {
             Size.instance().evaluate(null);
-            fail("Expected NullPointerException");
-        } catch(NullPointerException e) {
+            fail("Expected IllegalArgumentException");
+        } catch(IllegalArgumentException e) {
             // expected
         }
     }
@@ -102,8 +103,8 @@
     public void testEvaluateNonCollection() throws Exception {
         try {
             Size.instance().evaluate(new Integer(3));
-            fail("Expected ClassCastException");
-        } catch(ClassCastException e) {
+            fail("Expected IllegalArgumentException");
+        } catch(IllegalArgumentException e) {
             // expected
         }
     }

Modified: commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/collection/TestTransformedIterator.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/collection/TestTransformedIterator.java?rev=665786&r1=665785&r2=665786&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/collection/TestTransformedIterator.java (original)
+++ commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/collection/TestTransformedIterator.java Mon Jun  9 10:17:39 2008
@@ -33,6 +33,7 @@
  * @version $Revision$ $Date$
  * @author Rodney Waldhoff
  */
+@SuppressWarnings("unchecked")
 public class TestTransformedIterator extends BaseFunctorTest {
 
     // Conventional
@@ -168,7 +169,7 @@
 
     public void testTransformWithNullPredicateReturnsIdentity() {
         Iterator iter = list.iterator();
-        assertSame(iter,TransformedIterator.transform(iter,null));
+        assertSame(iter,TransformedIterator.maybeTransform(iter,null));
     }
 
     public void testConstructorProhibitsNull() {

Modified: commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/comparator/TestComparatorFunction.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/comparator/TestComparatorFunction.java?rev=665786&r1=665785&r2=665786&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/comparator/TestComparatorFunction.java (original)
+++ commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/comparator/TestComparatorFunction.java Mon Jun  9 10:17:39 2008
@@ -51,7 +51,7 @@
     // ------------------------------------------------------------------------
 
     public void testEvaluate() {
-        ComparatorFunction f = new ComparatorFunction();
+        ComparatorFunction f = ComparatorFunction.instance();
 
         assertTrue(((Integer)(f.evaluate(new Integer(Integer.MAX_VALUE),new Integer(Integer.MAX_VALUE)))).intValue() == 0);
         assertTrue(((Integer)(f.evaluate(new Integer(Integer.MAX_VALUE),new Integer(1)))).intValue() > 0);
@@ -85,10 +85,8 @@
     }
 
     public void testEquals() {
-        ComparatorFunction f = new ComparatorFunction();
+        ComparatorFunction f = ComparatorFunction.instance();
         assertObjectsAreEqual(f,f);
-        assertObjectsAreEqual(f,new ComparatorFunction(null));
-        assertObjectsAreEqual(new ComparatorFunction(null),new ComparatorFunction(null));
         assertObjectsAreEqual(f,new ComparatorFunction(new ComparableComparator()));
         assertObjectsAreNotEqual(f,new ComparatorFunction(Collections.reverseOrder()));
     }

Modified: commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/comparator/TestIsEquivalent.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/comparator/TestIsEquivalent.java?rev=665786&r1=665785&r2=665786&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/comparator/TestIsEquivalent.java (original)
+++ commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/comparator/TestIsEquivalent.java Mon Jun  9 10:17:39 2008
@@ -42,7 +42,7 @@
     // ------------------------------------------------------------------------
 
     protected Object makeFunctor() {
-        return new IsEquivalent();
+        return IsEquivalent.instance();
     }
 
     // Lifecycle
@@ -60,7 +60,7 @@
     // ------------------------------------------------------------------------
 
     public void testTest() throws Exception {
-        IsEquivalent p = new IsEquivalent();
+        IsEquivalent p = IsEquivalent.instance();
         assertTrue(!p.test(new Integer(2),new Integer(4)));
         assertTrue(!p.test(new Integer(3),new Integer(4)));
         assertTrue(p.test(new Integer(4),new Integer(4)));
@@ -74,14 +74,11 @@
     }
 
     public void testEquals() throws Exception {
-        IsEquivalent p = new IsEquivalent();
+        IsEquivalent p = IsEquivalent.instance();
         assertEquals(p,p);
 
-        assertObjectsAreEqual(p,new IsEquivalent());
-        assertObjectsAreEqual(p,new IsEquivalent(null));
-        assertObjectsAreEqual(p,new IsEquivalent(new ComparableComparator()));
         assertObjectsAreEqual(p,IsEquivalent.instance());
-        assertSame(IsEquivalent.instance(),IsEquivalent.instance());
+        assertObjectsAreEqual(p,new IsEquivalent(new ComparableComparator()));
         assertObjectsAreNotEqual(p,new Constant(false));
     }
 

Modified: commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/comparator/TestIsGreaterThan.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/comparator/TestIsGreaterThan.java?rev=665786&r1=665785&r2=665786&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/comparator/TestIsGreaterThan.java (original)
+++ commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/comparator/TestIsGreaterThan.java Mon Jun  9 10:17:39 2008
@@ -78,10 +78,8 @@
         assertEquals(p,p);
 
         assertObjectsAreEqual(p,new IsGreaterThan());
-        assertObjectsAreEqual(p,new IsGreaterThan(null));
         assertObjectsAreEqual(p,new IsGreaterThan(new ComparableComparator()));
         assertObjectsAreEqual(p,IsGreaterThan.instance());
-        assertSame(IsGreaterThan.instance(),IsGreaterThan.instance());
         assertObjectsAreNotEqual(p,new Constant(false));
     }
 

Modified: commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/comparator/TestIsGreaterThanOrEqual.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/comparator/TestIsGreaterThanOrEqual.java?rev=665786&r1=665785&r2=665786&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/comparator/TestIsGreaterThanOrEqual.java (original)
+++ commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/comparator/TestIsGreaterThanOrEqual.java Mon Jun  9 10:17:39 2008
@@ -78,10 +78,8 @@
         assertEquals(p,p);
 
         assertObjectsAreEqual(p,new IsGreaterThanOrEqual());
-        assertObjectsAreEqual(p,new IsGreaterThanOrEqual(null));
         assertObjectsAreEqual(p,new IsGreaterThanOrEqual(new ComparableComparator()));
         assertObjectsAreEqual(p,IsGreaterThanOrEqual.instance());
-        assertSame(IsGreaterThanOrEqual.instance(),IsGreaterThanOrEqual.instance());
         assertObjectsAreNotEqual(p,new Constant(false));
     }
 

Modified: commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/comparator/TestIsLessThan.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/comparator/TestIsLessThan.java?rev=665786&r1=665785&r2=665786&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/comparator/TestIsLessThan.java (original)
+++ commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/comparator/TestIsLessThan.java Mon Jun  9 10:17:39 2008
@@ -78,10 +78,8 @@
         assertEquals(p,p);
 
         assertObjectsAreEqual(p,new IsLessThan());
-        assertObjectsAreEqual(p,new IsLessThan(null));
         assertObjectsAreEqual(p,new IsLessThan(new ComparableComparator()));
         assertObjectsAreEqual(p,IsLessThan.instance());
-        assertSame(IsLessThan.instance(),IsLessThan.instance());
         assertObjectsAreNotEqual(p,new Constant(false));
     }
 

Modified: commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/comparator/TestIsLessThanOrEqual.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/comparator/TestIsLessThanOrEqual.java?rev=665786&r1=665785&r2=665786&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/comparator/TestIsLessThanOrEqual.java (original)
+++ commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/comparator/TestIsLessThanOrEqual.java Mon Jun  9 10:17:39 2008
@@ -78,10 +78,8 @@
         assertEquals(p,p);
 
         assertObjectsAreEqual(p,new IsLessThanOrEqual());
-        assertObjectsAreEqual(p,new IsLessThanOrEqual(null));
         assertObjectsAreEqual(p,new IsLessThanOrEqual(new ComparableComparator()));
         assertObjectsAreEqual(p,IsLessThanOrEqual.instance());
-        assertSame(IsLessThanOrEqual.instance(),IsLessThanOrEqual.instance());
         assertObjectsAreNotEqual(p,new Constant(false));
     }
 

Modified: commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/comparator/TestIsNotEquivalent.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/comparator/TestIsNotEquivalent.java?rev=665786&r1=665785&r2=665786&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/comparator/TestIsNotEquivalent.java (original)
+++ commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/comparator/TestIsNotEquivalent.java Mon Jun  9 10:17:39 2008
@@ -42,7 +42,7 @@
     // ------------------------------------------------------------------------
 
     protected Object makeFunctor() {
-        return new IsNotEquivalent();
+        return IsNotEquivalent.instance();
     }
 
     // Lifecycle
@@ -60,7 +60,7 @@
     // ------------------------------------------------------------------------
 
     public void testTest() throws Exception {
-        IsNotEquivalent p = new IsNotEquivalent();
+        IsNotEquivalent p = IsNotEquivalent.instance();
         assertTrue(p.test(new Integer(2),new Integer(4)));
         assertTrue(p.test(new Integer(3),new Integer(4)));
         assertTrue(!p.test(new Integer(4),new Integer(4)));
@@ -74,14 +74,11 @@
     }
 
     public void testEquals() throws Exception {
-        IsNotEquivalent p = new IsNotEquivalent();
+        IsNotEquivalent p = IsNotEquivalent.instance();
         assertEquals(p,p);
 
-        assertObjectsAreEqual(p,new IsNotEquivalent());
-        assertObjectsAreEqual(p,new IsNotEquivalent(null));
         assertObjectsAreEqual(p,new IsNotEquivalent(new ComparableComparator()));
         assertObjectsAreEqual(p,IsNotEquivalent.instance());
-        assertSame(IsNotEquivalent.instance(),IsNotEquivalent.instance());
         assertObjectsAreNotEqual(p,new Constant(false));
     }
 

Modified: commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/comparator/TestMax.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/comparator/TestMax.java?rev=665786&r1=665785&r2=665786&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/comparator/TestMax.java (original)
+++ commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/comparator/TestMax.java Mon Jun  9 10:17:39 2008
@@ -44,7 +44,7 @@
     // ------------------------------------------------------------------------
 
     protected Object makeFunctor() {
-        return new Max();
+        return Max.instance();
     }
 
     private Integer MIN = new Integer(Integer.MIN_VALUE);
@@ -56,7 +56,7 @@
     // ------------------------------------------------------------------------
 
     public void testEvaluate() {
-        Max f = new Max();
+        Max f = Max.instance();
         assertEquals(ONE,f.evaluate(ONE,ONE));
         assertEquals(ONE,f.evaluate(ZERO,ONE));
         assertEquals(ONE,f.evaluate(ONE,ZERO));
@@ -66,11 +66,9 @@
     }
 
     public void testEquals() {
-        Max f = new Max();
+        Max f = Max.instance();
         assertObjectsAreEqual(f,f);
         assertObjectsAreEqual(f,Max.instance());
-        assertObjectsAreEqual(f,new Max(null));
-        assertObjectsAreEqual(new Max(null),new Max(null));
         assertObjectsAreEqual(f,new Max(new ComparableComparator()));
         assertObjectsAreNotEqual(f,new Max(Collections.reverseOrder()));
     }

Modified: commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/comparator/TestMin.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/comparator/TestMin.java?rev=665786&r1=665785&r2=665786&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/comparator/TestMin.java (original)
+++ commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/comparator/TestMin.java Mon Jun  9 10:17:39 2008
@@ -44,7 +44,7 @@
     // ------------------------------------------------------------------------
 
     protected Object makeFunctor() {
-        return new Min();
+        return Min.instance();
     }
 
     private Integer MIN = new Integer(Integer.MIN_VALUE);
@@ -56,7 +56,7 @@
     // ------------------------------------------------------------------------
 
     public void testEvaluate() {
-        Min f = new Min();
+        Min f = Min.instance();
         assertEquals(ONE,f.evaluate(ONE,ONE));
         assertEquals(ZERO,f.evaluate(ZERO,ONE));
         assertEquals(ZERO,f.evaluate(ONE,ZERO));
@@ -66,11 +66,9 @@
     }
 
     public void testEquals() {
-        Min f = new Min();
+        Min f = Min.instance();
         assertObjectsAreEqual(f,f);
         assertObjectsAreEqual(f,Min.instance());
-        assertObjectsAreEqual(f,new Min(null));
-        assertObjectsAreEqual(new Min(null),new Min(null));
         assertObjectsAreEqual(f,new Min(new ComparableComparator()));
         assertObjectsAreNotEqual(f,new Min(Collections.reverseOrder()));
     }

Modified: commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestBinaryAnd.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestBinaryAnd.java?rev=665786&r1=665785&r2=665786&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestBinaryAnd.java (original)
+++ commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestBinaryAnd.java Mon Jun  9 10:17:39 2008
@@ -44,7 +44,7 @@
     // ------------------------------------------------------------------------
 
     protected Object makeFunctor() {
-        return new BinaryAnd(new Constant(true),new Constant(true));
+        return new BinaryAnd<Object, Object>(Constant.TRUE, Constant.TRUE);
     }
 
     // Lifecycle
@@ -62,68 +62,68 @@
     // ------------------------------------------------------------------------
 
     public void testTrue() throws Exception {
-        assertTrue((new BinaryAnd()).test("xyzzy",new Integer(3)));
-        assertTrue((new BinaryAnd(new Constant(true))).test("xyzzy",new Integer(3)));
-        assertTrue((new BinaryAnd(new Constant(true),new Constant(true))).test("xyzzy",new Integer(3)));
-        assertTrue((new BinaryAnd(new Constant(true),new Constant(true),new Constant(true))).test("xyzzy",new Integer(3)));
+        assertTrue((new BinaryAnd<String, Integer>()).test("xyzzy",3));
+        assertTrue((new BinaryAnd<String, Integer>(Constant.TRUE)).test("xyzzy",3));
+        assertTrue((new BinaryAnd<String, Integer>(Constant.TRUE,Constant.TRUE)).test("xyzzy",3));
+        assertTrue((new BinaryAnd<String, Integer>(Constant.TRUE,Constant.TRUE,Constant.TRUE)).test("xyzzy",3));
 
-        BinaryAnd p = new BinaryAnd(new Constant(true));
-        assertTrue(p.test("xyzzy",new Integer(3)));
+        BinaryAnd<String, Integer> p = new BinaryAnd<String, Integer>(Constant.TRUE);
+        assertTrue(p.test("xyzzy",3));
         for (int i=0;i<10;i++) {
-            p.and(new Constant(true));
-            assertTrue(p.test("xyzzy",new Integer(3)));
+            p.and(Constant.TRUE);
+            assertTrue(p.test("xyzzy",3));
         }
 
-        BinaryAnd q = new BinaryAnd(new Constant(true));
-        assertTrue(q.test("xyzzy",new Integer(3)));
+        BinaryAnd<String, Integer> q = new BinaryAnd<String, Integer>(Constant.TRUE);
+        assertTrue(q.test("xyzzy",3));
         for (int i=0;i<10;i++) {
-            q.and(new Constant(true));
-            assertTrue(q.test("xyzzy",new Integer(3)));
+            q.and(Constant.TRUE);
+            assertTrue(q.test("xyzzy",3));
         }
 
-        BinaryAnd r = new BinaryAnd(p,q);
-        assertTrue(r.test("xyzzy",new Integer(3)));
+        BinaryAnd<String, Integer> r = new BinaryAnd<String, Integer>(p,q);
+        assertTrue(r.test("xyzzy",3));
     }
 
     public void testFalse() throws Exception {
-        assertTrue(!(new BinaryAnd(new Constant(false))).test("xyzzy",new Integer(3)));
-        assertTrue(!(new BinaryAnd(new Constant(true),new Constant(false))).test("xyzzy",new Integer(3)));
-        assertTrue(!(new BinaryAnd(new Constant(true),new Constant(true),new Constant(false))).test("xyzzy",new Integer(3)));
+        assertTrue(!(new BinaryAnd<String, Integer>(Constant.FALSE)).test("xyzzy",3));
+        assertTrue(!(new BinaryAnd<String, Integer>(Constant.TRUE,Constant.FALSE)).test("xyzzy",3));
+        assertTrue(!(new BinaryAnd<String, Integer>(Constant.TRUE,Constant.TRUE,Constant.FALSE)).test("xyzzy",3));
 
-        BinaryAnd p = new BinaryAnd(new Constant(false));
-        assertTrue(!p.test("xyzzy",new Integer(3)));
+        BinaryAnd<String, Integer> p = new BinaryAnd<String, Integer>(Constant.FALSE);
+        assertTrue(!p.test("xyzzy",3));
         for (int i=0;i<10;i++) {
-            p.and(new Constant(false));
-            assertTrue(!p.test("xyzzy",new Integer(3)));
+            p.and(Constant.FALSE);
+            assertTrue(!p.test("xyzzy",3));
         }
 
-        BinaryAnd q = new BinaryAnd(new Constant(true));
-        assertTrue(q.test("xyzzy",new Integer(3)));
+        BinaryAnd<String, Integer> q = new BinaryAnd<String, Integer>(Constant.TRUE);
+        assertTrue(q.test("xyzzy",3));
         for (int i=0;i<10;i++) {
-            q.and(new Constant(true));
-            assertTrue(q.test("xyzzy",new Integer(3)));
+            q.and(Constant.TRUE);
+            assertTrue(q.test("xyzzy",3));
         }
 
-        BinaryAnd r = new BinaryAnd(p,q);
-        assertTrue(!r.test("xyzzy",new Integer(3)));
+        BinaryAnd<String, Integer> r = new BinaryAnd<String, Integer>(p,q);
+        assertTrue(!r.test("xyzzy",3));
     }
 
     public void testDuplicateAdd() throws Exception {
-        BinaryPredicate p = new Constant(true);
-        BinaryAnd q = new BinaryAnd(p,p);
-        assertTrue(q.test("xyzzy",new Integer(3)));
+        BinaryPredicate<Object, Object> p = Constant.TRUE;
+        BinaryAnd<String, Integer> q = new BinaryAnd<String, Integer>(p,p);
+        assertTrue(q.test("xyzzy",3));
         for (int i=0;i<10;i++) {
             q.and(p);
-            assertTrue(q.test("xyzzy",new Integer(3)));
+            assertTrue(q.test("xyzzy",3));
         }
     }
 
     public void testEquals() throws Exception {
-        BinaryAnd p = new BinaryAnd();
+        BinaryAnd<Object, Object> p = new BinaryAnd<Object, Object>();
         assertEquals(p,p);
-        BinaryAnd q = new BinaryAnd();
+        BinaryAnd<Object, Object> q = new BinaryAnd<Object, Object>();
         assertObjectsAreEqual(p,q);
-        BinaryOr r = new BinaryOr();
+        BinaryOr<Object, Object> r = new BinaryOr<Object, Object>();
         assertObjectsAreNotEqual(p,r);
 
         for (int i=0;i<3;i++) {
@@ -131,9 +131,9 @@
             assertObjectsAreNotEqual(p,q);
             q.and(Constant.truePredicate());
             assertObjectsAreEqual(p,q);
-            p.and(new BinaryAnd(Constant.truePredicate(),Constant.falsePredicate()));
+            p.and(new BinaryAnd<Object, Object>(Constant.truePredicate(),Constant.falsePredicate()));
             assertObjectsAreNotEqual(p,q);
-            q.and(new BinaryAnd(Constant.truePredicate(),Constant.falsePredicate()));
+            q.and(new BinaryAnd<Object, Object>(Constant.truePredicate(),Constant.falsePredicate()));
             assertObjectsAreEqual(p,q);
         }
 

Modified: commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestBinaryCompositeBinaryFunction.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestBinaryCompositeBinaryFunction.java?rev=665786&r1=665785&r2=665786&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestBinaryCompositeBinaryFunction.java (original)
+++ commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestBinaryCompositeBinaryFunction.java Mon Jun  9 10:17:39 2008
@@ -46,10 +46,10 @@
     // ------------------------------------------------------------------------
 
     protected Object makeFunctor() {
-        return new BinaryCompositeBinaryFunction(
-            new RightIdentity(),
-            new Constant("left"),
-            new RightIdentity());
+        return new BinaryCompositeBinaryFunction<Object, Object, Object>(
+            RightIdentity.FUNCTION,
+            Constant.of("left"),
+            RightIdentity.FUNCTION);
     }
 
     // Lifecycle
@@ -66,42 +66,59 @@
     // Tests
     // ------------------------------------------------------------------------
 
-    public void testEvaluate() throws Exception {
+    @SuppressWarnings("unchecked")
+    public void testEvaluateRaw() throws Exception {
         BinaryFunction f = new BinaryCompositeBinaryFunction(
-            new RightIdentity(),
-            new Constant("K"),
-            new RightIdentity());
+                RightIdentity.FUNCTION,
+                Constant.of("K"),
+                RightIdentity.FUNCTION);
+        assertEquals("right",f.evaluate("left","right"));
+        assertNull("right",f.evaluate("left",null));
+        assertEquals("right",f.evaluate(null,"right"));
+    }
+
+    public void testEvaluate() throws Exception {
+        BinaryFunction<String, String, String> f = new BinaryCompositeBinaryFunction<String, String, String>(
+                RightIdentity.<String, String>function(),
+                Constant.of("K"),
+                RightIdentity.<String, String>function());
+        assertEquals("right",f.evaluate("left","right"));
+        assertNull("right",f.evaluate("left",null));
+        assertEquals("right",f.evaluate(null,"right"));
+    }
+    
+    public void testEvaluateObject() throws Exception {
+        BinaryFunction<Object, Object, Object> f = new BinaryCompositeBinaryFunction<Object, Object, Object>(
+                RightIdentity.FUNCTION,
+                Constant.of("K"),
+                RightIdentity.FUNCTION);
         assertEquals("right",f.evaluate("left","right"));
         assertNull("right",f.evaluate("left",null));
         assertEquals("right",f.evaluate(null,"right"));
     }
 
     public void testEquals() throws Exception {
-        BinaryFunction f = new BinaryCompositeBinaryFunction(
-            new LeftIdentity(),
-            new Constant("left"),
-            new Constant("right"));
+        BinaryFunction<Object, Object, Object> f = new BinaryCompositeBinaryFunction<Object, Object, Object>(
+            LeftIdentity.FUNCTION,
+            Constant.of("left"),
+            Constant.of("right"));
         assertEquals(f,f);
-        assertObjectsAreEqual(f,new BinaryCompositeBinaryFunction(
-            new LeftIdentity(),
-            new Constant("left"),
-            new Constant("right")));
-        assertObjectsAreNotEqual(f,new BinaryCompositeBinaryFunction(
-            new RightIdentity(),
-            new Constant("left"),
-            new Constant("right")));
-        assertObjectsAreNotEqual(f,new BinaryCompositeBinaryFunction(
-            new LeftIdentity(),
-            new RightIdentity(),
-            new Constant("right")));
-        assertObjectsAreNotEqual(f,new BinaryCompositeBinaryFunction(
-            new LeftIdentity(),
-            new Constant("left"),
-            new RightIdentity()));
-        assertObjectsAreNotEqual(f,new BinaryCompositeBinaryFunction(null,null,null));
-        assertObjectsAreEqual(
-            new BinaryCompositeBinaryFunction(null,null,null),
-            new BinaryCompositeBinaryFunction(null,null,null));
+        assertObjectsAreEqual(f,new BinaryCompositeBinaryFunction<Object, Object, Object>(
+                LeftIdentity.FUNCTION,
+                Constant.of("left"),
+            Constant.of("right")));
+        assertObjectsAreNotEqual(f,new BinaryCompositeBinaryFunction<Object, Object, Object>(
+            RightIdentity.FUNCTION,
+            Constant.of("left"),
+            Constant.of("right")));
+        assertObjectsAreNotEqual(f,new BinaryCompositeBinaryFunction<Object, Object, Object>(
+            RightIdentity.FUNCTION,
+            RightIdentity.FUNCTION,
+            Constant.of("right")));
+        assertObjectsAreNotEqual(f,new BinaryCompositeBinaryFunction<Object, Object, Object>(
+            LeftIdentity.FUNCTION,
+            Constant.of("left"),
+            RightIdentity.FUNCTION));
     }
 
 }

Modified: commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestBinarySequence.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestBinarySequence.java?rev=665786&r1=665785&r2=665786&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestBinarySequence.java (original)
+++ commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestBinarySequence.java Mon Jun  9 10:17:39 2008
@@ -30,6 +30,7 @@
  * @version $Revision$ $Date$
  * @author Rodney Waldhoff
  */
+@SuppressWarnings("unchecked")
 public class TestBinarySequence extends BaseFunctorTest {
 
     // Conventional

Modified: commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestComposite.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestComposite.java?rev=665786&r1=665785&r2=665786&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestComposite.java (original)
+++ commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestComposite.java Mon Jun  9 10:17:39 2008
@@ -56,8 +56,8 @@
     }
 
     public void testBinaryMethods() {
-        assertNotNull(Composite.function(LeftIdentity.instance(),LeftIdentity.instance(),LeftIdentity.instance()));
-        assertNotNull(Composite.predicate(IsGreaterThan.instance(),Identity.instance(),Identity.instance()));
-        assertNotNull(Composite.function(LeftIdentity.instance(),Identity.instance(),Identity.instance()));
+        assertNotNull(Composite.function(LeftIdentity.function(),LeftIdentity.function(),LeftIdentity.function()));
+        assertNotNull(Composite.predicate(IsGreaterThan.instance(),new Identity<Comparable<?>>(),new Identity<Comparable<?>>()));
+        assertNotNull(Composite.function(LeftIdentity.function(),Identity.instance(),Identity.instance()));
     }
 }

Modified: commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestCompositeUnaryFunction.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestCompositeUnaryFunction.java?rev=665786&r1=665785&r2=665786&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestCompositeUnaryFunction.java (original)
+++ commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestCompositeUnaryFunction.java Mon Jun  9 10:17:39 2008
@@ -22,7 +22,6 @@
 import org.apache.commons.functor.BaseFunctorTest;
 import org.apache.commons.functor.UnaryFunction;
 import org.apache.commons.functor.core.Constant;
-import org.apache.commons.functor.core.Identity;
 
 /**
  * @version $Revision$ $Date$
@@ -45,7 +44,7 @@
     // ------------------------------------------------------------------------
 
     protected Object makeFunctor() {
-        return new CompositeUnaryFunction(new Identity(),new Constant(new Integer(3)));
+        return Composite.function(Constant.of(3));
     }
 
     // Lifecycle
@@ -63,51 +62,45 @@
     // ------------------------------------------------------------------------
 
     public void testEvaluate() throws Exception {
-        // empty composite acts like identity function
-        assertEquals("xyzzy",(new CompositeUnaryFunction()).evaluate("xyzzy"));
-        assertNull(null,(new CompositeUnaryFunction()).evaluate(null));
 
-        assertEquals(new Integer(4),(new CompositeUnaryFunction(new Constant(new Integer(4)))).evaluate(null));
+        assertEquals(new Integer(4),(new CompositeUnaryFunction<Object, Integer>(Constant.of(4))).evaluate(null));
 
-        assertEquals(new Integer(4),(new CompositeUnaryFunction(new Constant(new Integer(4)),new Constant(new Integer(3)))).evaluate("xyzzy"));
-        assertEquals(new Integer(3),(new CompositeUnaryFunction(new Constant(new Integer(3)),new Constant(new Integer(4)))).evaluate("xyzzy"));
+        assertEquals(new Integer(4),(Composite.function(Constant.of(4)).of(Constant.of(3)).evaluate("xyzzy")));
+        assertEquals(new Integer(3),(new CompositeUnaryFunction<Object, Integer>(Constant.of(3)).of(Constant.of(4)).evaluate("xyzzy")));
     }
 
     public void testOf() throws Exception {
-        CompositeUnaryFunction f = new CompositeUnaryFunction();
-        assertNull(f.evaluate(null));
-        for (int i=0;i<10;i++) {
-            f.of(new UnaryFunction() {
-                    public Object evaluate(Object obj) {
-                        if (obj instanceof Integer) {
-                            return new Integer((((Integer) obj).intValue())+1);
-                        } else {
-                            return new Integer(1);
-                        }
-                    }
-                });
-            assertEquals(new Integer(i+1),f.evaluate(null));
+        UnaryFunction<Object, Integer> uf = new UnaryFunction<Object, Integer>() {
+            public Integer evaluate(Object obj) {
+                if (obj instanceof Integer) {
+                    return (((Integer) obj).intValue()) + 1;
+                } else {
+                    return 1;
+                }
+            }
+        };
+        CompositeUnaryFunction<Object, Integer> f = null;
+        for (int i = 0; i < 10; i++) {
+            f = f == null ? new CompositeUnaryFunction<Object, Integer>(uf) : f.of(uf);
+            assertEquals(Integer.valueOf(i+1),f.evaluate(null));
         }
     }
 
     public void testEquals() throws Exception {
-        CompositeUnaryFunction f = new CompositeUnaryFunction();
+        CompositeUnaryFunction<Object, String> f = new CompositeUnaryFunction<Object, String>(Constant.of("x"));
         assertEquals(f,f);
-        CompositeUnaryFunction g = new CompositeUnaryFunction();
+        
+        CompositeUnaryFunction<Object, String> g = new CompositeUnaryFunction<Object, String>(Constant.of("x"));
         assertObjectsAreEqual(f,g);
 
         for (int i=0;i<3;i++) {
-            f.of(new Constant("x"));
+            f = f.of(Constant.of("y")).of(Constant.of("z"));
             assertObjectsAreNotEqual(f,g);
-            g.of(new Constant("x"));
-            assertObjectsAreEqual(f,g);
-            f.of(new CompositeUnaryFunction(new Constant("y"),new Constant("z")));
-            assertObjectsAreNotEqual(f,g);
-            g.of(new CompositeUnaryFunction(new Constant("y"),new Constant("z")));
+            g = g.of(Constant.of("y")).of(Constant.of("z"));
             assertObjectsAreEqual(f,g);
         }
 
-        assertObjectsAreNotEqual(f,new Constant("y"));
+        assertObjectsAreNotEqual(f, Constant.of("y"));
     }
 
 }

Modified: commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestCompositeUnaryPredicate.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestCompositeUnaryPredicate.java?rev=665786&r1=665785&r2=665786&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestCompositeUnaryPredicate.java (original)
+++ commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestCompositeUnaryPredicate.java Mon Jun  9 10:17:39 2008
@@ -21,7 +21,6 @@
 
 import org.apache.commons.functor.BaseFunctorTest;
 import org.apache.commons.functor.core.Constant;
-import org.apache.commons.functor.core.Identity;
 
 /**
  * @version $Revision$ $Date$
@@ -44,7 +43,7 @@
     // ------------------------------------------------------------------------
 
     protected Object makeFunctor() {
-        return new CompositeUnaryPredicate(new Identity(),new Constant(true));
+        return Composite.predicate(Constant.TRUE);
     }
 
     // Lifecycle
@@ -62,59 +61,53 @@
     // ------------------------------------------------------------------------
 
     public void testTest() throws Exception {
-        assertEquals(true,(new CompositeUnaryPredicate(new Constant(true))).test(null));
-        assertEquals(true,(new CompositeUnaryPredicate(new Constant(true),new Constant(new Integer(3)))).test("xyzzy"));
-        assertEquals(false,(new CompositeUnaryPredicate(new Constant(false),new Constant(new Integer(4)))).test("xyzzy"));
+        assertTrue(Composite.predicate(Constant.TRUE).test(null));
+        assertTrue(Composite.predicate(Constant.TRUE, Constant.of(3)).test("xyzzy"));
+        assertFalse(Composite.predicate(Constant.FALSE, Constant.of(4)).test("xyzzy"));
     }
 
     public void testNullNotAllowed() throws Exception {
         try {
             new CompositeUnaryPredicate(null);
-            fail("Expected NullPointerException");
-        } catch(NullPointerException e) {
+            fail("Expected IllegalArgumentException");
+        } catch(IllegalArgumentException e) {
             // expected
         }
         try {
-            new CompositeUnaryPredicate(null,null);
-            fail("Expected NullPointerException");
-        } catch(NullPointerException e) {
-            // expected
-        }
-        try {
-            new CompositeUnaryPredicate(Constant.truePredicate(),null);
-            fail("Expected NullPointerException");
-        } catch(NullPointerException e) {
+            Composite.function(Constant.TRUE, null);
+            fail("Expected IllegalArgumentException");
+        } catch(IllegalArgumentException e) {
             // expected
         }
     }
 
     public void testOf() throws Exception {
-        CompositeUnaryPredicate f = new CompositeUnaryPredicate(new Constant(true));
+        CompositeUnaryPredicate<Object> f = new CompositeUnaryPredicate<Object>(Constant.TRUE);
         assertTrue(f.test(null));
         for (int i=0;i<10;i++) {
-            f.of(new Constant(false));
-            assertEquals(true,f.test(null));
+            f = f.of(Constant.FALSE);
+            assertTrue(f.test(null));
         }
     }
 
     public void testEquals() throws Exception {
-        CompositeUnaryPredicate f = new CompositeUnaryPredicate(new Constant(true));
+        CompositeUnaryPredicate<Object> f = new CompositeUnaryPredicate<Object>(Constant.TRUE);
         assertEquals(f,f);
-        CompositeUnaryPredicate g = new CompositeUnaryPredicate(new Constant(true));
+        CompositeUnaryPredicate<Object> g = new CompositeUnaryPredicate<Object>(Constant.TRUE);
         assertObjectsAreEqual(f,g);
 
         for (int i=0;i<3;i++) {
-            f.of(new Constant("x"));
+            f = f.of(Constant.of("x"));
             assertObjectsAreNotEqual(f,g);
-            g.of(new Constant("x"));
+            g = g.of(Constant.of("x"));
             assertObjectsAreEqual(f,g);
-            f.of(new CompositeUnaryFunction(new Constant("y"),new Constant("z")));
+            f = f.of(Constant.of("y")).of(Constant.of("z"));
             assertObjectsAreNotEqual(f,g);
-            g.of(new CompositeUnaryFunction(new Constant("y"),new Constant("z")));
+            g = g.of(Constant.of("y")).of(Constant.of("z"));
             assertObjectsAreEqual(f,g);
         }
 
-        assertObjectsAreNotEqual(f,new Constant(false));
+        assertObjectsAreNotEqual(f,Constant.FALSE);
     }
 
 }

Modified: commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestCompositeUnaryProcedure.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestCompositeUnaryProcedure.java?rev=665786&r1=665785&r2=665786&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestCompositeUnaryProcedure.java (original)
+++ commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestCompositeUnaryProcedure.java Mon Jun  9 10:17:39 2008
@@ -45,7 +45,7 @@
     // ------------------------------------------------------------------------
 
     protected Object makeFunctor() {
-        return new CompositeUnaryProcedure(new NoOp(),new Constant(true));
+        return Composite.procedure(NoOp.instance(), Constant.TRUE);
     }
 
     // Lifecycle
@@ -63,51 +63,45 @@
     // ------------------------------------------------------------------------
 
     public void testRun() throws Exception {
-        new CompositeUnaryProcedure(new NoOp(),new Identity()).run(null);
+        Composite.procedure(NoOp.instance(), Identity.instance()).run(null);
     }
 
     public void testNullNotAllowed() throws Exception {
         try {
             new CompositeUnaryProcedure(null);
-            fail("Expected NullPointerException");
-        } catch(NullPointerException e) {
+            fail("Expected IllegalArgumentException");
+        } catch(IllegalArgumentException e) {
             // expected
         }
         try {
-            new CompositeUnaryProcedure(null,null);
-            fail("Expected NullPointerException");
-        } catch(NullPointerException e) {
-            // expected
-        }
-        try {
-            new CompositeUnaryProcedure(NoOp.instance(),null);
-            fail("Expected NullPointerException");
-        } catch(NullPointerException e) {
+            new CompositeUnaryProcedure<Object>(NoOp.instance()).of(null);
+            fail("Expected IllegalArgumentException");
+        } catch(IllegalArgumentException e) {
             // expected
         }
     }
     public void testOf() throws Exception {
-        new CompositeUnaryProcedure(new NoOp()).of(new Identity()).run(null);
+        Composite.procedure(NoOp.instance()).of(Identity.instance()).run(null);
     }
 
     public void testEquals() throws Exception {
-        CompositeUnaryProcedure f = new CompositeUnaryProcedure(new NoOp());
+        CompositeUnaryProcedure<Object> f = Composite.procedure(NoOp.instance());
         assertEquals(f,f);
-        CompositeUnaryProcedure g = new CompositeUnaryProcedure(new NoOp());
+        CompositeUnaryProcedure<Object> g = Composite.procedure(NoOp.instance());
         assertObjectsAreEqual(f,g);
 
         for (int i=0;i<3;i++) {
-            f.of(new Constant("x"));
+            f = f.of(Constant.of("x"));
             assertObjectsAreNotEqual(f,g);
-            g.of(new Constant("x"));
+            g = g.of(Constant.of("x"));
             assertObjectsAreEqual(f,g);
-            f.of(new CompositeUnaryFunction(new Constant("y"),new Constant("z")));
+            f = f.of(Constant.of("y")).of(Constant.of("z"));
             assertObjectsAreNotEqual(f,g);
-            g.of(new CompositeUnaryFunction(new Constant("y"),new Constant("z")));
+            g = g.of(Constant.of("y")).of(Constant.of("z"));
             assertObjectsAreEqual(f,g);
         }
 
-        assertObjectsAreNotEqual(f,new Constant(false));
+        assertObjectsAreNotEqual(f,Constant.FALSE);
     }
 
 }