commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mben...@apache.org
Subject svn commit: r666345 - in /commons/sandbox/functor/trunk/src: main/java/org/apache/commons/functor/core/collection/ main/java/org/apache/commons/functor/core/comparator/ main/java/org/apache/commons/functor/core/composite/ main/java/org/apache/commons/f...
Date Tue, 10 Jun 2008 22:13:45 GMT
Author: mbenson
Date: Tue Jun 10 15:13:44 2008
New Revision: 666345

URL: http://svn.apache.org/viewvc?rev=666345&view=rev
Log:
unchecked warnings

Modified:
    commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/collection/FilteredIterator.java
    commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/comparator/IsWithinRange.java
    commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/Not.java
    commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/UnaryAnd.java
    commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/UnaryNot.java
    commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/generator/BaseGenerator.java
    commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/generator/FilteredGenerator.java
    commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/generator/GenerateUntil.java
    commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/generator/GenerateWhile.java
    commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/generator/UntilGenerate.java
    commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/generator/WhileGenerate.java
    commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/generator/util/CollectionTransformer.java
    commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/generator/util/EachElement.java
    commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/adapter/TestPredicateUnaryPredicate.java
    commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/TestIsNotEqual.java
    commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/TestIsNotNull.java
    commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/TestIsNull.java
    commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/collection/TestIsEmpty.java
    commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/comparator/TestIsWithinRange.java
    commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/comparator/TestMax.java
    commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/comparator/TestMin.java
    commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestDoWhileProcedure.java
    commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestNot.java
    commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestOr.java
    commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestTransposedPredicate.java
    commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestUnaryAnd.java
    commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestUnaryNot.java
    commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestUnaryOr.java
    commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestWhileDoProcedure.java
    commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/example/kata/two/BinaryChop.java
    commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/generator/TestBaseGenerator.java

Modified: commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/collection/FilteredIterator.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/collection/FilteredIterator.java?rev=666345&r1=666344&r2=666345&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/collection/FilteredIterator.java (original)
+++ commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/collection/FilteredIterator.java Tue Jun 10 15:13:44 2008
@@ -131,6 +131,7 @@
      * @param pred to apply
      * @return Iterator
      */
+    @SuppressWarnings("unchecked")
     public static <T> Iterator<T> filter(Iterator<? extends T> iter, UnaryPredicate<? super T> pred) {
         return null == pred ? (Iterator<T>) iter : (null == iter ? null : new FilteredIterator<T>(iter, pred));
     }

Modified: commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/comparator/IsWithinRange.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/comparator/IsWithinRange.java?rev=666345&r1=666344&r2=666345&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/comparator/IsWithinRange.java (original)
+++ commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/comparator/IsWithinRange.java Tue Jun 10 15:13:44 2008
@@ -99,6 +99,17 @@
      * {@inheritDoc}
      */
     public String toString() {
-        return "IsBetween(" + min + ", " + max + ")";
+        return "IsWithinRange(" + min + ", " + max + ")";
+    }
+
+    /**
+     * Obtain an IsWithinRange instance.
+     * @param <A>
+     * @param min A
+     * @param max A
+     * @return IsWithinRange<A>
+     */
+    public static <A extends Comparable<A>> IsWithinRange<A> instance(A min, A max) {
+        return new IsWithinRange<A>(min, max);
     }
 }
\ No newline at end of file

Modified: commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/Not.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/Not.java?rev=666345&r1=666344&r2=666345&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/Not.java (original)
+++ commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/Not.java Tue Jun 10 15:13:44 2008
@@ -44,10 +44,13 @@
     // ------------------------------------------------------------------------
     /**
      * Create a new Not.
-     * @param p Predicate to negate
+     * @param predicate Predicate to negate
      */
