commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mben...@apache.org
Subject svn commit: r665786 [4/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...
Date Mon, 09 Jun 2008 17:17:43 GMT
Modified: commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/ConditionalBinaryFunction.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/ConditionalBinaryFunction.java?rev=665786&r1=665785&r2=665786&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/ConditionalBinaryFunction.java (original)
+++ commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/ConditionalBinaryFunction.java Mon Jun  9 10:17:39 2008
@@ -41,12 +41,12 @@
  * @version $Revision$ $Date$
  * @author Rodney Waldhoff
  */
-public final class ConditionalBinaryFunction implements BinaryFunction, Serializable {
+public final class ConditionalBinaryFunction<L, R, T> implements BinaryFunction<L, R, T>, Serializable {
     // attributes
     // ------------------------------------------------------------------------
-    private BinaryPredicate ifPred = null;
-    private BinaryFunction thenFunc = null;
-    private BinaryFunction elseFunc = null;
+    private BinaryPredicate<? super L, ? super R> ifPred;
+    private BinaryFunction<? super L, ? super R, ? extends T> thenFunc;
+    private BinaryFunction<? super L, ? super R, ? extends T> elseFunc;
 
     // constructor
     // ------------------------------------------------------------------------
@@ -56,7 +56,15 @@
      * @param thenFunc then
      * @param elseFunc else
      */
-    public ConditionalBinaryFunction(BinaryPredicate ifPred, BinaryFunction thenFunc, BinaryFunction elseFunc) {
+    public ConditionalBinaryFunction(BinaryPredicate<? super L, ? super R> ifPred,
+            BinaryFunction<? super L, ? super R, ? extends T> thenFunc,
+            BinaryFunction<? super L, ? super R, ? extends T> elseFunc) {
+        if (ifPred == null) {
+            throw new IllegalArgumentException("test predicate must not be null");
+        }
+        if (thenFunc == null || elseFunc == null) {
+            throw new IllegalArgumentException("neither resulting function may be null");
+        }
         this.ifPred = ifPred;
         this.thenFunc = thenFunc;
         this.elseFunc = elseFunc;
@@ -67,7 +75,7 @@
     /**
      * {@inheritDoc}
      */
-    public Object evaluate(Object left, Object right) {
+    public T evaluate(L left, R right) {
         return ifPred.test(left, right) ? thenFunc.evaluate(left, right) : elseFunc.evaluate(left, right);
     }
 
@@ -75,7 +83,7 @@
      * {@inheritDoc}
      */
     public boolean equals(Object that) {
-        return that == this || (that instanceof ConditionalBinaryFunction && equals((ConditionalBinaryFunction) that));
+        return that == this || (that instanceof ConditionalBinaryFunction && equals((ConditionalBinaryFunction<?, ?, ?>) that));
     }
 
     /**
@@ -83,7 +91,7 @@
      * @param that ConditionalBinaryFunction to test
      * @return boolean
      */
-    public boolean equals(ConditionalBinaryFunction that) {
+    public boolean equals(ConditionalBinaryFunction<?, ?, ?> that) {
         return null != that
                 && (null == ifPred ? null == that.ifPred : ifPred.equals(that.ifPred))
                 && (null == thenFunc ? null == that.thenFunc : thenFunc.equals(that.thenFunc))

Modified: commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/ConditionalBinaryPredicate.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/ConditionalBinaryPredicate.java?rev=665786&r1=665785&r2=665786&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/ConditionalBinaryPredicate.java (original)
+++ commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/ConditionalBinaryPredicate.java Mon Jun  9 10:17:39 2008
@@ -40,12 +40,12 @@
  * @version $Revision$ $Date$
  * @author Rodney Waldhoff
  */
-public final class ConditionalBinaryPredicate implements BinaryPredicate, Serializable {
+public final class ConditionalBinaryPredicate<L, R> implements BinaryPredicate<L, R>, Serializable {
     // attributes
     // ------------------------------------------------------------------------
-    private BinaryPredicate ifPred = null;
-    private BinaryPredicate thenPred = null;
-    private BinaryPredicate elsePred = null;
+    private BinaryPredicate<? super L, ? super R> ifPred = null;
+    private BinaryPredicate<? super L, ? super R> thenPred = null;
+    private BinaryPredicate<? super L, ? super R> elsePred = null;
 
     // constructor
     // ------------------------------------------------------------------------
@@ -55,7 +55,8 @@
      * @param thenPred then
      * @param elsePred else
      */
-    public ConditionalBinaryPredicate(BinaryPredicate ifPred, BinaryPredicate thenPred, BinaryPredicate elsePred) {
+    public ConditionalBinaryPredicate(BinaryPredicate<? super L, ? super R> ifPred,
+            BinaryPredicate<? super L, ? super R> thenPred, BinaryPredicate<? super L, ? super R> elsePred) {
         this.ifPred = ifPred;
         this.thenPred = thenPred;
         this.elsePred = elsePred;
@@ -66,7 +67,7 @@
     /**
      * {@inheritDoc}
      */
-    public boolean test(Object left, Object right) {
+    public boolean test(L left, R right) {
         return ifPred.test(left, right) ? thenPred.test(left, right) : elsePred.test(left, right);
     }
 
@@ -75,7 +76,7 @@
      */
     public boolean equals(Object that) {
         return that == this
-                || (that instanceof ConditionalBinaryPredicate && equals((ConditionalBinaryPredicate) that));
+                || (that instanceof ConditionalBinaryPredicate && equals((ConditionalBinaryPredicate<?, ?>) that));
     }
 
     /**
@@ -83,7 +84,7 @@
      * @param that ConditionalBinaryPredicate to test
      * @return boolean
      */
-    public boolean equals(ConditionalBinaryPredicate that) {
+    public boolean equals(ConditionalBinaryPredicate<?, ?> that) {
         return null != that
                 && (null == ifPred ? null == that.ifPred : ifPred.equals(that.ifPred))
                 && (null == thenPred ? null == that.thenPred : thenPred.equals(that.thenPred))

Modified: commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/ConditionalBinaryProcedure.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/ConditionalBinaryProcedure.java?rev=665786&r1=665785&r2=665786&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/ConditionalBinaryProcedure.java (original)
+++ commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/ConditionalBinaryProcedure.java Mon Jun  9 10:17:39 2008
@@ -41,13 +41,13 @@
  * @version $Revision$ $Date$
  * @author Rodney Waldhoff
  */
-public final class ConditionalBinaryProcedure implements BinaryProcedure, Serializable {
+public final class ConditionalBinaryProcedure<L, R> implements BinaryProcedure<L, R>, Serializable {
 
     // attributes
     // ------------------------------------------------------------------------
-    private BinaryPredicate ifPred = null;
-    private BinaryProcedure thenProc = null;
-    private BinaryProcedure elseProc = null;
+    private BinaryPredicate<? super L, ? super R> ifPred;
+    private BinaryProcedure<? super L, ? super R> thenProc;
+    private BinaryProcedure<? super L, ? super R> elseProc;
 
     // constructor
     // ------------------------------------------------------------------------
@@ -57,7 +57,8 @@
      * @param ifPred to evaluate
      * @param thenProc if <code>ifPred</code> yields <code>true</code>
      */
-    public ConditionalBinaryProcedure(BinaryPredicate ifPred, BinaryProcedure thenProc) {
+    public ConditionalBinaryProcedure(BinaryPredicate<? super L, ? super R> ifPred,
+            BinaryProcedure<? super L, ? super R> thenProc) {
         this(ifPred, thenProc, NoOp.instance());
     }
     
@@ -67,7 +68,8 @@
      * @param thenProc if <code>ifPred</code> yields <code>true</code>
      * @param elseProc if <code>ifPred</code> yields <code>false</code>
      */
-    public ConditionalBinaryProcedure(BinaryPredicate ifPred, BinaryProcedure thenProc, BinaryProcedure elseProc) {
+    public ConditionalBinaryProcedure(BinaryPredicate<? super L, ? super R> ifPred,
+            BinaryProcedure<? super L, ? super R> thenProc, BinaryProcedure<? super L, ? super R> elseProc) {
         this.ifPred = ifPred;
         this.thenProc = thenProc;
         this.elseProc = elseProc;
@@ -79,7 +81,7 @@
     /**
      * {@inheritDoc}
      */
-    public void run(Object left, Object right) {
+    public void run(L left, R right) {
         if (ifPred.test(left, right)) {
             thenProc.run(left, right);
         } else {
@@ -92,7 +94,7 @@
      */
     public boolean equals(Object that) {
         return that == this
-                || (that instanceof ConditionalBinaryProcedure && equals((ConditionalBinaryProcedure) that));
+                || (that instanceof ConditionalBinaryProcedure && equals((ConditionalBinaryProcedure<?, ?>) that));
     }
 
     /**
@@ -100,7 +102,7 @@
      * @param that compared object
      * @return boolean
      */
-    public boolean equals(ConditionalBinaryProcedure that) {
+    public boolean equals(ConditionalBinaryProcedure<?, ?> that) {
         return null != that
                 && (null == ifPred ? null == that.ifPred : ifPred.equals(that.ifPred))
                 && (null == thenProc ? null == that.thenProc : thenProc.equals(that.thenProc))

Modified: commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/ConditionalFunction.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/ConditionalFunction.java?rev=665786&r1=665785&r2=665786&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/ConditionalFunction.java (original)
+++ commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/ConditionalFunction.java Mon Jun  9 10:17:39 2008
@@ -41,12 +41,12 @@
  * @version $Revision$ $Date$
  * @author Rodney Waldhoff
  */
-public final class ConditionalFunction implements Function, Serializable {
+public final class ConditionalFunction<T> implements Function<T>, Serializable {
     // attributes
     // ------------------------------------------------------------------------
     private Predicate ifPred = null;
-    private Function thenFunc = null;
-    private Function elseFunc = null;
+    private Function<? extends T> thenFunc = null;
+    private Function<? extends T> elseFunc = null;
 
     // constructor
     // ------------------------------------------------------------------------
@@ -56,7 +56,7 @@
      * @param thenFunc then
      * @param elseFunc else
      */
-    public ConditionalFunction(Predicate ifPred, Function thenFunc, Function elseFunc) {
+    public ConditionalFunction(Predicate ifPred, Function<? extends T> thenFunc, Function<? extends T> elseFunc) {
         this.ifPred = ifPred;
         this.thenFunc = thenFunc;
         this.elseFunc = elseFunc;
@@ -67,7 +67,7 @@
     /**
      * {@inheritDoc}
      */
-    public Object evaluate() {
+    public T evaluate() {
         return ifPred.test() ? thenFunc.evaluate() : elseFunc.evaluate();
     }
 
@@ -75,7 +75,7 @@
      * {@inheritDoc}
      */
     public boolean equals(Object that) {
-        return that == this || (that instanceof ConditionalFunction && equals((ConditionalFunction) that));
+        return that == this || (that instanceof ConditionalFunction && equals((ConditionalFunction<?>) that));
     }
 
     /**
@@ -83,7 +83,7 @@
      * @param that ConditionalFunction to test
      * @return boolean
      */
-    public boolean equals(ConditionalFunction that) {
+    public boolean equals(ConditionalFunction<?> that) {
         return null != that
                 && (null == ifPred ? null == that.ifPred : ifPred.equals(that.ifPred))
                 && (null == thenFunc ? null == that.thenFunc : thenFunc.equals(that.thenFunc))

Modified: commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/ConditionalUnaryFunction.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/ConditionalUnaryFunction.java?rev=665786&r1=665785&r2=665786&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/ConditionalUnaryFunction.java (original)
+++ commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/ConditionalUnaryFunction.java Mon Jun  9 10:17:39 2008
@@ -41,12 +41,12 @@
  * @version $Revision$ $Date$
  * @author Rodney Waldhoff
  */
-public final class ConditionalUnaryFunction implements UnaryFunction, Serializable {
+public final class ConditionalUnaryFunction<A, T> implements UnaryFunction<A, T>, Serializable {
     // attributes
     // ------------------------------------------------------------------------
-    private UnaryPredicate ifPred = null;
-    private UnaryFunction thenFunc = null;
-    private UnaryFunction elseFunc = null;
+    private UnaryPredicate<? super A> ifPred;
+    private UnaryFunction<? super A, ? extends T> thenFunc;
+    private UnaryFunction<? super A, ? extends T> elseFunc;
 
     // constructor
     // ------------------------------------------------------------------------
@@ -56,7 +56,8 @@
      * @param thenPred then
      * @param elsePred else
      */
-    public ConditionalUnaryFunction(UnaryPredicate ifPred, UnaryFunction thenPred, UnaryFunction elsePred) {
+    public ConditionalUnaryFunction(UnaryPredicate<? super A> ifPred, UnaryFunction<? super A, ? extends T> thenPred,
+            UnaryFunction<? super A, ? extends T> elsePred) {
         this.ifPred = ifPred;
         this.thenFunc = thenPred;
         this.elseFunc = elsePred;
@@ -67,7 +68,7 @@
     /**
      * {@inheritDoc}
      */
-    public Object evaluate(Object obj) {
+    public T evaluate(A obj) {
         return ifPred.test(obj) ? thenFunc.evaluate(obj) : elseFunc.evaluate(obj);
     }
 
@@ -75,7 +76,7 @@
      * {@inheritDoc}
      */
     public boolean equals(Object that) {
-        return that == this || (that instanceof ConditionalUnaryFunction && equals((ConditionalUnaryFunction) that));
+        return that == this || (that instanceof ConditionalUnaryFunction && equals((ConditionalUnaryFunction<?, ?>) that));
     }
 
     /**
@@ -83,7 +84,7 @@
      * @param that ConditionalUnaryFunction to test
      * @return boolean
      */
-    public boolean equals(ConditionalUnaryFunction that) {
+    public boolean equals(ConditionalUnaryFunction<?, ?> that) {
         return null != that
                 && (null == ifPred ? null == that.ifPred : ifPred.equals(that.ifPred))
                 && (null == thenFunc ? null == that.thenFunc : thenFunc.equals(that.thenFunc))

Modified: commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/ConditionalUnaryPredicate.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/ConditionalUnaryPredicate.java?rev=665786&r1=665785&r2=665786&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/ConditionalUnaryPredicate.java (original)
+++ commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/ConditionalUnaryPredicate.java Mon Jun  9 10:17:39 2008
@@ -40,12 +40,12 @@
  * @version $Revision$ $Date$
  * @author Rodney Waldhoff
  */
-public final class ConditionalUnaryPredicate implements UnaryPredicate, Serializable {
+public final class ConditionalUnaryPredicate<A> implements UnaryPredicate<A>, Serializable {
     // attributes
     // ------------------------------------------------------------------------
-    private UnaryPredicate ifPred = null;
-    private UnaryPredicate thenPred = null;
-    private UnaryPredicate elsePred = null;
+    private UnaryPredicate<? super A> ifPred = null;
+    private UnaryPredicate<? super A> thenPred = null;
+    private UnaryPredicate<? super A> elsePred = null;
 
     // constructor
     // ------------------------------------------------------------------------
@@ -55,7 +55,8 @@
      * @param thenPred then
      * @param elsePred else
      */
-    public ConditionalUnaryPredicate(UnaryPredicate ifPred, UnaryPredicate thenPred, UnaryPredicate elsePred) {
+    public ConditionalUnaryPredicate(UnaryPredicate<? super A> ifPred, UnaryPredicate<? super A> thenPred,
+            UnaryPredicate<? super A> elsePred) {
         this.ifPred = ifPred;
         this.thenPred = thenPred;
         this.elsePred = elsePred;
@@ -66,7 +67,7 @@
     /**
      * {@inheritDoc}
      */
-    public boolean test(Object obj) {
+    public boolean test(A obj) {
         return ifPred.test(obj) ? thenPred.test(obj) : elsePred.test(obj);
     }
 
@@ -74,7 +75,7 @@
      * {@inheritDoc}
      */
     public boolean equals(Object that) {
-        return that == this || (that instanceof ConditionalUnaryPredicate && equals((ConditionalUnaryPredicate) that));
+        return that == this || (that instanceof ConditionalUnaryPredicate && equals((ConditionalUnaryPredicate<?>) that));
     }
 
     /**
@@ -82,7 +83,7 @@
      * @param that ConditionalUnaryPredicate to test
      * @return boolean
      */
-    public boolean equals(ConditionalUnaryPredicate that) {
+    public boolean equals(ConditionalUnaryPredicate<?> that) {
         return null != that
                 && (null == ifPred ? null == that.ifPred : ifPred.equals(that.ifPred))
                 && (null == thenPred ? null == that.thenPred : thenPred.equals(that.thenPred))

Modified: commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/ConditionalUnaryProcedure.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/ConditionalUnaryProcedure.java?rev=665786&r1=665785&r2=665786&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/ConditionalUnaryProcedure.java (original)
+++ commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/ConditionalUnaryProcedure.java Mon Jun  9 10:17:39 2008
@@ -41,12 +41,12 @@
  * @version $Revision$ $Date$
  * @author Rodney Waldhoff
  */
-public final class ConditionalUnaryProcedure implements UnaryProcedure, Serializable {
+public final class ConditionalUnaryProcedure<A> implements UnaryProcedure<A>, Serializable {
     // attributes
     // ------------------------------------------------------------------------
-    private UnaryPredicate ifPred = null;
-    private UnaryProcedure thenProc = null;
-    private UnaryProcedure elseProc = null;
+    private UnaryPredicate<? super A> ifPred = null;
+    private UnaryProcedure<? super A> thenProc = null;
+    private UnaryProcedure<? super A> elseProc = null;
 
     // constructor
     // ------------------------------------------------------------------------
@@ -55,7 +55,7 @@
      * @param ifPred if
      * @param thenProc then
      */
-    public ConditionalUnaryProcedure(UnaryPredicate ifPred, UnaryProcedure thenProc) {
+    public ConditionalUnaryProcedure(UnaryPredicate<? super A> ifPred, UnaryProcedure<? super A> thenProc) {
     	this(ifPred, thenProc, NoOp.instance());
 	}
 
@@ -65,7 +65,7 @@
      * @param thenProc then
      * @param elseProc else
      */
-    public ConditionalUnaryProcedure(UnaryPredicate ifPred, UnaryProcedure thenProc, UnaryProcedure elseProc) {
+    public ConditionalUnaryProcedure(UnaryPredicate<? super A> ifPred, UnaryProcedure<? super A> thenProc, UnaryProcedure<? super A> elseProc) {
         this.ifPred = ifPred;
         this.thenProc = thenProc;
         this.elseProc = elseProc;
@@ -76,7 +76,7 @@
     /**
      * {@inheritDoc}
      */
-    public void run(Object obj) {
+    public void run(A obj) {
         if (ifPred.test(obj)) {
             thenProc.run(obj);
         } else {
@@ -88,7 +88,7 @@
      * {@inheritDoc}
      */
     public boolean equals(Object that) {
-        return that == this || (that instanceof ConditionalUnaryProcedure && equals((ConditionalUnaryProcedure) that));
+        return that == this || (that instanceof ConditionalUnaryProcedure && equals((ConditionalUnaryProcedure<?>) that));
     }
 
     /**
@@ -96,7 +96,7 @@
      * @param that ConditionalUnaryProcedure to test
      * @return boolean
      */
-    public boolean equals(ConditionalUnaryProcedure that) {
+    public boolean equals(ConditionalUnaryProcedure<?> that) {
         return null != that
                 && (null == ifPred ? null == that.ifPred : ifPred.equals(that.ifPred))
                 && (null == thenProc ? null == that.thenProc : thenProc.equals(that.thenProc))

Modified: commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/Or.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/Or.java?rev=665786&r1=665785&r2=665786&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/Or.java (original)
+++ commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/Or.java Mon Jun  9 10:17:39 2008
@@ -90,8 +90,8 @@
      * {@inheritDoc}
      */
     public boolean test() {
-        for (Iterator iter = getPredicateIterator(); iter.hasNext();) {
-            if (((Predicate) iter.next()).test()) {
+        for (Iterator<Predicate> iter = getPredicateIterator(); iter.hasNext();) {
+            if (iter.next().test()) {
                 return true;
             }
         }

Modified: commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/Sequence.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/Sequence.java?rev=665786&r1=665785&r2=665786&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/Sequence.java (original)
+++ commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/Sequence.java Mon Jun  9 10:17:39 2008
@@ -44,7 +44,7 @@
 
     // attributes
     // ------------------------------------------------------------------------
-    private List list = new ArrayList();
+    private List<Procedure> list = new ArrayList<Procedure>();
 
     // constructor
     // ------------------------------------------------------------------------
@@ -90,8 +90,8 @@
      * {@inheritDoc}
      */
     public void run() {
-        for (ListIterator iter = list.listIterator(list.size()); iter.hasPrevious();) {
-            ((Procedure) iter.previous()).run();
+        for (ListIterator<Procedure> iter = list.listIterator(list.size()); iter.hasPrevious();) {
+            iter.previous().run();
         }
     }
 

Modified: commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/TransposedFunction.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/TransposedFunction.java?rev=665786&r1=665785&r2=665786&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/TransposedFunction.java (original)
+++ commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/TransposedFunction.java Mon Jun  9 10:17:39 2008
@@ -39,10 +39,10 @@
  * @version $Revision$ $Date$
  * @author Rodney Waldhoff
  */
-public class TransposedFunction implements BinaryFunction, Serializable {
+public class TransposedFunction<L, R, T> implements BinaryFunction<L, R, T>, Serializable {
     // attributes
     // ------------------------------------------------------------------------
-    private BinaryFunction function = null;
+    private BinaryFunction<? super R, ? super L, ? extends T> function = null;
 
     // constructor
     // ------------------------------------------------------------------------
@@ -50,7 +50,10 @@
      * Create a new TransposedFunction.
      * @param f BinaryFunction to transpose.
      */
-    public TransposedFunction(BinaryFunction f) {
+    public TransposedFunction(BinaryFunction<? super R, ? super L, ? extends T> f) {
+        if (f == null) {
+            throw new IllegalArgumentException("BinaryFunction argument was null");
+        }
         function = f;
     }
 
@@ -59,7 +62,7 @@
     /**
      * {@inheritDoc}
      */
-    public Object evaluate(Object left, Object right) {
+    public T evaluate(L left, R right) {
         return function.evaluate(right, left);
     }
 
@@ -67,7 +70,7 @@
      * {@inheritDoc}
      */
     public boolean equals(Object that) {
-        return that == this || (that instanceof TransposedFunction && equals((TransposedFunction) that));
+        return that == this || (that instanceof TransposedFunction && equals((TransposedFunction<?, ?, ?>) that));
     }
 
     /**
@@ -75,7 +78,7 @@
      * @param that TransposedFunction to test
      * @return boolean
      */
-    public boolean equals(TransposedFunction that) {
+    public boolean equals(TransposedFunction<?, ?, ?> that) {
         return null != that && (null == function ? null == that.function : function.equals(that.function));
     }
 
@@ -104,8 +107,8 @@
      * @param f BinaryFunction to transpose
      * @return TransposedFunction
      */
-    public static TransposedFunction transpose(BinaryFunction f) {
-        return null == f ? null : new TransposedFunction(f);
+    public static <L, R, T> TransposedFunction<R, L, T> transpose(BinaryFunction<? super L, ? super R, ? extends T> f) {
+        return null == f ? null : new TransposedFunction<R, L, T>(f);
     }
 
 }

Modified: commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/TransposedPredicate.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/TransposedPredicate.java?rev=665786&r1=665785&r2=665786&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/TransposedPredicate.java (original)
+++ commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/TransposedPredicate.java Mon Jun  9 10:17:39 2008
@@ -39,10 +39,10 @@
  * @version $Revision$ $Date$
  * @author Rodney Waldhoff
  */
-public class TransposedPredicate implements BinaryPredicate, Serializable {
+public class TransposedPredicate<L, R> implements BinaryPredicate<L, R>, Serializable {
     // attributes
     // ------------------------------------------------------------------------
-    private BinaryPredicate predicate = null;
+    private BinaryPredicate<? super R, ? super L> predicate = null;
 
     // constructor
     // ------------------------------------------------------------------------
@@ -50,7 +50,10 @@
      * Create a new TransposedPredicate.
      * @param p the BinaryPredicate to transpose
      */
-    public TransposedPredicate(BinaryPredicate p) {
+    public TransposedPredicate(BinaryPredicate<? super R, ? super L> p) {
+        if (p == null) {
+            throw new IllegalArgumentException("BinaryPredicate argument must not be null");
+        }
         predicate = p;
     }
 
@@ -59,7 +62,7 @@
     /**
      * {@inheritDoc}
      */
-    public boolean test(Object left, Object right) {
+    public boolean test(L left, R right) {
         return predicate.test(right, left);
     }
 
@@ -67,7 +70,7 @@
      * {@inheritDoc}
      */
     public boolean equals(Object that) {
-        return that == this || (that instanceof TransposedPredicate && equals((TransposedPredicate) that));
+        return that == this || (that instanceof TransposedPredicate && equals((TransposedPredicate<?, ?>) that));
     }
 
     /**
@@ -75,7 +78,7 @@
      * @param that the TransposedPredicate to test
      * @return boolean
      */
-    public boolean equals(TransposedPredicate that) {
+    public boolean equals(TransposedPredicate<?, ?> that) {
         return null != that && (null == predicate ? null == that.predicate : predicate.equals(that.predicate));
     }
 
@@ -104,8 +107,8 @@
      * @param p BinaryPredicate to transpose
      * @return TransposedPredicate
      */
-    public static TransposedPredicate transpose(BinaryPredicate p) {
-        return null == p ? null : new TransposedPredicate(p);
+    public static <L, R> TransposedPredicate<R, L> transpose(BinaryPredicate<? super L, ? super R> p) {
+        return null == p ? null : new TransposedPredicate<R, L>(p);
     }
 
 }

Modified: commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/TransposedProcedure.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/TransposedProcedure.java?rev=665786&r1=665785&r2=665786&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/TransposedProcedure.java (original)
+++ commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/TransposedProcedure.java Mon Jun  9 10:17:39 2008
@@ -39,10 +39,10 @@
  * @version $Revision$ $Date$
  * @author Rodney Waldhoff
  */
-public class TransposedProcedure implements BinaryProcedure, Serializable {
+public class TransposedProcedure<L, R> implements BinaryProcedure<L, R>, Serializable {
     // attributes
     // ------------------------------------------------------------------------
-    private BinaryProcedure procedure = null;
+    private BinaryProcedure<? super R, ? super L> procedure = null;
 
     // constructor
     // ------------------------------------------------------------------------
@@ -50,7 +50,7 @@
      * Create a new TransposedProcedure.
      * @param p BinaryProcedure to transpose
      */
-    public TransposedProcedure(BinaryProcedure p) {
+    public TransposedProcedure(BinaryProcedure<? super R, ? super L> p) {
         procedure = p;
     }
 
@@ -59,7 +59,7 @@
     /**
      * {@inheritDoc}
      */
-    public void run(Object left, Object right) {
+    public void run(L left, R right) {
         procedure.run(right, left);
     }
 
@@ -67,7 +67,7 @@
      * {@inheritDoc}
      */
     public boolean equals(Object that) {
-        return that == this || (that instanceof TransposedProcedure && equals((TransposedProcedure) that));
+        return that == this || (that instanceof TransposedProcedure && equals((TransposedProcedure<?, ?>) that));
     }
 
     /**
@@ -75,7 +75,7 @@
      * @param that TransposedPredicate to test
      * @return boolean
      */
-    public boolean equals(TransposedProcedure that) {
+    public boolean equals(TransposedProcedure<?, ?> that) {
         return null != that && (null == procedure ? null == that.procedure : procedure.equals(that.procedure));
     }
 
@@ -104,8 +104,8 @@
      * @param p to transpose
      * @return TransposedProcedure
      */
-    public static TransposedProcedure transpose(BinaryProcedure p) {
-        return null == p ? null : new TransposedProcedure(p);
+    public static <L, R> TransposedProcedure<R, L> transpose(BinaryProcedure<? super L, ? super R> p) {
+        return null == p ? null : new TransposedProcedure<R, L>(p);
     }
 
 }

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=665786&r1=665785&r2=665786&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 Mon Jun  9 10:17:39 2008
@@ -36,7 +36,7 @@
  * @version $Revision$ $Date$
  * @author Rodney Waldhoff
  */
-public final class UnaryAnd extends BaseUnaryPredicateList {
+public final class UnaryAnd<A> extends BaseUnaryPredicateList<A> {
 
     // constructor
     // ------------------------------------------------------------------------
@@ -51,7 +51,7 @@
      * Create a new UnaryAnd.
      * @param p UnaryPredicate to add
      */
-    public UnaryAnd(UnaryPredicate p) {
+    public UnaryAnd(UnaryPredicate<? super A> p) {
         super(p);
     }
 
@@ -60,7 +60,7 @@
      * @param p UnaryPredicate to add
      * @param q UnaryPredicate to add
      */
-    public UnaryAnd(UnaryPredicate p, UnaryPredicate q) {
+    public UnaryAnd(UnaryPredicate<? super A> p, UnaryPredicate<? super A> q) {
         super(p, q);
     }
 
@@ -70,7 +70,7 @@
      * @param q UnaryPredicate to add
      * @param r UnaryPredicate to add
      */
-    public UnaryAnd(UnaryPredicate p, UnaryPredicate q, UnaryPredicate r) {
+    public UnaryAnd(UnaryPredicate<? super A> p, UnaryPredicate<? super A> q, UnaryPredicate<? super A> r) {
         super(p, q, r);
     }
 
@@ -81,7 +81,7 @@
      * @param p UnaryPredicate to add
      * @return this
      */
-    public UnaryAnd and(UnaryPredicate p) {
+    public UnaryAnd and(UnaryPredicate<? super A> p) {
         super.addUnaryPredicate(p);
         return this;
     }
@@ -91,9 +91,9 @@
     /**
      * {@inheritDoc}
      */
-    public boolean test(Object obj) {
-        for (Iterator iter = getUnaryPredicateIterator(); iter.hasNext();) {
-            if (!((UnaryPredicate) iter.next()).test(obj)) {
+    public boolean test(A obj) {
+        for (Iterator<UnaryPredicate<? super A>> iter = getUnaryPredicateIterator(); iter.hasNext();) {
+            if (!iter.next().test(obj)) {
                 return false;
             }
         }
@@ -104,7 +104,7 @@
      * {@inheritDoc}
      */
     public boolean equals(Object that) {
-        return that == this || (that instanceof UnaryAnd && equals((UnaryAnd) that));
+        return that == this || (that instanceof UnaryAnd && equals((UnaryAnd<?>) that));
     }
 
     /**
@@ -112,7 +112,7 @@
      * @param that UnaryAnd to test
      * @return boolean
      */
-    public boolean equals(UnaryAnd that) {
+    public boolean equals(UnaryAnd<?> that) {
         return getUnaryPredicateListEquals(that);
     }
 

Modified: commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/UnaryCompositeBinaryFunction.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/UnaryCompositeBinaryFunction.java?rev=665786&r1=665785&r2=665786&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/UnaryCompositeBinaryFunction.java (original)
+++ commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/UnaryCompositeBinaryFunction.java Mon Jun  9 10:17:39 2008
@@ -38,12 +38,35 @@
  * @version $Revision$ $Date$
  * @author Rodney Waldhoff
  */
-public class UnaryCompositeBinaryFunction implements BinaryFunction, Serializable {
-    // attributes
-    // ------------------------------------------------------------------------
-    private BinaryFunction binary = null;
-    private UnaryFunction leftUnary = null;
-    private UnaryFunction rightUnary = null;
+public class UnaryCompositeBinaryFunction<L, R, T> implements BinaryFunction<L, R, T>, Serializable {
+
+    private class Helper<G, H> implements BinaryFunction<L, R, T>, Serializable {
+        private BinaryFunction<? super G, ? super H, ? extends T> f;
+        private UnaryFunction<? super L, ? extends G> g;
+        private UnaryFunction<? super R, ? extends H> h;
+
+        /**
+         * Create a new Helper.
+         * @param f BinaryFunction to receive <code>(output(g), output(h))</code>
+         * @param g left UnaryFunction
+         * @param h right UnaryFunction
+         */
+        public Helper(BinaryFunction<? super G, ? super H, ? extends T> f, UnaryFunction<? super L, ? extends G> g,
+                UnaryFunction<? super R, ? extends H> h) {
+            this.f = f;
+            this.g = g;
+            this.h = h;
+        }
+
+        /**
+         * {@inheritDoc}
+         */
+        public T evaluate(L left, R right) {
+            return f.evaluate(g.evaluate(left), h.evaluate(right));
+        }
+    }
+
+    private Helper<?, ?> helper;
 
     // constructor
     // ------------------------------------------------------------------------
@@ -53,10 +76,15 @@
      * @param g left UnaryFunction
      * @param h right UnaryFunction
      */
-    public UnaryCompositeBinaryFunction(BinaryFunction f, UnaryFunction g, UnaryFunction h) {
-        binary = f;
-        leftUnary = g;
-        rightUnary = h;
+    public <G, H> UnaryCompositeBinaryFunction(BinaryFunction<? super G, ? super H, ? extends T> f,
+            UnaryFunction<? super L, ? extends G> g, UnaryFunction<? super R, ? extends H> h) {
+        if (f == null) {
+            throw new IllegalArgumentException("BinaryFunction must not be null");
+        }
+        if (g == null || h == null) {
+            throw new IllegalArgumentException("Left and right UnaryFunctions may not be null");
+        }
+        this.helper = new Helper<G, H>(f, g, h);
     }
 
     // function interface
@@ -64,8 +92,8 @@
     /**
      * {@inheritDoc}
      */
-    public Object evaluate(Object left, Object right) {
-        return binary.evaluate(leftUnary.evaluate(left), rightUnary.evaluate(right));
+    public T evaluate(L left, R right) {
+        return helper.evaluate(left, right);
     }
 
     /**
@@ -73,7 +101,7 @@
      */
     public boolean equals(Object that) {
         return that == this
-                || (that instanceof UnaryCompositeBinaryFunction && equals((UnaryCompositeBinaryFunction) that));
+                || (that instanceof UnaryCompositeBinaryFunction && equals((UnaryCompositeBinaryFunction<?, ?, ?>) that));
     }
 
     /**
@@ -81,11 +109,11 @@
      * @param that UnaryCompositeBinaryFunction to test
      * @return boolean
      */
-    public boolean equals(UnaryCompositeBinaryFunction that) {
-        return (null != that)
-                && (null == binary ? null == that.binary : binary.equals(that.binary))
-                && (null == leftUnary ? null == that.leftUnary : leftUnary.equals(that.leftUnary))
-                && (null == rightUnary ? null == that.rightUnary : rightUnary.equals(that.rightUnary));
+    public boolean equals(UnaryCompositeBinaryFunction<?, ?, ?> that) {
+        return null != that
+                && helper.f.equals(that.helper.f)
+                && helper.g.equals(that.helper.g)
+                && helper.h.equals(that.helper.h);
     }
 
     /**
@@ -93,18 +121,12 @@
      */
     public int hashCode() {
         int hash = "UnaryCompositeBinaryFunction".hashCode();
-        if (null != binary) {
-            hash <<= 4;
-            hash ^= binary.hashCode();
-        }
-        if (null != leftUnary) {
-            hash <<= 4;
-            hash ^= leftUnary.hashCode();
-        }
-        if (null != rightUnary) {
-            hash <<= 4;
-            hash ^= rightUnary.hashCode();
-        }
+        hash <<= 4;
+        hash ^= helper.f.hashCode();
+        hash <<= 4;
+        hash ^= helper.g.hashCode();
+        hash <<= 4;
+        hash ^= helper.h.hashCode();
         return hash;
     }
 
@@ -112,7 +134,7 @@
      * {@inheritDoc}
      */
     public String toString() {
-        return "UnaryCompositeBinaryFunction<" + binary + ";" + leftUnary + ";" + rightUnary + ">";
+        return "UnaryCompositeBinaryFunction<" + helper.f + ";" + helper.g + ";" + helper.h + ">";
     }
 
 }

Modified: commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/UnaryCompositeBinaryPredicate.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/UnaryCompositeBinaryPredicate.java?rev=665786&r1=665785&r2=665786&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/UnaryCompositeBinaryPredicate.java (original)
+++ commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/UnaryCompositeBinaryPredicate.java Mon Jun  9 10:17:39 2008
@@ -38,12 +38,36 @@
  * @version $Revision$ $Date$
  * @author Rodney Waldhoff
  */
-public class UnaryCompositeBinaryPredicate implements BinaryPredicate, Serializable {
+public class UnaryCompositeBinaryPredicate<L, R> implements BinaryPredicate<L, R>, Serializable {
+    private class Helper<G, H> implements BinaryPredicate<L, R>, Serializable {
+        private BinaryPredicate<? super G, ? super H> f;
+        private UnaryFunction<? super L, ? extends G> g;
+        private UnaryFunction<? super R, ? extends H> h;
+
+        /**
+         * Create a new Helper.
+         * @param f BinaryPredicate to test <i>output(</i><code>f</code><i>), output(</i><code>g</code><i>)</i>
+         * @param g left UnaryFunction
+         * @param h right UnaryFunction
+         */
+        public Helper(BinaryPredicate<? super G, ? super H> f, UnaryFunction<? super L, ? extends G> g,
+                UnaryFunction<? super R, ? extends H> h) {
+            this.f = f;
+            this.g = g;
+            this.h = h;
+        }
+
+        /**
+         * {@inheritDoc}
+         */
+        public boolean test(L left, R right) {
+            return f.test(g.evaluate(left), h.evaluate(right));
+        }
+    }
+
     // attributes
     // ------------------------------------------------------------------------
-    private BinaryPredicate binary = null;
-    private UnaryFunction leftUnary = null;
-    private UnaryFunction rightUnary = null;
+    private Helper<?, ?> helper;
 
     // constructor
     // ------------------------------------------------------------------------
@@ -53,10 +77,15 @@
      * @param g left UnaryFunction
      * @param h right UnaryFunction
      */
-    public UnaryCompositeBinaryPredicate(BinaryPredicate f, UnaryFunction g, UnaryFunction h) {
-        binary = f;
-        leftUnary = g;
-        rightUnary = h;
+    public <G, H> UnaryCompositeBinaryPredicate(final BinaryPredicate<? super G, ? super H> f,
+            final UnaryFunction<? super L, ? extends G> g, final UnaryFunction<? super R, ? extends H> h) {
+        if (f == null) {
+            throw new IllegalArgumentException("BinaryPredicate must not be null");
+        }
+        if (g == null || h == null) {
+            throw new IllegalArgumentException("Left and right UnaryFunctions may not be null");
+        }
+        helper = new Helper<G, H>(f, g, h);
     }
 
     // function interface
@@ -64,8 +93,8 @@
     /**
      * {@inheritDoc}
      */
-    public boolean test(Object left, Object right) {
-        return binary.test(leftUnary.evaluate(left), rightUnary.evaluate(right));
+    public boolean test(L left, R right) {
+        return helper.test(left, right);
     }
 
     /**
@@ -73,7 +102,7 @@
      */
     public boolean equals(Object that) {
         return that == this
-                || (that instanceof UnaryCompositeBinaryPredicate && equals((UnaryCompositeBinaryPredicate) that));
+                || (that instanceof UnaryCompositeBinaryPredicate && equals((UnaryCompositeBinaryPredicate<?, ?>) that));
     }
 
     /**
@@ -81,11 +110,9 @@
      * @param that UnaryCompositeBinaryPredicate to test
      * @return boolean
      */
-    public boolean equals(UnaryCompositeBinaryPredicate that) {
-        return (null != that)
-                && (null == binary ? null == that.binary : binary.equals(that.binary))
-                && (null == leftUnary ? null == that.leftUnary : leftUnary.equals(that.leftUnary))
-                && (null == rightUnary ? null == that.rightUnary : rightUnary.equals(that.rightUnary));
+    public boolean equals(UnaryCompositeBinaryPredicate<?, ?> that) {
+        return null != that && helper.f.equals(that.helper.f) && helper.g.equals(that.helper.g)
+                && helper.h.equals(that.helper.h);
     }
 
     /**
@@ -93,18 +120,12 @@
      */
     public int hashCode() {
         int hash = "UnaryCompositeBinaryPredicate".hashCode();
-        if (null != binary) {
-            hash <<= 4;
-            hash ^= binary.hashCode();
-        }
-        if (null != leftUnary) {
-            hash <<= 4;
-            hash ^= leftUnary.hashCode();
-        }
-        if (null != rightUnary) {
-            hash <<= 4;
-            hash ^= rightUnary.hashCode();
-        }
+        hash <<= 4;
+        hash ^= helper.f.hashCode();
+        hash <<= 4;
+        hash ^= helper.g.hashCode();
+        hash <<= 4;
+        hash ^= helper.h.hashCode();
         return hash;
     }
 
@@ -112,7 +133,7 @@
      * {@inheritDoc}
      */
     public String toString() {
-        return "UnaryCompositeBinaryPredicate<" + binary + ";" + leftUnary + ";" + rightUnary + ">";
+        return "UnaryCompositeBinaryPredicate<" + helper.f + ";" + helper.g + ";" + helper.h + ">";
     }
 
 }

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=665786&r1=665785&r2=665786&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 Mon Jun  9 10:17:39 2008
@@ -34,10 +34,10 @@
  * @version $Revision$ $Date$
  * @author Rodney Waldhoff
  */
-public final class UnaryNot implements UnaryPredicate, Serializable {
+public final class UnaryNot<A> implements UnaryPredicate<A>, Serializable {
     // attributes
     // ------------------------------------------------------------------------
-    private UnaryPredicate predicate = null;
+    private UnaryPredicate<? super A> predicate = null;
 
     // constructor
     // ------------------------------------------------------------------------
@@ -45,7 +45,7 @@
      * Create a new UnaryNot.
      * @param p UnaryPredicate to negate
      */
-    public UnaryNot(UnaryPredicate p) {
+    public UnaryNot(UnaryPredicate<? super A> p) {
         this.predicate = p;
     }
 
@@ -54,7 +54,7 @@
     /**
      * {@inheritDoc}
      */
-    public boolean test(Object obj) {
+    public boolean test(A obj) {
         return !(predicate.test(obj));
     }
 
@@ -62,7 +62,7 @@
      * {@inheritDoc}
      */
     public boolean equals(Object that) {
-        return that == this || (that instanceof UnaryNot && equals((UnaryNot) that));
+        return that == this || (that instanceof UnaryNot && equals((UnaryNot<?>) that));
     }
 
     /**
@@ -70,7 +70,7 @@
      * @param that UnaryNot to test
      * @return boolean
      */
-    public boolean equals(UnaryNot that) {
+    public boolean equals(UnaryNot<?> that) {
         return null != that && (null == predicate ? null == that.predicate : predicate.equals(that.predicate));
     }
 
@@ -97,10 +97,10 @@
     /**
      * Invert a UnaryPredicate.
      * @param pred UnaryPredicate to invert
-     * @return UnaryPredicate
+     * @return UnaryPredicate<A
      */
-    public static UnaryPredicate not(UnaryPredicate pred) {
-        return null == pred ? null : new UnaryNot(pred);
+    public static <A> UnaryPredicate<A> not(UnaryPredicate<? super A> pred) {
+        return null == pred ? null : new UnaryNot<A>(pred);
     }
 
 }

Modified: commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/UnaryOr.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/UnaryOr.java?rev=665786&r1=665785&r2=665786&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/UnaryOr.java (original)
+++ commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/UnaryOr.java Mon Jun  9 10:17:39 2008
@@ -36,7 +36,7 @@
  * @version $Revision$ $Date$
  * @author Rodney Waldhoff
  */
-public final class UnaryOr extends BaseUnaryPredicateList {
+public final class UnaryOr<A> extends BaseUnaryPredicateList<A> {
 
     // constructor
     // ------------------------------------------------------------------------
@@ -51,7 +51,7 @@
      * Create a new UnaryOr.
      * @param p Predicate to add
      */
-    public UnaryOr(UnaryPredicate p) {
+    public UnaryOr(UnaryPredicate<? super A> p) {
         super(p);
     }
 
@@ -60,7 +60,7 @@
      * @param p Predicate to add
      * @param q Predicate to add
      */
-    public UnaryOr(UnaryPredicate p, UnaryPredicate q) {
+    public UnaryOr(UnaryPredicate<? super A> p, UnaryPredicate<? super A> q) {
         super(p, q);
     }
 
@@ -70,7 +70,7 @@
      * @param q Predicate to add
      * @param r Predicate to add
      */
-    public UnaryOr(UnaryPredicate p, UnaryPredicate q, UnaryPredicate r) {
+    public UnaryOr(UnaryPredicate<? super A> p, UnaryPredicate<? super A> q, UnaryPredicate<? super A> r) {
         super(p, q, r);
     }
 
@@ -81,7 +81,7 @@
      * @param p Predicate to add
      * @return this
      */
-    public UnaryOr or(UnaryPredicate p) {
+    public UnaryOr<A> or(UnaryPredicate<? super A> p) {
         super.addUnaryPredicate(p);
         return this;
     }
@@ -91,9 +91,9 @@
     /**
      * {@inheritDoc}
      */
-    public boolean test(Object a) {
-        for (Iterator iter = getUnaryPredicateIterator(); iter.hasNext();) {
-            if (((UnaryPredicate) iter.next()).test(a)) {
+    public boolean test(A a) {
+        for (Iterator<UnaryPredicate<? super A>> iter = getUnaryPredicateIterator(); iter.hasNext();) {
+            if (iter.next().test(a)) {
                 return true;
             }
         }
@@ -104,7 +104,7 @@
      * {@inheritDoc}
      */
     public boolean equals(Object that) {
-        return that == this || (that instanceof UnaryOr && equals((UnaryOr) that));
+        return that == this || (that instanceof UnaryOr && equals((UnaryOr<?>) that));
     }
 
     /**
@@ -112,7 +112,7 @@
      * @param that UnaryOr to test
      * @return boolean
      */
-    public boolean equals(UnaryOr that) {
+    public boolean equals(UnaryOr<?> that) {
         return getUnaryPredicateListEquals(that);
     }
 

Modified: commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/UnarySequence.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/UnarySequence.java?rev=665786&r1=665785&r2=665786&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/UnarySequence.java (original)
+++ commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/UnarySequence.java Mon Jun  9 10:17:39 2008
@@ -40,11 +40,11 @@
  * @version $Revision$ $Date$
  * @author Rodney Waldhoff
  */
-public class UnarySequence implements UnaryProcedure, Serializable {
+public class UnarySequence<A> implements UnaryProcedure<A>, Serializable {
 
     // attributes
     // ------------------------------------------------------------------------
-    private List list = new ArrayList();
+    private List<UnaryProcedure<? super A>> list = new ArrayList<UnaryProcedure<? super A>>();
 
     // constructor
     // ------------------------------------------------------------------------
@@ -58,7 +58,7 @@
      * Create a new UnarySequence.
      * @param p UnaryProcedure to add
      */
-    public UnarySequence(UnaryProcedure p) {
+    public UnarySequence(UnaryProcedure<? super A> p) {
         then(p);
     }
 
@@ -67,7 +67,7 @@
      * @param p UnaryProcedure to add
      * @param q UnaryProcedure to add
      */
-    public UnarySequence(UnaryProcedure p, UnaryProcedure q) {
+    public UnarySequence(UnaryProcedure<? super A> p, UnaryProcedure<? super A> q) {
         then(p);
         then(q);
     }
@@ -79,7 +79,7 @@
      * @param p UnaryProcedure to add
      * @return this
      */
-    public UnarySequence then(UnaryProcedure p) {
+    public UnarySequence<A> then(UnaryProcedure<? super A> p) {
         list.add(p);
         return this;
     }
@@ -89,9 +89,9 @@
     /**
      * {@inheritDoc}
      */
-    public void run(Object obj) {
-        for (ListIterator iter = list.listIterator(list.size()); iter.hasPrevious();) {
-            ((UnaryProcedure) iter.previous()).run(obj);
+    public void run(A obj) {
+        for (ListIterator<UnaryProcedure<? super A>> iter = list.listIterator(list.size()); iter.hasPrevious();) {
+            iter.previous().run(obj);
         }
     }
 
@@ -99,7 +99,7 @@
      * {@inheritDoc}
      */
     public boolean equals(Object that) {
-        return that == this || (that instanceof UnarySequence && equals((UnarySequence) that));
+        return that == this || (that instanceof UnarySequence && equals((UnarySequence<?>) that));
     }
 
     /**
@@ -107,7 +107,7 @@
      * @param that UnarySequence to test
      * @return boolean
      */
-    public boolean equals(UnarySequence that) {
+    public boolean equals(UnarySequence<?> that) {
         // by construction, list is never null
         return null != that && list.equals(that.list);
     }

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=665786&r1=665785&r2=665786&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 Mon Jun  9 10:17:39 2008
@@ -17,7 +17,6 @@
 import java.util.Collection;
 
 import org.apache.commons.functor.UnaryFunction;
-import org.apache.commons.functor.UnaryProcedure;
 import org.apache.commons.functor.generator.util.CollectionTransformer;
 
 /**
@@ -28,10 +27,10 @@
  * @version $Revision$ $Date$
  * @author  Jason Horman (jason@jhorman.org)
  */
-public abstract class BaseGenerator implements Generator {
+public abstract class BaseGenerator<E> implements Generator<E> {
 
     /** A generator can wrap another generator. */
-    private Generator wrappedGenerator = null;
+    private Generator<?> wrappedGenerator = null;
 
     /** Set to true when the generator is {@link #stop stopped}. */
     private boolean stopped = false;
@@ -46,7 +45,7 @@
      * {@link #stop} method to stop the wrapped generator as well.
      * @param generator Generator to wrap
      */
-    public BaseGenerator(Generator generator) {
+    public BaseGenerator(Generator<?> generator) {
         this.wrappedGenerator = generator;
     }
 
@@ -54,22 +53,18 @@
      * Get the generator that is being wrapped.
      * @return Generator
      */
-    protected Generator getWrappedGenerator() {
+    protected Generator<?> getWrappedGenerator() {
         return wrappedGenerator;
     }
 
     /**
      * {@inheritDoc}
-     * Generators must implement this method.
-     */
-    public abstract void run(UnaryProcedure proc);
-
-    /**
-     * {@inheritDoc}
      * Stop the generator. Will stop the wrapped generator if one was set.
      */
     public void stop() {
-        if (wrappedGenerator != null) { wrappedGenerator.stop(); }
+        if (wrappedGenerator != null) {
+            wrappedGenerator.stop();
+        }
         stopped = true;
     }
 
@@ -87,7 +82,7 @@
      * UnaryFunction. An example function might turn the contents of the
      * generator into a {@link Collection} of elements.
      */
-    public final Object to(UnaryFunction transformer) {
+    public final <T> T to(UnaryFunction<Generator<? extends E>, ? extends T> transformer) {
         return transformer.evaluate(this);
     }
 
@@ -95,15 +90,15 @@
      * {@inheritDoc}
      * Same as to(new CollectionTransformer(collection)).
      */
-    public final Collection to(Collection collection) {
-        return (Collection) to(new CollectionTransformer(collection));
+    public final Collection<? super E> to(Collection<? super E> collection) {
+        return to(new CollectionTransformer<E>(collection));
     }
 
     /**
      * {@inheritDoc}
      * Same as to(new CollectionTransformer()).
      */
-    public final Collection toCollection() {
-        return (Collection) to(new CollectionTransformer());
+    public final Collection<E> toCollection() {
+        return (Collection<E>) to(new CollectionTransformer<E>());
     }
 }
\ No newline at end of file

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=665786&r1=665785&r2=665786&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 Mon Jun  9 10:17:39 2008
@@ -26,15 +26,15 @@
  *
  * @version $Revision$ $Date$
  */
-public class FilteredGenerator extends BaseGenerator {
-    private UnaryPredicate pred;
+public class FilteredGenerator<E> extends BaseGenerator<E> {
+    private UnaryPredicate<? super E> pred;
 
     /**
      * Create a new FilteredGenerator.
      * @param wrapped Generator to wrap
      * @param pred filtering UnaryPredicate
      */
-    public FilteredGenerator(Generator wrapped, UnaryPredicate pred) {
+    public FilteredGenerator(Generator<? extends E> wrapped, UnaryPredicate<? super E> pred) {
         super(wrapped);
         if (wrapped == null) {
             throw new IllegalArgumentException("Generator argument was null");
@@ -48,8 +48,16 @@
     /**
      * {@inheritDoc}
      */
-    public void run(UnaryProcedure proc) {
-        getWrappedGenerator().run(new ConditionalUnaryProcedure(pred, proc));
+    public void run(UnaryProcedure<? super E> proc) {
+        getWrappedGenerator().run(new ConditionalUnaryProcedure<E>(pred, proc));
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    protected Generator<? extends E> getWrappedGenerator() {
+        return (Generator<? extends E>) super.getWrappedGenerator();
     }
 
     /**
@@ -62,7 +70,7 @@
         if (obj instanceof FilteredGenerator == false) {
             return false;
         }
-        FilteredGenerator other = (FilteredGenerator) obj;
+        FilteredGenerator<?> other = (FilteredGenerator<?>) obj;
         return other.getWrappedGenerator().equals(getWrappedGenerator()) && other.pred.equals(pred);
     }
 
@@ -72,7 +80,7 @@
     public int hashCode() {
         int result = "FilteredGenerator".hashCode();
         result <<= 2;
-        Generator gen = getWrappedGenerator();
+        Generator<?> gen = getWrappedGenerator();
         result ^= gen == null ? 0 : gen.hashCode();
         result <<= 2;
         result ^= pred == null ? 0 : pred.hashCode();

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=665786&r1=665785&r2=665786&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 Mon Jun  9 10:17:39 2008
@@ -25,15 +25,15 @@
  *
  * @version $Revision$ $Date$
  */
-public class GenerateUntil extends BaseGenerator {
-    private UnaryPredicate test;
+public class GenerateUntil<E> extends BaseGenerator<E> {
+    private UnaryPredicate<? super E> test;
 
     /**
      * Create a new GenerateUntil.
      * @param wrapped {@link Generator}
      * @param test {@link UnaryPredicate}
      */
-    public GenerateUntil(Generator wrapped, UnaryPredicate test) {
+    public GenerateUntil(Generator<? extends E> wrapped, UnaryPredicate<? super E> test) {
         super(wrapped);
         if (wrapped == null) {
             throw new IllegalArgumentException("Generator argument was null");
@@ -47,9 +47,9 @@
     /**
      * {@inheritDoc}
      */
-    public void run(final UnaryProcedure proc) {
-        getWrappedGenerator().run(new UnaryProcedure() {
-            public void run(Object obj) {
+    public void run(final UnaryProcedure<? super E> proc) {
+        getWrappedGenerator().run(new UnaryProcedure<E>() {
+            public void run(E obj) {
                 proc.run(obj);
                 if (test.test(obj)) {
                     getWrappedGenerator().stop();
@@ -61,6 +61,14 @@
     /**
      * {@inheritDoc}
      */
+    @Override
+    protected Generator<? extends E> getWrappedGenerator() {
+        return (Generator<? extends E>) super.getWrappedGenerator();
+    }
+
+    /**
+     * {@inheritDoc}
+     */
     public boolean equals(Object obj) {
         if (obj == this) {
             return true;
@@ -68,7 +76,7 @@
         if (obj instanceof GenerateUntil == false) {
             return false;
         }
-        GenerateUntil other = (GenerateUntil) obj;
+        GenerateUntil<?> other = (GenerateUntil<?>) obj;
         return other.getWrappedGenerator().equals(getWrappedGenerator()) && other.test.equals(test);
     }
 
@@ -78,7 +86,7 @@
     public int hashCode() {
         int result = "GenerateUntil".hashCode();
         result <<= 2;
-        Generator gen = getWrappedGenerator();
+        Generator<?> gen = getWrappedGenerator();
         result ^= gen == null ? 0 : gen.hashCode();
         result <<= 2;
         result ^= test == null ? 0 : test.hashCode();

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=665786&r1=665785&r2=665786&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 Mon Jun  9 10:17:39 2008
@@ -25,15 +25,15 @@
  *
  * @version $Revision$ $Date$
  */
-public class GenerateWhile extends BaseGenerator {
-    private UnaryPredicate test;
+public class GenerateWhile<E> extends BaseGenerator<E> {
+    private UnaryPredicate<? super E> test;
 
     /**
      * Create a new GenerateWhile.
      * @param wrapped {@link Generator}
      * @param test {@link UnaryPredicate}
      */
-    public GenerateWhile(Generator wrapped, UnaryPredicate test) {
+    public GenerateWhile(Generator<? extends E> wrapped, UnaryPredicate<? super E> test) {
         super(wrapped);
         if (wrapped == null) {
             throw new IllegalArgumentException("Generator argument was null");
@@ -47,9 +47,9 @@
     /**
      * {@inheritDoc}
      */
-    public void run(final UnaryProcedure proc) {
-        getWrappedGenerator().run(new UnaryProcedure() {
-            public void run(Object obj) {
+    public void run(final UnaryProcedure<? super E> proc) {
+        getWrappedGenerator().run(new UnaryProcedure<E>() {
+            public void run(E obj) {
                 proc.run(obj);
                 if (!test.test(obj)) {
                     getWrappedGenerator().stop();
@@ -61,6 +61,14 @@
     /**
      * {@inheritDoc}
      */
+    @Override
+    protected Generator<? extends E> getWrappedGenerator() {
+        return (Generator<? extends E>) super.getWrappedGenerator();
+    }
+
+    /**
+     * {@inheritDoc}
+     */
     public boolean equals(Object obj) {
         if (obj == this) {
             return true;
@@ -68,7 +76,7 @@
         if (obj instanceof GenerateWhile == false) {
             return false;
         }
-        GenerateWhile other = (GenerateWhile) obj;
+        GenerateWhile<?> other = (GenerateWhile<?>) obj;
         return other.getWrappedGenerator().equals(getWrappedGenerator()) && other.test.equals(test);
     }
 
@@ -78,7 +86,7 @@
     public int hashCode() {
         int result = "GenerateWhile".hashCode();
         result <<= 2;
-        Generator gen = getWrappedGenerator();
+        Generator<?> gen = getWrappedGenerator();
         result ^= gen == null ? 0 : gen.hashCode();
         result <<= 2;
         result ^= test == null ? 0 : test.hashCode();

Modified: commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/generator/Generator.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/generator/Generator.java?rev=665786&r1=665785&r2=665786&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/generator/Generator.java (original)
+++ commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/generator/Generator.java Mon Jun  9 10:17:39 2008
@@ -26,12 +26,12 @@
  * @author Jason Horman (jason@jhorman.org)
  * @author Rodney Waldhoff
  */
-public interface Generator {
+public interface Generator<E> {
     /**
      * Generators must implement this method.
      * @param proc UnaryProcedure to run
      */
-    public abstract void run(UnaryProcedure proc);
+    public abstract void run(UnaryProcedure<? super E> proc);
 
     /**
      * Stop the generator. Will stop the wrapped generator if one was set.
@@ -51,18 +51,18 @@
      * @param transformer UnaryFunction to apply to this
      * @return transformation result
      */
-    public abstract Object to(UnaryFunction transformer);
+    public abstract <Z> Z to(UnaryFunction<Generator<? extends E>, ? extends Z> transformer);
 
     /**
      * Same as to(new CollectionTransformer(collection)).
      * @param collection Collection to which my elements should be added
      * @return <code>collection</code>
      */
-    public abstract Collection to(Collection collection);
+    public abstract Collection<? super E> to(Collection<? super E> collection);
 
     /**
      * Same as to(new CollectionTransformer()).
      * @return Collection
      */
-    public abstract Collection toCollection();
+    public abstract Collection<? super E> toCollection();
 }

Modified: commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/generator/IteratorToGeneratorAdapter.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/generator/IteratorToGeneratorAdapter.java?rev=665786&r1=665785&r2=665786&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/generator/IteratorToGeneratorAdapter.java (original)
+++ commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/generator/IteratorToGeneratorAdapter.java Mon Jun  9 10:17:39 2008
@@ -26,11 +26,11 @@
  * @author Jason Horman (jason@jhorman.org)
  * @author Rodney Waldhoff
  */
-public final class IteratorToGeneratorAdapter extends BaseGenerator {
+public final class IteratorToGeneratorAdapter<E> extends BaseGenerator<E> {
     // instance variables
     //-----------------------------------------------------
 
-    private Iterator iter = null;
+    private Iterator<? extends E> iter = null;
 
     // constructors
     //-----------------------------------------------------
@@ -38,7 +38,7 @@
      * Create a new IteratorToGeneratorAdapter.
      * @param iter Iterator to adapt
      */
-    public IteratorToGeneratorAdapter(Iterator iter) {
+    public IteratorToGeneratorAdapter(Iterator<? extends E> iter) {
         if (null == iter) {
             throw new IllegalArgumentException("Iterator argument was null");
         }
@@ -50,7 +50,7 @@
     /**
      * {@inheritDoc}
      */
-    public void run(UnaryProcedure proc) {
+    public void run(UnaryProcedure<? super E> proc) {
         while (iter.hasNext()) {
             proc.run(iter.next());
             if (isStopped()) {
@@ -69,7 +69,7 @@
         if (obj instanceof IteratorToGeneratorAdapter == false) {
             return false;
         }
-        IteratorToGeneratorAdapter that = (IteratorToGeneratorAdapter) obj;
+        IteratorToGeneratorAdapter<?> that = (IteratorToGeneratorAdapter<?>) obj;
         return this.iter.equals(that.iter);
     }
 
@@ -97,8 +97,8 @@
      * @param iter to adapt
      * @return IteratorToGeneratorAdapter
      */
-    public static IteratorToGeneratorAdapter adapt(Iterator iter) {
-        return null == iter ? null : new IteratorToGeneratorAdapter(iter);
+    public static <E> IteratorToGeneratorAdapter<E> adapt(Iterator<? extends E> iter) {
+        return null == iter ? null : new IteratorToGeneratorAdapter<E>(iter);
     }
 
 }
\ No newline at end of file

Modified: commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/generator/TransformedGenerator.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/generator/TransformedGenerator.java?rev=665786&r1=665785&r2=665786&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/generator/TransformedGenerator.java (original)
+++ commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/generator/TransformedGenerator.java Mon Jun  9 10:17:39 2008
@@ -24,15 +24,15 @@
  *
  * @version $Revision$ $Date$
  */
-public class TransformedGenerator extends BaseGenerator {
-    private UnaryFunction func;
+public class TransformedGenerator<I, E> extends BaseGenerator<E> {
+    private UnaryFunction<? super I, ? extends E> func;
 
     /**
      * Create a new TransformedGenerator.
      * @param wrapped Generator to transform
      * @param func UnaryFunction to apply to each element
      */
-    public TransformedGenerator(Generator wrapped, UnaryFunction func) {
+    public TransformedGenerator(Generator<? extends I> wrapped, UnaryFunction<? super I, ? extends E> func) {
         super(wrapped);
         if (wrapped == null) {
             throw new IllegalArgumentException("Generator argument was null");
@@ -46,9 +46,9 @@
     /**
      * {@inheritDoc}
      */
-    public void run(final UnaryProcedure proc) {
-        getWrappedGenerator().run(new UnaryProcedure() {
-            public void run(Object obj) {
+    public void run(final UnaryProcedure<? super E> proc) {
+        getWrappedGenerator().run(new UnaryProcedure<I>() {
+            public void run(I obj) {
                 proc.run(func.evaluate(obj));
             }
         });
@@ -57,6 +57,15 @@
     /**
      * {@inheritDoc}
      */
+    @SuppressWarnings("unchecked")
+    @Override
+    protected Generator<? extends I> getWrappedGenerator() {
+        return (Generator<? extends I>) super.getWrappedGenerator();
+    }
+
+    /**
+     * {@inheritDoc}
+     */
     public boolean equals(Object obj) {
         if (obj == this) {
             return true;
@@ -64,7 +73,7 @@
         if (obj instanceof TransformedGenerator == false) {
             return false;
         }
-        TransformedGenerator other = (TransformedGenerator) obj;
+        TransformedGenerator<?, ?> other = (TransformedGenerator<?, ?>) obj;
         return other.getWrappedGenerator().equals(getWrappedGenerator()) && other.func == func;
     }
 

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=665786&r1=665785&r2=665786&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 Mon Jun  9 10:17:39 2008
@@ -25,15 +25,15 @@
  *
  * @version $Revision$ $Date$
  */
-public class UntilGenerate extends BaseGenerator {
-    private UnaryPredicate test;
+public class UntilGenerate<E> extends BaseGenerator<E> {
+    private UnaryPredicate<? super E> test;
 
     /**
      * Create a new UntilGenerate.
      * @param wrapped {@link Generator}
      * @param test {@link UnaryPredicate}
      */
-    public UntilGenerate(UnaryPredicate test, Generator wrapped) {
+    public UntilGenerate(UnaryPredicate<? super E> test, Generator<? extends E> wrapped) {
         super(wrapped);
         if (wrapped == null) {
             throw new IllegalArgumentException("Generator argument was null");
@@ -47,9 +47,9 @@
     /**
      * {@inheritDoc}
      */
-    public void run(final UnaryProcedure proc) {
-        getWrappedGenerator().run(new UnaryProcedure() {
-            public void run(Object obj) {
+    public void run(final UnaryProcedure<? super E> proc) {
+        getWrappedGenerator().run(new UnaryProcedure<E>() {
+            public void run(E obj) {
                 if (test.test(obj)) {
                     getWrappedGenerator().stop();
                 } else {
@@ -62,6 +62,14 @@
     /**
      * {@inheritDoc}
      */
+    @Override
+    protected Generator<? extends E> getWrappedGenerator() {
+        return (Generator<? extends E>) super.getWrappedGenerator();
+    }
+
+    /**
+     * {@inheritDoc}
+     */
     public boolean equals(Object obj) {
         if (obj == this) {
             return true;
@@ -69,7 +77,7 @@
         if (obj instanceof UntilGenerate == false) {
             return false;
         }
-        UntilGenerate other = (UntilGenerate) obj;
+        UntilGenerate<?> other = (UntilGenerate<?>) obj;
         return other.getWrappedGenerator().equals(getWrappedGenerator()) && other.test.equals(test);
     }
 
@@ -79,7 +87,7 @@
     public int hashCode() {
         int result = "UntilGenerate".hashCode();
         result <<= 2;
-        Generator gen = getWrappedGenerator();
+        Generator<?> gen = getWrappedGenerator();
         result ^= gen == null ? 0 : gen.hashCode();
         result <<= 2;
         result ^= test == null ? 0 : test.hashCode();

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=665786&r1=665785&r2=665786&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 Mon Jun  9 10:17:39 2008
@@ -25,15 +25,15 @@
  *
  * @version $Revision$ $Date$
  */
-public class WhileGenerate extends BaseGenerator {
-    private UnaryPredicate test;
+public class WhileGenerate<E> extends BaseGenerator<E> {
+    private UnaryPredicate<? super E> test;
 
     /**
      * Create a new WhileGenerate.
      * @param test {@link UnaryPredicate}
      * @param wrapped {@link Generator}
      */
-    public WhileGenerate(UnaryPredicate test, Generator wrapped) {
+    public WhileGenerate(UnaryPredicate<? super E> test, Generator<? extends E> wrapped) {
         super(wrapped);
         if (wrapped == null) {
             throw new IllegalArgumentException("Generator argument was null");
@@ -47,9 +47,9 @@
     /**
      * {@inheritDoc}
      */
-    public void run(final UnaryProcedure proc) {
-        getWrappedGenerator().run(new UnaryProcedure() {
-            public void run(Object obj) {
+    public void run(final UnaryProcedure<? super E> proc) {
+        getWrappedGenerator().run(new UnaryProcedure<E>() {
+            public void run(E obj) {
                 if (!test.test(obj)) {
                     getWrappedGenerator().stop();
                 } else {
@@ -62,6 +62,14 @@
     /**
      * {@inheritDoc}
      */
+    @Override
+    protected Generator<? extends E> getWrappedGenerator() {
+        return (Generator<? extends E>) super.getWrappedGenerator();
+    }
+
+    /**
+     * {@inheritDoc}
+     */
     public boolean equals(Object obj) {
         if (obj == this) {
             return true;
@@ -69,7 +77,7 @@
         if (obj instanceof WhileGenerate == false) {
             return false;
         }
-        WhileGenerate other = (WhileGenerate) obj;
+        WhileGenerate<?> other = (WhileGenerate<?>) obj;
         return other.getWrappedGenerator().equals(getWrappedGenerator()) && other.test.equals(test);
     }
 
@@ -79,7 +87,7 @@
     public int hashCode() {
         int result = "WhileGenerate".hashCode();
         result <<= 2;
-        Generator gen = getWrappedGenerator();
+        Generator<?> gen = getWrappedGenerator();
         result ^= gen == null ? 0 : gen.hashCode();
         result <<= 2;
         result ^= test == null ? 0 : test.hashCode();

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=665786&r1=665785&r2=665786&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 Mon Jun  9 10:17:39 2008
@@ -29,11 +29,11 @@
  * @version $Revision$ $Date$
  * @author Jason Horman (jason@jhorman.org)
  */
-public class CollectionTransformer implements UnaryFunction {
+public class CollectionTransformer<E> implements UnaryFunction<Generator<? extends E>, Collection<? super E>> {
 
     // instance methods
     //---------------------------------------------------
-    private Collection toFill = null;
+    private Collection<? super E> toFill = null;
 
     // constructors
     //---------------------------------------------------
@@ -41,14 +41,14 @@
      * Create a new CollectionTransformer.
      */
     public CollectionTransformer() {
-        toFill = new ArrayList();
+        toFill = new ArrayList<E>();
     }
 
     /**
      * Create a new CollectionTransformer.
      * @param toFill Collection to fill
      */
-    public CollectionTransformer(Collection toFill) {
+    public CollectionTransformer(Collection<? super E> toFill) {
         this.toFill = toFill;
     }
 
@@ -57,21 +57,12 @@
     /**
      * {@inheritDoc}
      */
-    public Object evaluate(Object obj) {
-        return evaluate((Generator) obj);
-    }
-
-    /**
-     * Add the Generator's contents to a Collection.
-     * @param generator to run
-     * @return filled Collection
-     */
-    public Object evaluate(Generator generator) {
-        generator.run(new UnaryProcedure() {
-            public void run(Object obj) {
+    public Collection<E> evaluate(Generator<? extends E> generator) {
+        generator.run(new UnaryProcedure<E>() {
+            public void run(E obj) {
                 toFill.add(obj);
             }
         });
-        return toFill;
+        return (Collection<E>) toFill;
     }
 }
\ No newline at end of file

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=665786&r1=665785&r2=665786&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 Mon Jun  9 10:17:39 2008
@@ -18,6 +18,7 @@
 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;
@@ -31,16 +32,18 @@
  */
 public final class EachElement {
     /**
+     * Create a new EachElement for bean-dependent APIs.
+     */
+    public EachElement() {
+    }
+
+    /**
      * Get a Generator for each element of a Collection.
      * @param collection to iterate
-     * @return Generator
+     * @return Generator<E>
      */
-    public static final Generator from(Collection collection) {
-        if (null == collection) {
-            return null;
-        } else {
-            return EachElement.from(collection.iterator());
-        }
+    public static final <E> Generator<E> from(Collection<? extends E> collection) {
+        return collection == null ? null : EachElement.from(collection.iterator());
     }
 
     /**
@@ -48,12 +51,11 @@
      * @param map to iterate
      * @return Generator
      */
-    public static final Generator from(Map map) {
-        if (null == map) {
+    public static final <K, V> Generator<Map.Entry<K, V>> from(Map<? extends K, ? extends V> map) {
+        if (map == null) {
             return null;
-        } else {
-            return EachElement.from(map.entrySet().iterator());
         }
+        return map == null ? null : EachElement.from(((Map<K, V>) map).entrySet().iterator());
     }
 
     /**
@@ -61,12 +63,8 @@
      * @param array to iterate
      * @return Generator
      */
-    public static final Generator from(Object[] array) {
-        if (null == array) {
-            return null;
-        } else {
-            return EachElement.from(Arrays.asList(array).iterator());
-        }
+    public static final <E> Generator<E> from(E[] array) {
+        return array == null ? null : EachElement.from(Arrays.asList(array).iterator());
     }
 
     /**
@@ -74,11 +72,7 @@
      * @param iter to iterate
      * @return Generator
      */
-    public static final Generator from(Iterator iter) {
-        if (null == iter) {
-            return null;
-        } else {
-            return new IteratorToGeneratorAdapter(iter);
-        }
+    public static final <E> Generator<E> from(Iterator<? extends E> iter) {
+        return iter == null ? null : new IteratorToGeneratorAdapter<E>(iter);
     }
 }
\ No newline at end of file

Modified: commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/generator/util/IntegerRange.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/generator/util/IntegerRange.java?rev=665786&r1=665785&r2=665786&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/generator/util/IntegerRange.java (original)
+++ commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/generator/util/IntegerRange.java Mon Jun  9 10:17:39 2008
@@ -26,7 +26,7 @@
  * @author Jason Horman (jason@jhorman.org)
  * @author Rodney Waldhoff
  */
-public final class IntegerRange extends BaseGenerator {
+public final class IntegerRange extends BaseGenerator<Integer> {
     // attributes
     //---------------------------------------------------------------
 
@@ -73,11 +73,10 @@
     public IntegerRange(int from, int to, int 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
@@ -85,14 +84,14 @@
     /**
      * {@inheritDoc}
      */
-    public void run(UnaryProcedure proc) {
+    public void run(UnaryProcedure<? super Integer> proc) {
         if (signOf(step) == -1) {
             for (int i = from; i > to; i += step) {
-                proc.run(new Integer(i));
+                proc.run(i);
             }
         } else {
             for (int i = from; i < to; i += step) {
-                proc.run(new Integer(i));
+                proc.run(i);
             }
         }
     }
@@ -140,13 +139,7 @@
      * @return int
      */
     private static int signOf(int value) {
-        if (value < 0) {
-            return -1;
-        } else if (value > 0) {
-            return 1;
-        } else {
-            return 0;
-        }
+        return value < 0 ? -1 : value > 0 ? 1 : 0;
     }
 
     /**
@@ -156,11 +149,7 @@
      * @return int
      */
     private static int defaultStep(int from, int to) {
-        if (from > to) {
-            return -1;
-        } else {
-            return 1;
-        }
+        return from > to ? -1 : 1;
     }
 
 }
\ No newline at end of file



Mime
View raw message