-    public Not(Predicate p) {
-        this.predicate = p;
+    public Not(Predicate predicate) {
+        if (predicate == null) {
+            throw new IllegalArgumentException("Predicate argument was null");
+        }
+        this.predicate = predicate;
     }
 
     // predicate interface

Modified: commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/UnaryAnd.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/UnaryAnd.java?rev=666345&r1=666344&r2=666345&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/UnaryAnd.java (original)
+++ commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/UnaryAnd.java Tue Jun 10 15:13:44 2008
@@ -81,7 +81,7 @@
      * @param p UnaryPredicate to add
      * @return this
      */
-    public UnaryAnd and(UnaryPredicate<? super A> p) {
+    public UnaryAnd<A> and(UnaryPredicate<? super A> p) {
         super.addUnaryPredicate(p);
         return this;
     }

Modified: commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/UnaryNot.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/UnaryNot.java?rev=666345&r1=666344&r2=666345&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/UnaryNot.java (original)
+++ commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/UnaryNot.java Tue Jun 10 15:13:44 2008
@@ -43,10 +43,13 @@
     // ------------------------------------------------------------------------
     /**
      * Create a new UnaryNot.
-     * @param p UnaryPredicate to negate
+     * @param predicate UnaryPredicate to negate
      */
-    public UnaryNot(UnaryPredicate<? super A> p) {
-        this.predicate = p;
+    public UnaryNot(UnaryPredicate<? super A> predicate) {
+        if (predicate == null) {
+            throw new IllegalArgumentException("UnaryPredicate argument was null");
+        }
+        this.predicate = predicate;
     }
 
     // predicate interface

Modified: commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/generator/BaseGenerator.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/generator/BaseGenerator.java?rev=666345&r1=666344&r2=666345&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/generator/BaseGenerator.java (original)
+++ commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/generator/BaseGenerator.java Tue Jun 10 15:13:44 2008
@@ -98,6 +98,7 @@
      * {@inheritDoc}
      * Same as to(new CollectionTransformer()).
      */
+    @SuppressWarnings("unchecked")
     public final Collection<E> toCollection() {
         return (Collection<E>) to(new CollectionTransformer<E>());
     }

Modified: commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/generator/FilteredGenerator.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/generator/FilteredGenerator.java?rev=666345&r1=666344&r2=666345&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/generator/FilteredGenerator.java (original)
+++ commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/generator/FilteredGenerator.java Tue Jun 10 15:13:44 2008
@@ -55,6 +55,7 @@
     /**
      * {@inheritDoc}
      */
+    @SuppressWarnings("unchecked")
     @Override
     protected Generator<? extends E> getWrappedGenerator() {
         return (Generator<? extends E>) super.getWrappedGenerator();

Modified: commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/generator/GenerateUntil.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/generator/GenerateUntil.java?rev=666345&r1=666344&r2=666345&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/generator/GenerateUntil.java (original)
+++ commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/generator/GenerateUntil.java Tue Jun 10 15:13:44 2008
@@ -61,6 +61,7 @@
     /**
      * {@inheritDoc}
      */
+    @SuppressWarnings("unchecked")
     @Override
     protected Generator<? extends E> getWrappedGenerator() {
         return (Generator<? extends E>) super.getWrappedGenerator();

Modified: commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/generator/GenerateWhile.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/generator/GenerateWhile.java?rev=666345&r1=666344&r2=666345&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/generator/GenerateWhile.java (original)
+++ commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/generator/GenerateWhile.java Tue Jun 10 15:13:44 2008
@@ -61,6 +61,7 @@
     /**
      * {@inheritDoc}
      */
+    @SuppressWarnings("unchecked")
     @Override
     protected Generator<? extends E> getWrappedGenerator() {
         return (Generator<? extends E>) super.getWrappedGenerator();

Modified: commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/generator/UntilGenerate.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/generator/UntilGenerate.java?rev=666345&r1=666344&r2=666345&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/generator/UntilGenerate.java (original)
+++ commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/generator/UntilGenerate.java Tue Jun 10 15:13:44 2008
@@ -62,6 +62,7 @@
     /**
      * {@inheritDoc}
      */
+    @SuppressWarnings("unchecked")
     @Override
     protected Generator<? extends E> getWrappedGenerator() {
         return (Generator<? extends E>) super.getWrappedGenerator();

Modified: commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/generator/WhileGenerate.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/generator/WhileGenerate.java?rev=666345&r1=666344&r2=666345&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/generator/WhileGenerate.java (original)
+++ commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/generator/WhileGenerate.java Tue Jun 10 15:13:44 2008
@@ -62,6 +62,7 @@
     /**
      * {@inheritDoc}
      */
+    @SuppressWarnings("unchecked")
     @Override
     protected Generator<? extends E> getWrappedGenerator() {
         return (Generator<? extends E>) super.getWrappedGenerator();

Modified: commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/generator/util/CollectionTransformer.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/generator/util/CollectionTransformer.java?rev=666345&r1=666344&r2=666345&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/generator/util/CollectionTransformer.java (original)
+++ commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/generator/util/CollectionTransformer.java Tue Jun 10 15:13:44 2008
@@ -57,6 +57,7 @@
     /**
      * {@inheritDoc}
      */
+    @SuppressWarnings("unchecked")
     public Collection<E> evaluate(Generator<? extends E> generator) {
         generator.run(new UnaryProcedure<E>() {
             public void run(E obj) {

Modified: commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/generator/util/EachElement.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/generator/util/EachElement.java?rev=666345&r1=666344&r2=666345&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/generator/util/EachElement.java (original)
+++ commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/generator/util/EachElement.java Tue Jun 10 15:13:44 2008
@@ -18,7 +18,6 @@
 import java.util.Collection;
 import java.util.Iterator;
 import java.util.Map;
-import java.util.Set;
 
 import org.apache.commons.functor.generator.Generator;
 import org.apache.commons.functor.generator.IteratorToGeneratorAdapter;
@@ -51,6 +50,7 @@
      * @param map to iterate
      * @return Generator
      */
+    @SuppressWarnings("unchecked")
     public static final <K, V> Generator<Map.Entry<K, V>> from(Map<? extends K, ? extends V> map) {
         if (map == null) {
             return null;

Modified: commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/adapter/TestPredicateUnaryPredicate.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/adapter/TestPredicateUnaryPredicate.java?rev=666345&r1=666344&r2=666345&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/adapter/TestPredicateUnaryPredicate.java (original)
+++ commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/adapter/TestPredicateUnaryPredicate.java Tue Jun 10 15:13:44 2008
@@ -44,7 +44,7 @@
     // ------------------------------------------------------------------------
 
     protected Object makeFunctor() {
-        return new PredicateUnaryPredicate(Constant.TRUE);
+        return new PredicateUnaryPredicate<Object>(Constant.TRUE);
     }
 
     // Lifecycle

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=666345&r1=666344&r2=666345&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 Tue Jun 10 15:13:44 2008
@@ -43,7 +43,7 @@
     // ------------------------------------------------------------------------
 
     protected Object makeFunctor() {
-        return new IsNotEqual();
+        return new IsNotEqual<Object, Object>();
     }
 
     // Lifecycle

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=666345&r1=666344&r2=666345&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 Tue Jun 10 15:13:44 2008
@@ -43,7 +43,7 @@
     // ------------------------------------------------------------------------
 
     protected Object makeFunctor() {
-        return new IsNotNull();
+        return new IsNotNull<Object>();
     }
 
     // Lifecycle
@@ -61,18 +61,18 @@
     // ------------------------------------------------------------------------
 
     public void testTest() throws Exception {
-        UnaryPredicate p = new IsNotNull();
+        UnaryPredicate<Object> p = new IsNotNull<Object>();
         assertTrue(!p.test(null));
         assertTrue(p.test("foo"));
         assertTrue(p.test(new Integer(3)));
     }
 
     public void testEquals() throws Exception {
-        UnaryPredicate p = new IsNotNull();
+        UnaryPredicate<Object> p = new IsNotNull<Object>();
         assertEquals(p,p);
-        assertObjectsAreEqual(p,new IsNotNull());
+        assertObjectsAreEqual(p,new IsNotNull<Object>());
         assertObjectsAreEqual(p,IsNotNull.instance());
-        assertObjectsAreNotEqual(p,Constant.truePredicate());
+        assertObjectsAreNotEqual(p,Constant.TRUE);
     }
 
     public void testConstant() throws Exception {

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=666345&r1=666344&r2=666345&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 Tue Jun 10 15:13:44 2008
@@ -43,7 +43,7 @@
     // ------------------------------------------------------------------------
 
     protected Object makeFunctor() {
-        return new IsNull();
+        return new IsNull<Object>();
     }
 
     // Lifecycle
@@ -61,25 +61,25 @@
     // ------------------------------------------------------------------------
 
     public void testTest() throws Exception {
-        UnaryPredicate p = new IsNull();
+        UnaryPredicate<Object> p = new IsNull<Object>();
         assertTrue(p.test(null));
-        assertTrue(!p.test("foo"));
-        assertTrue(!p.test(new Integer(3)));
+        assertFalse(p.test("foo"));
+        assertFalse(p.test(new Integer(3)));
     }
 
     public void testAsBinary() throws Exception {
-        assertTrue( IsNull.left().test(null,"not null"));
-        assertTrue(!IsNull.left().test("not null",null));
-        assertTrue( IsNull.right().test("not null",null));
-        assertTrue(!IsNull.right().test(null,"not null"));
+        assertTrue(IsNull.left().test(null,"not null"));
+        assertFalse(IsNull.left().test("not null",null));
+        assertTrue(IsNull.right().test("not null",null));
+        assertFalse(IsNull.right().test(null,"not null"));
     }
 
     public void testEquals() throws Exception {
-        UnaryPredicate p = new IsNull();
+        UnaryPredicate<Object> p = new IsNull<Object>();
         assertEquals(p,p);
-        assertObjectsAreEqual(p,new IsNull());
+        assertObjectsAreEqual(p,new IsNull<Object>());
         assertObjectsAreEqual(p,IsNull.instance());
-        assertObjectsAreNotEqual(p,Constant.truePredicate());
+        assertObjectsAreNotEqual(p,Constant.TRUE);
     }
 
     public void testConstant() throws Exception {

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=666345&r1=666344&r2=666345&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 Tue Jun 10 15:13:44 2008
@@ -30,7 +30,6 @@
 import org.apache.commons.functor.BaseFunctorTest;
 import org.apache.commons.functor.UnaryPredicate;
 import org.apache.commons.functor.core.Constant;
-import org.apache.commons.functor.core.composite.UnaryNot;
 
 /**
  * @version $Revision$ $Date$
@@ -130,9 +129,7 @@
         assertEquals(p,p);
         assertObjectsAreEqual(p,new IsEmpty());
         assertObjectsAreEqual(p,IsEmpty.instance());
-        assertSame(IsEmpty.instance(),IsEmpty.instance());
         assertObjectsAreNotEqual(p,new Constant(true));
-        assertObjectsAreNotEqual(p,new UnaryNot(null));
     }
 
 }

Modified: commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/comparator/TestIsWithinRange.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/comparator/TestIsWithinRange.java?rev=666345&r1=666344&r2=666345&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/comparator/TestIsWithinRange.java (original)
+++ commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/comparator/TestIsWithinRange.java Tue Jun 10 15:13:44 2008
@@ -43,7 +43,7 @@
     // ------------------------------------------------------------------------
 
     protected Object makeFunctor() {
-        return new IsWithinRange(new Integer(5), new Integer(10));
+        return new IsWithinRange<Integer>(new Integer(5), new Integer(10));
     }
 
     // Lifecycle
@@ -61,7 +61,7 @@
     // ------------------------------------------------------------------------
 
     public void testTest() throws Exception {
-        IsWithinRange p = new IsWithinRange(new Integer(5), new Integer(10));
+        IsWithinRange<Integer> p = new IsWithinRange<Integer>(new Integer(5), new Integer(10));
         assertTrue(p.test(new Integer(5)));
         assertTrue(p.test(new Integer(6)));
         assertTrue(p.test(new Integer(7)));
@@ -76,7 +76,7 @@
 
     public void testInvalidRange() {
         try {
-            new IsWithinRange(new Integer(5), new Integer(4));
+            new IsWithinRange<Integer>(new Integer(5), new Integer(4));
             fail("should have thrown IllegalArgumentException");
         } catch (IllegalArgumentException e) {
             // good
@@ -85,7 +85,7 @@
         }
 
         try {
-            new IsWithinRange(new Integer(5), null);
+            new IsWithinRange<Integer>(new Integer(5), null);
             fail("should have thrown IllegalArgumentException");
         } catch (IllegalArgumentException e) {
             // good
@@ -95,12 +95,26 @@
     }
 
     public void testEquals() throws Exception {
-        IsWithinRange p1 = new IsWithinRange(new Integer(5), new Integer(10));
-        IsWithinRange p2 = new IsWithinRange(new Integer(5), new Integer(10));
+        IsWithinRange<Integer> p1 = new IsWithinRange<Integer>(new Integer(5), new Integer(10));
+        IsWithinRange<Integer> p2 = new IsWithinRange<Integer>(new Integer(5), new Integer(10));
         assertEquals(p1, p2);
-        p2 = new IsWithinRange(new Integer(5), new Integer(11));
+        p2 = new IsWithinRange<Integer>(new Integer(5), new Integer(11));
         assertTrue(!p1.equals(p2));
-        p2 = new IsWithinRange(new Integer(6), new Integer(10));
+        p2 = new IsWithinRange<Integer>(new Integer(6), new Integer(10));
         assertTrue(!p1.equals(p2));
     }
+
+    public void testFactory() throws Exception {
+        IsWithinRange<Integer> p = IsWithinRange.instance(new Integer(5), new Integer(10));
+        assertTrue(p.test(new Integer(5)));
+        assertTrue(p.test(new Integer(6)));
+        assertTrue(p.test(new Integer(7)));
+        assertTrue(p.test(new Integer(8)));
+        assertTrue(p.test(new Integer(9)));
+        assertTrue(p.test(new Integer(10)));
+
+        assertTrue(!p.test(new Integer(4)));
+        assertTrue(!p.test(new Integer(11)));
+
+    }
 }

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=666345&r1=666344&r2=666345&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 Tue Jun 10 15:13:44 2008
@@ -56,7 +56,7 @@
     // ------------------------------------------------------------------------
 
     public void testEvaluate() {
-        Max f = Max.instance();
+        Max<Integer> f = Max.instance();
         assertEquals(ONE,f.evaluate(ONE,ONE));
         assertEquals(ONE,f.evaluate(ZERO,ONE));
         assertEquals(ONE,f.evaluate(ONE,ZERO));
@@ -65,11 +65,12 @@
         assertEquals(MINUS_TWO,f.evaluate(MIN,MINUS_TWO));
     }
 
+    @SuppressWarnings("unchecked")
     public void testEquals() {
-        Max f = Max.instance();
+        Max<Comparable<?>> f = Max.instance();
         assertObjectsAreEqual(f,f);
         assertObjectsAreEqual(f,Max.instance());
-        assertObjectsAreEqual(f,new Max(new ComparableComparator()));
-        assertObjectsAreNotEqual(f,new Max(Collections.reverseOrder()));
+        assertObjectsAreEqual(f,new Max<Comparable<?>>(ComparableComparator.INSTANCE));
+        assertObjectsAreNotEqual(f,new Max<Comparable<?>>(Collections.<Comparable<?>>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=666345&r1=666344&r2=666345&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 Tue Jun 10 15:13:44 2008
@@ -56,7 +56,7 @@
     // ------------------------------------------------------------------------
 
     public void testEvaluate() {
-        Min f = Min.instance();
+        Min<Integer> f = Min.instance();
         assertEquals(ONE,f.evaluate(ONE,ONE));
         assertEquals(ZERO,f.evaluate(ZERO,ONE));
         assertEquals(ZERO,f.evaluate(ONE,ZERO));
@@ -65,11 +65,12 @@
         assertEquals(MIN,f.evaluate(MIN,MINUS_TWO));
     }
 
+    @SuppressWarnings("unchecked")
     public void testEquals() {
-        Min f = Min.instance();
+        Min<Comparable<?>> f = Min.instance();
         assertObjectsAreEqual(f,f);
         assertObjectsAreEqual(f,Min.instance());
-        assertObjectsAreEqual(f,new Min(new ComparableComparator()));
-        assertObjectsAreNotEqual(f,new Min(Collections.reverseOrder()));
+        assertObjectsAreEqual(f,new Min<Comparable<?>>(ComparableComparator.INSTANCE));
+        assertObjectsAreNotEqual(f,new Min<Comparable<?>>(Collections.<Comparable<?>>reverseOrder()));
     }
 }

Modified: commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestDoWhileProcedure.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestDoWhileProcedure.java?rev=666345&r1=666344&r2=666345&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestDoWhileProcedure.java (original)
+++ commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestDoWhileProcedure.java Tue Jun 10 15:13:44 2008
@@ -51,7 +51,7 @@
     // ------------------------------------------------------------------------
 
     protected Object makeFunctor() {
-        return new DoWhileProcedure(new NoOp(), new Constant(false));
+        return new DoWhileProcedure(NoOp.INSTANCE, Constant.FALSE);
     }
 
     // Lifecycle
@@ -68,10 +68,10 @@
     // Tests
     // ------------------------------------------------------------------------
     public class ListRemoveFirstProcedure implements Procedure {
-        protected List list;
+        protected List<Object> list;
 
 
-        public ListRemoveFirstProcedure(List list) {
+        public ListRemoveFirstProcedure(List<Object> list) {
             this.list=list;
         }
 
@@ -82,8 +82,8 @@
     }
 
 
-    private List getList() {
-        List list=new LinkedList();
+    private List<Object> getList() {
+        List<Object> list = new LinkedList<Object>();
         list.add("a");
         list.add("b");
         list.add("c");
@@ -93,10 +93,10 @@
 
 
     public void testLoopWithAction() throws Exception {
-        List list=getList();
+        List<Object> list=getList();
 
         Procedure action=new ListRemoveFirstProcedure(list);
-        Predicate condition=new Not(new BoundPredicate(new IsEmpty(), list));
+        Predicate condition=new Not(new BoundPredicate(new IsEmpty<List<Object>>(), list));
         Procedure procedure=new DoWhileProcedure(action, condition);
 
         assertTrue("The condition should be true before running the loop", condition.test());
@@ -123,9 +123,9 @@
     }
 
     public void testLoopForNothing() {
-        List list=getList();
+        List<Object> list=getList();
         Procedure action=new ListRemoveFirstProcedure(list);
-        Procedure procedure=new DoWhileProcedure(action, new Constant(false));
+        Procedure procedure=new DoWhileProcedure(action, Constant.FALSE);
         assertTrue("The list should contain 4 elements before runnning the loop", list.size()==4);
         procedure.run();
         assertTrue("The list should contain 3 elements after runnning the loop", list.size()==3);

Modified: commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestNot.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestNot.java?rev=666345&r1=666344&r2=666345&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestNot.java (original)
+++ commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestNot.java Tue Jun 10 15:13:44 2008
@@ -44,7 +44,7 @@
     // ------------------------------------------------------------------------
 
     protected Object makeFunctor() {
-        return new Not(new Constant(true));
+        return new Not(Constant.TRUE);
     }
 
     // Lifecycle
@@ -62,18 +62,17 @@
     // ------------------------------------------------------------------------
 
     public void testTest() throws Exception {
-        Predicate truePred = new Not(new Constant(false));
+        Predicate truePred = new Not(Constant.FALSE);
         assertTrue(truePred.test());
     }
 
     public void testEquals() throws Exception {
-        Not p = new Not(Constant.truePredicate());
+        Not p = new Not(Constant.TRUE);
         assertEquals(p,p);
-        assertObjectsAreEqual(p,new Not(new Constant(true)));
-        assertObjectsAreEqual(p,Not.not(new Constant(true)));
-        assertObjectsAreNotEqual(p,new Not(new Constant(false)));
-        assertObjectsAreNotEqual(p,Constant.truePredicate());
-        assertObjectsAreNotEqual(p,new Not(null));
+        assertObjectsAreEqual(p,new Not(Constant.TRUE));
+        assertObjectsAreEqual(p,Not.not(Constant.TRUE));
+        assertObjectsAreNotEqual(p,new Not(Constant.FALSE));
+        assertObjectsAreNotEqual(p,Constant.TRUE);
     }
 
     public void testNotNull() throws Exception {
@@ -81,6 +80,6 @@
     }
 
     public void testNotNotNull() throws Exception {
-        assertNotNull(Not.not(Constant.truePredicate()));
+        assertNotNull(Not.not(Constant.TRUE));
     }
 }

Modified: commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestOr.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestOr.java?rev=666345&r1=666344&r2=666345&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestOr.java (original)
+++ commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestOr.java Tue Jun 10 15:13:44 2008
@@ -44,7 +44,7 @@
     // ------------------------------------------------------------------------
 
     protected Object makeFunctor() {
-        return new Or(new Constant(false),new Constant(true));
+        return new Or(Constant.FALSE, Constant.TRUE);
     }
 
     // Lifecycle
@@ -62,21 +62,21 @@
     // ------------------------------------------------------------------------
 
     public void testTrue() throws Exception {
-        assertTrue((new Or(new Constant(true))).test());
-        assertTrue((new Or(new Constant(false),new Constant(true))).test());
-        assertTrue((new Or(new Constant(false),new Constant(false),new Constant(true))).test());
+        assertTrue((new Or(Constant.TRUE)).test());
+        assertTrue((new Or(Constant.FALSE, Constant.TRUE)).test());
+        assertTrue((new Or(Constant.FALSE, Constant.FALSE, Constant.TRUE)).test());
 
-        Or p = new Or(new Constant(true));
+        Or p = new Or(Constant.TRUE);
         assertTrue(p.test());
         for (int i=0;i<10;i++) {
-            p.or(new Constant(i%2==0));
+            p.or(Constant.of(i%2==0));
             assertTrue(p.test());
         }
 
-        Or q = new Or(new Constant(true));
+        Or q = new Or(Constant.TRUE);
         assertTrue(q.test());
         for (int i=0;i<10;i++) {
-            q.or(new Constant(i%2==0));
+            q.or(Constant.of(i%2==0));
             assertTrue(q.test());
         }
 
@@ -85,23 +85,23 @@
     }
 
     public void testFalse() throws Exception {
-        assertTrue(!(new Or()).test());
-        assertTrue(!(new Or(new Constant(false))).test());
-        assertTrue(!(new Or(new Constant(false),new Constant(false))).test());
-        assertTrue(!(new Or(new Constant(false),new Constant(false),new Constant(false))).test());
+        assertFalse(new Or().test());
+        assertFalse(new Or(Constant.FALSE).test());
+        assertFalse(new Or(Constant.FALSE,Constant.FALSE).test());
+        assertFalse(new Or(Constant.FALSE,Constant.FALSE,Constant.FALSE).test());
 
-        Or p = new Or(new Constant(false));
-        assertTrue(!p.test());
+        Or p = new Or(Constant.FALSE);
+        assertFalse(p.test());
         for (int i=0;i<10;i++) {
-            p.or(new Constant(false));
-            assertTrue(!p.test());
+            p.or(Constant.FALSE);
+            assertFalse(p.test());
         }
 
-        Or q = new Or(new Constant(false));
-        assertTrue(!q.test());
+        Or q = new Or(Constant.FALSE);
+        assertFalse(q.test());
         for (int i=0;i<10;i++) {
-            q.or(new Constant(false));
-            assertTrue(!q.test());
+            q.or(Constant.FALSE);
+            assertFalse(q.test());
         }
 
         Or r = new Or(p,q);
@@ -109,7 +109,7 @@
     }
 
     public void testDuplicateAdd() throws Exception {
-        Predicate p = new Constant(true);
+        Predicate p = Constant.TRUE;
         Or q = new Or(p,p);
         assertTrue(q.test());
         for (int i=0;i<10;i++) {
@@ -129,22 +129,22 @@
         assertObjectsAreNotEqual(p,r);
 
         for (int i=0;i<3;i++) {
-            p.or(Constant.truePredicate());
+            p.or(Constant.TRUE);
             assertObjectsAreNotEqual(p,q);
-            q.or(Constant.truePredicate());
+            q.or(Constant.TRUE);
             assertObjectsAreEqual(p,q);
-            r.and(Constant.truePredicate());
+            r.and(Constant.TRUE);
             assertObjectsAreNotEqual(p,r);
 
-            p.or(new Or(Constant.truePredicate(),Constant.falsePredicate()));
+            p.or(new Or(Constant.TRUE,Constant.FALSE));
             assertObjectsAreNotEqual(p,q);
-            q.or(new Or(Constant.truePredicate(),Constant.falsePredicate()));
+            q.or(new Or(Constant.TRUE,Constant.FALSE));
             assertObjectsAreEqual(p,q);
-            r.and(new Or(Constant.truePredicate(),Constant.falsePredicate()));
+            r.and(new Or(Constant.TRUE,Constant.FALSE));
             assertObjectsAreNotEqual(p,r);
         }
 
-        assertObjectsAreNotEqual(p,Constant.truePredicate());
+        assertObjectsAreNotEqual(p,Constant.TRUE);
     }
 
 }

Modified: commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestTransposedPredicate.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestTransposedPredicate.java?rev=666345&r1=666344&r2=666345&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestTransposedPredicate.java (original)
+++ commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestTransposedPredicate.java Tue Jun 10 15:13:44 2008
@@ -46,7 +46,7 @@
     // ------------------------------------------------------------------------
 
     protected Object makeFunctor() {
-        return new TransposedPredicate(Constant.truePredicate());
+        return new TransposedPredicate<Object, Object>(Constant.TRUE);
     }
 
     // Lifecycle
@@ -84,6 +84,6 @@
     }
 
     public void testTranspose() throws Exception {
-        assertNotNull(TransposedPredicate.transpose(new Constant(true)));
+        assertNotNull(TransposedPredicate.transpose(Constant.TRUE));
     }
 }

Modified: commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestUnaryAnd.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestUnaryAnd.java?rev=666345&r1=666344&r2=666345&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestUnaryAnd.java (original)
+++ commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestUnaryAnd.java Tue Jun 10 15:13:44 2008
@@ -44,7 +44,7 @@
     // ------------------------------------------------------------------------
 
     protected Object makeFunctor() {
-        return new UnaryAnd(new Constant(true),new Constant(true));
+        return new UnaryAnd<Object>(Constant.TRUE, Constant.TRUE);
     }
 
     // Lifecycle
@@ -62,55 +62,55 @@
     // ------------------------------------------------------------------------
 
     public void testTrue() throws Exception {
-        assertTrue((new UnaryAnd()).test("xyzzy"));
-        assertTrue((new UnaryAnd(new Constant(true))).test("xyzzy"));
-        assertTrue((new UnaryAnd(new Constant(true),new Constant(true))).test("xyzzy"));
-        assertTrue((new UnaryAnd(new Constant(true),new Constant(true),new Constant(true))).test("xyzzy"));
+        assertTrue((new UnaryAnd<Object>()).test("xyzzy"));
+        assertTrue((new UnaryAnd<Object>(Constant.TRUE)).test("xyzzy"));
+        assertTrue((new UnaryAnd<Object>(Constant.TRUE,Constant.TRUE)).test("xyzzy"));
+        assertTrue((new UnaryAnd<Object>(Constant.TRUE,Constant.TRUE,Constant.TRUE)).test("xyzzy"));
 
-        UnaryAnd p = new UnaryAnd(new Constant(true));
+        UnaryAnd<Object> p = new UnaryAnd<Object>(Constant.TRUE);
         assertTrue(p.test("xyzzy"));
         for (int i=0;i<10;i++) {
-            p.and(new Constant(true));
+            p.and(Constant.TRUE);
             assertTrue(p.test("xyzzy"));
         }
 
-        UnaryAnd q = new UnaryAnd(new Constant(true));
+        UnaryAnd<Object> q = new UnaryAnd<Object>(Constant.TRUE);
         assertTrue(q.test("xyzzy"));
         for (int i=0;i<10;i++) {
-            q.and(new Constant(true));
+            q.and(Constant.TRUE);
             assertTrue(q.test("xyzzy"));
         }
 
-        UnaryAnd r = new UnaryAnd(p,q);
+        UnaryAnd<Object> r = new UnaryAnd<Object>(p,q);
         assertTrue(r.test("xyzzy"));
     }
 
     public void testFalse() throws Exception {
-        assertTrue(!(new UnaryAnd(new Constant(false))).test("xyzzy"));
-        assertTrue(!(new UnaryAnd(new Constant(true),new Constant(false))).test("xyzzy"));
-        assertTrue(!(new UnaryAnd(new Constant(true),new Constant(true),new Constant(false))).test("xyzzy"));
+        assertFalse(new UnaryAnd<Object>(Constant.FALSE).test("xyzzy"));
+        assertFalse(new UnaryAnd<Object>(Constant.TRUE,Constant.FALSE).test("xyzzy"));
+        assertFalse(new UnaryAnd<Object>(Constant.TRUE,Constant.TRUE,Constant.FALSE).test("xyzzy"));
 
-        UnaryAnd p = new UnaryAnd(new Constant(false));
+        UnaryAnd<Object> p = new UnaryAnd<Object>(Constant.FALSE);
         assertTrue(!p.test("xyzzy"));
         for (int i=0;i<10;i++) {
-            p.and(new Constant(false));
+            p.and(Constant.TRUE);
             assertTrue(!p.test("xyzzy"));
         }
 
-        UnaryAnd q = new UnaryAnd(new Constant(true));
+        UnaryAnd<Object> q = new UnaryAnd<Object>(Constant.TRUE);
         assertTrue(q.test("xyzzy"));
         for (int i=0;i<10;i++) {
-            q.and(new Constant(true));
+            q.and(Constant.TRUE);
             assertTrue(q.test("xyzzy"));
         }
 
-        UnaryAnd r = new UnaryAnd(p,q);
+        UnaryAnd<Object> r = new UnaryAnd<Object>(p,q);
         assertTrue(!r.test("xyzzy"));
     }
 
     public void testDuplicateAdd() throws Exception {
-        UnaryPredicate p = new Constant(true);
-        UnaryAnd q = new UnaryAnd(p,p);
+        UnaryPredicate<Object> p = Constant.TRUE;
+        UnaryAnd<Object> q = new UnaryAnd<Object>(p,p);
         assertTrue(q.test("xyzzy"));
         for (int i=0;i<10;i++) {
             q.and(p);
@@ -119,9 +119,9 @@
     }
 
     public void testEquals() throws Exception {
-        UnaryAnd p = new UnaryAnd();
+        UnaryAnd<Object> p = new UnaryAnd<Object>();
         assertEquals(p,p);
-        UnaryAnd q = new UnaryAnd();
+        UnaryAnd<Object> q = new UnaryAnd<Object>();
         assertObjectsAreEqual(p,q);
 
         for (int i=0;i<3;i++) {
@@ -129,9 +129,9 @@
             assertObjectsAreNotEqual(p,q);
             q.and(Constant.truePredicate());
             assertObjectsAreEqual(p,q);
-            p.and(new UnaryAnd(Constant.truePredicate(),Constant.falsePredicate()));
+            p.and(new UnaryAnd<Object>(Constant.truePredicate(),Constant.falsePredicate()));
             assertObjectsAreNotEqual(p,q);
-            q.and(new UnaryAnd(Constant.truePredicate(),Constant.falsePredicate()));
+            q.and(new UnaryAnd<Object>(Constant.truePredicate(),Constant.falsePredicate()));
             assertObjectsAreEqual(p,q);
         }
 

Modified: commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestUnaryNot.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestUnaryNot.java?rev=666345&r1=666344&r2=666345&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestUnaryNot.java (original)
+++ commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestUnaryNot.java Tue Jun 10 15:13:44 2008
@@ -44,7 +44,7 @@
     // ------------------------------------------------------------------------
 
     protected Object makeFunctor() {
-        return new UnaryNot(new Constant(true));
+        return new UnaryNot<Object>(Constant.TRUE);
     }
 
     // Lifecycle
@@ -62,20 +62,19 @@
     // ------------------------------------------------------------------------
 
     public void testTest() throws Exception {
-        UnaryPredicate truePred = new UnaryNot(new Constant(false));
+        UnaryPredicate<Object> truePred = new UnaryNot<Object>(Constant.FALSE);
         assertTrue(truePred.test(null));
         assertTrue(truePred.test("xyzzy"));
         assertTrue(truePred.test(new Integer(3)));
     }
 
     public void testEquals() throws Exception {
-        UnaryNot p = new UnaryNot(Constant.truePredicate());
+        UnaryNot<Object> p = new UnaryNot<Object>(Constant.TRUE);
         assertEquals(p,p);
-        assertObjectsAreEqual(p,new UnaryNot(new Constant(true)));
-        assertObjectsAreEqual(p,UnaryNot.not(new Constant(true)));
-        assertObjectsAreNotEqual(p,new UnaryNot(new Constant(false)));
-        assertObjectsAreNotEqual(p,Constant.truePredicate());
-        assertObjectsAreNotEqual(p,new UnaryNot(null));
+        assertObjectsAreEqual(p,new UnaryNot<Object>(Constant.TRUE));
+        assertObjectsAreEqual(p,UnaryNot.not(Constant.TRUE));
+        assertObjectsAreNotEqual(p,new UnaryNot<Object>(Constant.FALSE));
+        assertObjectsAreNotEqual(p,Constant.TRUE);
     }
 
     public void testNotNull() throws Exception {

Modified: commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestUnaryOr.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestUnaryOr.java?rev=666345&r1=666344&r2=666345&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestUnaryOr.java (original)
+++ commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestUnaryOr.java Tue Jun 10 15:13:44 2008
@@ -44,7 +44,7 @@
     // ------------------------------------------------------------------------
 
     protected Object makeFunctor() {
-        return new UnaryOr(new Constant(false),new Constant(true));
+        return new UnaryOr<Object>(Constant.FALSE,Constant.TRUE);
     }
 
     // Lifecycle
@@ -62,55 +62,55 @@
     // ------------------------------------------------------------------------
 
     public void testTrue() throws Exception {
-        assertTrue((new UnaryOr(new Constant(true))).test("xyzzy"));
-        assertTrue((new UnaryOr(new Constant(false),new Constant(true))).test("xyzzy"));
-        assertTrue((new UnaryOr(new Constant(false),new Constant(false),new Constant(true))).test("xyzzy"));
+        assertTrue((new UnaryOr<Object>(Constant.TRUE)).test("xyzzy"));
+        assertTrue((new UnaryOr<Object>(Constant.FALSE,Constant.TRUE)).test("xyzzy"));
+        assertTrue((new UnaryOr<Object>(Constant.FALSE,Constant.FALSE,Constant.TRUE)).test("xyzzy"));
 
-        UnaryOr p = new UnaryOr(new Constant(true));
+        UnaryOr<Object> p = new UnaryOr<Object>(Constant.TRUE);
         assertTrue(p.test("xyzzy"));
         for (int i=0;i<10;i++) {
-            p.or(new Constant(i%2==0));
+            p.or(Constant.of(i%2==0));
             assertTrue(p.test("xyzzy"));
         }
 
-        UnaryOr q = new UnaryOr(new Constant(true));
+        UnaryOr<Object> q = new UnaryOr<Object>(Constant.TRUE);
         assertTrue(q.test("xyzzy"));
         for (int i=0;i<10;i++) {
-            q.or(new Constant(i%2==0));
+            q.or(Constant.of(i%2==0));
             assertTrue(q.test("xyzzy"));
         }
 
-        UnaryOr r = new UnaryOr(p,q);
+        UnaryOr<Object> r = new UnaryOr<Object>(p,q);
         assertTrue(r.test("xyzzy"));
     }
 
     public void testFalse() throws Exception {
-        assertTrue(!(new UnaryOr()).test("xyzzy"));
-        assertTrue(!(new UnaryOr(new Constant(false))).test("xyzzy"));
-        assertTrue(!(new UnaryOr(new Constant(false),new Constant(false))).test("xyzzy"));
-        assertTrue(!(new UnaryOr(new Constant(false),new Constant(false),new Constant(false))).test("xyzzy"));
+        assertTrue(!(new UnaryOr<Object>()).test("xyzzy"));
+        assertTrue(!(new UnaryOr<Object>(Constant.FALSE)).test("xyzzy"));
+        assertTrue(!(new UnaryOr<Object>(Constant.FALSE,Constant.FALSE)).test("xyzzy"));
+        assertTrue(!(new UnaryOr<Object>(Constant.FALSE,Constant.FALSE,Constant.FALSE)).test("xyzzy"));
 
-        UnaryOr p = new UnaryOr(new Constant(false));
+        UnaryOr<Object> p = new UnaryOr<Object>(Constant.FALSE);
         assertTrue(!p.test("xyzzy"));
         for (int i=0;i<10;i++) {
-            p.or(new Constant(false));
+            p.or(Constant.FALSE);
             assertTrue(!p.test("xyzzy"));
         }
 
-        UnaryOr q = new UnaryOr(new Constant(false));
+        UnaryOr<Object> q = new UnaryOr<Object>(Constant.FALSE);
         assertTrue(!q.test("xyzzy"));
         for (int i=0;i<10;i++) {
-            q.or(new Constant(false));
+            q.or(Constant.FALSE);
             assertTrue(!q.test("xyzzy"));
         }
 
-        UnaryOr r = new UnaryOr(p,q);
+        UnaryOr<Object> r = new UnaryOr<Object>(p,q);
         assertTrue(!r.test("xyzzy"));
     }
 
     public void testDuplicateAdd() throws Exception {
-        UnaryPredicate p = new Constant(true);
-        UnaryOr q = new UnaryOr(p,p);
+        UnaryPredicate<Object> p = Constant.TRUE;
+        UnaryOr<Object> q = new UnaryOr<Object>(p,p);
         assertTrue(q.test("xyzzy"));
         for (int i=0;i<10;i++) {
             q.or(p);
@@ -119,13 +119,13 @@
     }
 
     public void testEquals() throws Exception {
-        UnaryOr p = new UnaryOr();
+        UnaryOr<Object> p = new UnaryOr<Object>();
         assertEquals(p,p);
 
-        UnaryOr q = new UnaryOr();
+        UnaryOr<Object> q = new UnaryOr<Object>();
         assertObjectsAreEqual(p,q);
 
-        UnaryAnd r = new UnaryAnd();
+        UnaryAnd<Object> r = new UnaryAnd<Object>();
         assertObjectsAreNotEqual(p,r);
 
         for (int i=0;i<3;i++) {
@@ -136,11 +136,11 @@
             r.and(Constant.truePredicate());
             assertObjectsAreNotEqual(p,r);
 
-            p.or(new UnaryOr(Constant.truePredicate(),Constant.falsePredicate()));
+            p.or(new UnaryOr<Object>(Constant.truePredicate(),Constant.falsePredicate()));
             assertObjectsAreNotEqual(p,q);
-            q.or(new UnaryOr(Constant.truePredicate(),Constant.falsePredicate()));
+            q.or(new UnaryOr<Object>(Constant.truePredicate(),Constant.falsePredicate()));
             assertObjectsAreEqual(p,q);
-            r.and(new UnaryOr(Constant.truePredicate(),Constant.falsePredicate()));
+            r.and(new UnaryOr<Object>(Constant.truePredicate(),Constant.falsePredicate()));
             assertObjectsAreNotEqual(p,r);
         }
 

Modified: commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestWhileDoProcedure.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestWhileDoProcedure.java?rev=666345&r1=666344&r2=666345&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestWhileDoProcedure.java (original)
+++ commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestWhileDoProcedure.java Tue Jun 10 15:13:44 2008
@@ -51,7 +51,7 @@
     // ------------------------------------------------------------------------
 
     protected Object makeFunctor() {
-        return new WhileDoProcedure(new Constant(false), new NoOp());
+        return new WhileDoProcedure(Constant.FALSE, NoOp.INSTANCE);
     }
 
     // Lifecycle
@@ -68,10 +68,10 @@
     // Tests
     // ------------------------------------------------------------------------
     public class ListRemoveFirstProcedure implements Procedure {
-        protected List list;
+        protected List<Object> list;
 
 
-        public ListRemoveFirstProcedure(List list) {
+        public ListRemoveFirstProcedure(List<Object> list) {
             this.list=list;
         }
 
@@ -82,8 +82,8 @@
     }
 
 
-    private List getList() {
-        List list=new LinkedList();
+    private List<Object> getList() {
+        List<Object> list=new LinkedList<Object>();
         list.add("a");
         list.add("b");
         list.add("c");
@@ -93,10 +93,10 @@
 
 
     public void testLoopWithAction() throws Exception {
-        List list=getList();
+        List<Object> list=getList();
 
         Procedure action=new ListRemoveFirstProcedure(list);
-        Predicate condition=new Not(new BoundPredicate(new IsEmpty(), list));
+        Predicate condition=new Not(new BoundPredicate(new IsEmpty<List<Object>>(), list));
         Procedure procedure=new WhileDoProcedure(condition, action);
 
         assertTrue("The condition should be true before running the loop", condition.test());
@@ -123,9 +123,9 @@
     }
 
     public void testLoopForNothing() {
-        List list=getList();
+        List<Object> list=getList();
         Procedure action=new ListRemoveFirstProcedure(list);
-        Procedure procedure=new WhileDoProcedure(new Constant(false), action);
+        Procedure procedure=new WhileDoProcedure(Constant.FALSE, action);
         assertTrue("The list should contain 4 elements before runnning the loop", list.size()==4);
         procedure.run();
         assertTrue("The list should contain 4 elements after runnning the loop", list.size()==4);

Modified: commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/example/kata/two/BinaryChop.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/example/kata/two/BinaryChop.java?rev=666345&r1=666344&r2=666345&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/example/kata/two/BinaryChop.java (original)
+++ commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/example/kata/two/BinaryChop.java Tue Jun 10 15:13:44 2008
@@ -25,6 +25,7 @@
  * @version $Revision$ $Date$
  * @author Rodney Waldhoff
  */
+@SuppressWarnings("unchecked")
 public interface BinaryChop {
     int find(int seeking, int[] in);
     int find(Object seeking, Object[] in);

Modified: commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/generator/TestBaseGenerator.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/generator/TestBaseGenerator.java?rev=666345&r1=666344&r2=666345&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/generator/TestBaseGenerator.java (original)
+++ commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/generator/TestBaseGenerator.java Tue Jun 10 15:13:44 2008
@@ -25,10 +25,10 @@
 import junit.framework.TestCase;
 import junit.framework.TestSuite;
 
-import org.apache.commons.functor.UnaryPredicate;
+//import org.apache.commons.functor.UnaryPredicate;
 import org.apache.commons.functor.UnaryProcedure;
-import org.apache.commons.functor.adapter.LeftBoundPredicate;
-import org.apache.commons.functor.core.IsEqual;
+//import org.apache.commons.functor.adapter.LeftBoundPredicate;
+//import org.apache.commons.functor.core.IsEqual;
 import org.apache.commons.functor.generator.util.CollectionTransformer;
 
 /**
@@ -189,18 +189,18 @@
     private List evens = null;
     private List listWithDuplicates = null;
     private int sum = 0;
-    private UnaryPredicate equalsThree = LeftBoundPredicate.bind(IsEqual.instance(),new Integer(3));
-    private UnaryPredicate equalsTwentyThree = LeftBoundPredicate.bind(IsEqual.instance(),new Integer(23));
-    private UnaryPredicate isEven = new UnaryPredicate() {
-        public boolean test(Object obj) {
-            return ((Number) obj).intValue() % 2 == 0;
-        }
-    };
-    private UnaryPredicate isOdd = new UnaryPredicate() {
-        public boolean test(Object obj) {
-            return ((Number) obj).intValue() % 2 != 0;
-        }
-    };
+//    private UnaryPredicate equalsThree = LeftBoundPredicate.bind(IsEqual.instance(),new Integer(3));
+//    private UnaryPredicate equalsTwentyThree = LeftBoundPredicate.bind(IsEqual.instance(),new Integer(23));
+//    private UnaryPredicate isEven = new UnaryPredicate() {
+//        public boolean test(Object obj) {
+//            return ((Number) obj).intValue() % 2 == 0;
+//        }
+//    };
+//    private UnaryPredicate isOdd = new UnaryPredicate() {
+//        public boolean test(Object obj) {
+//            return ((Number) obj).intValue() % 2 != 0;
+//        }
+//    };
 
     // Classes
     // ------------------------------------------------------------------------



Mime
View raw message