commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mben...@apache.org
Subject svn commit: r1096509 - /commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/
Date Mon, 25 Apr 2011 16:27:29 GMT
Author: mbenson
Date: Mon Apr 25 16:27:28 2011
New Revision: 1096509

URL: http://svn.apache.org/viewvc?rev=1096509&view=rev
Log:
replace one/two/three arg constructors of Base*PredicateList (parenting *And/*Or) with varargs;
add Iterable-based constructors as well; expose list rather than its iterator (both of which
are mutable) to subclasses to enable Java 5 for construct

Modified:
    commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/And.java
    commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/BaseBinaryPredicateList.java
    commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/BasePredicateList.java
    commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/BaseUnaryPredicateList.java
    commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/BinaryAnd.java
    commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/BinaryOr.java
    commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/Or.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/UnaryOr.java

Modified: commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/And.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/And.java?rev=1096509&r1=1096508&r2=1096509&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/And.java
(original)
+++ commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/And.java
Mon Apr 25 16:27:28 2011
@@ -16,8 +16,6 @@
  */
 package org.apache.commons.functor.core.composite;
 
-import java.util.Iterator;
-
 import org.apache.commons.functor.Predicate;
 
 /**
@@ -40,6 +38,7 @@ public final class And extends BasePredi
 
     // constructor
     // ------------------------------------------------------------------------
+    
     /**
      * Create a new And.
      */
@@ -48,30 +47,21 @@ public final class And extends BasePredi
     }
 
     /**
-     * Create a new And.
-     * @param p Predicate to add
+     * Create a new And instance.
+     *
+     * @param predicates
      */
-    public And(Predicate p) {
-        super(p);
+    public And(Iterable<Predicate> predicates) {
+        super(predicates);
     }
 
     /**
-     * Create a new And.
-     * @param p Predicate to add
-     * @param q Predicate to add
-     */
-    public And(Predicate p, Predicate q) {
-        super(p, q);
-    }
-
-    /**
-     * Create a new And.
-     * @param p Predicate to add
-     * @param q Predicate to add
-     * @param r Predicate to add
+     * Create a new And instance.
+     *
+     * @param predicates
      */
-    public And(Predicate p, Predicate q, Predicate r) {
-        super(p, q, r);
+    public And(Predicate... predicates) {
+        super(predicates);
     }
 
     // modifiers
@@ -92,8 +82,8 @@ public final class And extends BasePredi
      * {@inheritDoc}
      */
     public boolean test() {
-        for (Iterator<Predicate> iter = getPredicateIterator(); iter.hasNext();) {
-            if (!iter.next().test()) {
+        for (Predicate p : getPredicateList()) {
+            if (!p.test()) {
                 return false;
             }
         }

Modified: commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/BaseBinaryPredicateList.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/BaseBinaryPredicateList.java?rev=1096509&r1=1096508&r2=1096509&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/BaseBinaryPredicateList.java
(original)
+++ commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/BaseBinaryPredicateList.java
Mon Apr 25 16:27:28 2011
@@ -18,7 +18,6 @@ package org.apache.commons.functor.core.
 
 import java.io.Serializable;
 import java.util.ArrayList;
-import java.util.Iterator;
 import java.util.List;
 
 import org.apache.commons.functor.BinaryPredicate;
@@ -49,38 +48,37 @@ abstract class BaseBinaryPredicateList<L
      * Create a new BaseBinaryPredicateList.
      */
     protected BaseBinaryPredicateList() {
+        super();
     }
 
     /**
-     * Create a new BaseBinaryPredicateList.
-     * @param p BinaryPredicate to add
-     */
-    protected BaseBinaryPredicateList(BinaryPredicate<? super L, ? super R> p) {
-        addBinaryPredicate(p);
-    }
-
-    /**
-     * Create a new BaseBinaryPredicateList.
-     * @param p BinaryPredicate to add
-     * @param q BinaryPredicate to add
+     * Create a new BaseBinaryPredicateList instance.
+     *
+     * @param predicates to add
      */
-    protected BaseBinaryPredicateList(BinaryPredicate<? super L, ? super R> p, BinaryPredicate<?
super L, ? super R> q) {
-        addBinaryPredicate(p);
-        addBinaryPredicate(q);
+    protected BaseBinaryPredicateList(BinaryPredicate<? super L, ? super R>... predicates)
{
+        this();
+        if (predicates != null) {
+            for (BinaryPredicate<? super L, ? super R> p : predicates) {
+                addBinaryPredicate(p);
+            }
+        }
     }
 
     /**
-     * Create a new BaseBinaryPredicateList.
-     * @param p BinaryPredicate to add
-     * @param q BinaryPredicate to add
-     * @param r BinaryPredicate to add
-     */
-    protected BaseBinaryPredicateList(BinaryPredicate<? super L, ? super R> p, BinaryPredicate<?
super L, ? super R> q, BinaryPredicate<? super L, ? super R> r) {
-        addBinaryPredicate(p);
-        addBinaryPredicate(q);
-        addBinaryPredicate(r);
+     * Create a new BaseBinaryPredicateList instance.
+     *
+     * @param predicates to add
+     */
+    protected BaseBinaryPredicateList(Iterable<BinaryPredicate<? super L, ? super R>>
predicates) {
+        this();
+        if (predicates != null) {
+            for (BinaryPredicate<? super L, ? super R> p : predicates) {
+                addBinaryPredicate(p);
+            }
+        }
     }
-
+    
     // abstract
     // ------------------------------------------------------------------------
     /**
@@ -114,11 +112,11 @@ abstract class BaseBinaryPredicateList<L
     // protected
     // ------------------------------------------------------------------------
     /**
-     * Get an Iterator over the list contents.
-     * @return Iterator
+     * Get the "live" list of contained {@link BinaryPredicate} instances.
+     * @return List
      */
-    protected Iterator<BinaryPredicate<? super L, ? super R>> getBinaryPredicateIterator()
{
-        return list.iterator();
+    protected List<BinaryPredicate<? super L, ? super R>> getBinaryPredicateList()
{
+        return list;
     }
 
     /**

Modified: commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/BasePredicateList.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/BasePredicateList.java?rev=1096509&r1=1096508&r2=1096509&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/BasePredicateList.java
(original)
+++ commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/BasePredicateList.java
Mon Apr 25 16:27:28 2011
@@ -18,7 +18,6 @@ package org.apache.commons.functor.core.
 
 import java.io.Serializable;
 import java.util.ArrayList;
-import java.util.Iterator;
 import java.util.List;
 
 import org.apache.commons.functor.Predicate;
@@ -45,39 +44,38 @@ abstract class BasePredicateList impleme
     // constructor
     // ------------------------------------------------------------------------
     /**
-     * Create a new BasePredicateList.
+     * Create a new BasePredicateList instance.
      */
     protected BasePredicateList() {
+        super();
     }
 
     /**
-     * Create a new BasePredicateList.
-     * @param p Predicate to add
-     */
-    protected BasePredicateList(Predicate p) {
-        addPredicate(p);
-    }
-
-    /**
-     * Create a new BasePredicateList.
-     * @param p Predicate to add
-     * @param q Predicate to add
+     * Create a new BasePredicateList instance.
+     *
+     * @param predicates to add
      */
-    protected BasePredicateList(Predicate p, Predicate q) {
-        addPredicate(p);
-        addPredicate(q);
+    protected BasePredicateList(Predicate... predicates) {
+        this();
+        if (predicates != null) {
+            for (Predicate p : predicates) {
+                addPredicate(p);
+            }
+        }
     }
 
     /**
-     * Create a new BasePredicateList.
-     * @param p Predicate to add
-     * @param q Predicate to add
-     * @param r Predicate to add
-     */
-    protected BasePredicateList(Predicate p, Predicate q, Predicate r) {
-        addPredicate(p);
-        addPredicate(q);
-        addPredicate(r);
+     * Create a new BasePredicateList instance.
+     *
+     * @param predicates to add
+     */
+    protected BasePredicateList(Iterable<Predicate> predicates) {
+        this();
+        if (predicates != null) {
+            for (Predicate p : predicates) {
+                addPredicate(p);
+            }
+        }
     }
 
     // abstract
@@ -112,12 +110,13 @@ abstract class BasePredicateList impleme
 
     // protected
     // ------------------------------------------------------------------------
+
     /**
-     * Get an Iterator over the contents of the list.
-     * @return Iterator<Predicate>
+     * Get the "live" list of {@link Predicate}s.
+     * @return List<Predicate>
      */
-    protected Iterator<Predicate> getPredicateIterator() {
-        return list.iterator();
+    protected List<Predicate> getPredicateList() {
+        return list;
     }
 
     /**

Modified: commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/BaseUnaryPredicateList.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/BaseUnaryPredicateList.java?rev=1096509&r1=1096508&r2=1096509&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/BaseUnaryPredicateList.java
(original)
+++ commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/BaseUnaryPredicateList.java
Mon Apr 25 16:27:28 2011
@@ -18,7 +18,6 @@ package org.apache.commons.functor.core.
 
 import java.io.Serializable;
 import java.util.ArrayList;
-import java.util.Iterator;
 import java.util.List;
 
 import org.apache.commons.functor.UnaryPredicate;
@@ -49,36 +48,35 @@ abstract class BaseUnaryPredicateList<A>
      * Create a new BaseUnaryPredicateList.
      */
     protected BaseUnaryPredicateList() {
+        super();
     }
 
     /**
-     * Create a new BaseUnaryPredicateList.
-     * @param p single Predicate to add
-     */
-    protected BaseUnaryPredicateList(UnaryPredicate<? super A> p) {
-        addUnaryPredicate(p);
-    }
-
-    /**
-     * Create a new BaseUnaryPredicateList.
-     * @param p Predicate to add
-     * @param q Predicate to add
+     * Create a new BaseUnaryPredicateList instance.
+     *
+     * @param predicates to add
      */
-    protected BaseUnaryPredicateList(UnaryPredicate<? super A> p, UnaryPredicate<?
super A> q) {
-        addUnaryPredicate(p);
-        addUnaryPredicate(q);
+    protected BaseUnaryPredicateList(UnaryPredicate<? super A>... predicates) {
+        this();
+        if (predicates != null) {
+            for (UnaryPredicate<? super A> p : predicates) {
+                addUnaryPredicate(p);
+            }
+        }
     }
 
     /**
-     * Create a new BaseUnaryPredicateList.
-     * @param p Predicate to add
-     * @param q Predicate to add
-     * @param r Predicate to add
-     */
-    protected BaseUnaryPredicateList(UnaryPredicate<? super A> p, UnaryPredicate<?
super A> q, UnaryPredicate<? super A> r) {
-        addUnaryPredicate(p);
-        addUnaryPredicate(q);
-        addUnaryPredicate(r);
+     * Create a new BaseUnaryPredicateList instance.
+     *
+     * @param predicates to add
+     */
+    protected BaseUnaryPredicateList(Iterable<UnaryPredicate<? super A>> predicates)
{
+        this();
+        if (predicates != null) {
+            for (UnaryPredicate<? super A> p : predicates) {
+                addUnaryPredicate(p);
+            }
+        }
     }
 
     // abstract
@@ -113,12 +111,13 @@ abstract class BaseUnaryPredicateList<A>
 
     // protected
     // ------------------------------------------------------------------------
+
     /**
-     * Get an Iterator over the contained UnaryPredicates.
-     * @return Iterator
+     * Get the "live" list of contained {@link UnaryPredicate}s.
+     * @return List
      */
-    protected Iterator<UnaryPredicate<? super A>> getUnaryPredicateIterator()
{
-        return list.iterator();
+    protected List<UnaryPredicate<? super A>> getUnaryPredicateList() {
+        return list;
     }
 
     /**

Modified: commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/BinaryAnd.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/BinaryAnd.java?rev=1096509&r1=1096508&r2=1096509&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/BinaryAnd.java
(original)
+++ commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/BinaryAnd.java
Mon Apr 25 16:27:28 2011
@@ -16,8 +16,6 @@
  */
 package org.apache.commons.functor.core.composite;
 
-import java.util.Iterator;
-
 import org.apache.commons.functor.BinaryPredicate;
 
 /**
@@ -48,31 +46,21 @@ public final class BinaryAnd<L, R> exten
     }
 
     /**
-     * Create a new BinaryAnd.
-     * @param p BinaryPredicate to add
+     * Create a new BinaryAnd instance.
+     *
+     * @param predicates
      */
-    public BinaryAnd(BinaryPredicate<? super L, ? super R> p) {
-        super(p);
+    public BinaryAnd(BinaryPredicate<? super L, ? super R>... predicates) {
+        super(predicates);
     }
 
     /**
-     * Create a new BinaryAnd.
-     * @param p BinaryPredicate to add
-     * @param q BinaryPredicate to add
-     */
-    public BinaryAnd(BinaryPredicate<? super L, ? super R> p, BinaryPredicate<?
super L, ? super R> q) {
-        super(p, q);
-    }
-
-    /**
-     * Create a new BinaryAnd.
-     * @param p BinaryPredicate to add
-     * @param q BinaryPredicate to add
-     * @param r BinaryPredicate to add
+     * Create a new BinaryAnd instance.
+     *
+     * @param predicates
      */
-    public BinaryAnd(BinaryPredicate<? super L, ? super R> p, BinaryPredicate<?
super L, ? super R> q,
-            BinaryPredicate<? super L, ? super R> r) {
-        super(p, q, r);
+    public BinaryAnd(Iterable<BinaryPredicate<? super L, ? super R>> predicates)
{
+        super(predicates);
     }
 
     // modifiers
@@ -93,8 +81,8 @@ public final class BinaryAnd<L, R> exten
      * {@inheritDoc}
      */
     public boolean test(L a, R b) {
-        for (Iterator<BinaryPredicate<? super L, ? super R>> iter = getBinaryPredicateIterator();
iter.hasNext();) {
-            if (!iter.next().test(a, b)) {
+        for (BinaryPredicate<? super L, ? super R> p : getBinaryPredicateList()) {
+            if (!p.test(a, b)) {
                 return false;
             }
         }

Modified: commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/BinaryOr.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/BinaryOr.java?rev=1096509&r1=1096508&r2=1096509&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/BinaryOr.java
(original)
+++ commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/BinaryOr.java
Mon Apr 25 16:27:28 2011
@@ -16,8 +16,6 @@
  */
 package org.apache.commons.functor.core.composite;
 
-import java.util.Iterator;
-
 import org.apache.commons.functor.BinaryPredicate;
 
 /**
@@ -48,31 +46,21 @@ public final class BinaryOr<L, R> extend
     }
 
     /**
-     * Create a new BinaryOr.
-     * @param p BinaryPredicate to add
+     * Create a new BinaryOr instance.
+     *
+     * @param predicates
      */
-    public BinaryOr(BinaryPredicate<? super L, ? super R> p) {
-        super(p);
+    public BinaryOr(BinaryPredicate<? super L, ? super R>... predicates) {
+        super(predicates);
     }
 
     /**
-     * Create a new BinaryOr.
-     * @param p BinaryPredicate to add
-     * @param q BinaryPredicate to add
-     */
-    public BinaryOr(BinaryPredicate<? super L, ? super R> p, BinaryPredicate<? super
L, ? super R> q) {
-        super(p, q);
-    }
-
-    /**
-     * Create a new BinaryOr.
-     * @param p BinaryPredicate to add
-     * @param q BinaryPredicate to add
-     * @param r BinaryPredicate to add
+     * Create a new BinaryOr instance.
+     *
+     * @param predicates
      */
-    public BinaryOr(BinaryPredicate<? super L, ? super R> p, BinaryPredicate<? super
L, ? super R> q,
-            BinaryPredicate<? super L, ? super R> r) {
-        super(p, q, r);
+    public BinaryOr(Iterable<BinaryPredicate<? super L, ? super R>> predicates)
{
+        super(predicates);
     }
 
     // modifiers
@@ -93,8 +81,8 @@ public final class BinaryOr<L, R> extend
      * {@inheritDoc}
      */
     public boolean test(L a, R b) {
-        for (Iterator<BinaryPredicate<? super L, ? super R>> iter = getBinaryPredicateIterator();
iter.hasNext();) {
-            if (iter.next().test(a, b)) {
+        for (BinaryPredicate<? super L, ? super R> p : getBinaryPredicateList()) {
+            if (p.test(a, b)) {
                 return true;
             }
         }

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=1096509&r1=1096508&r2=1096509&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 Apr 25 16:27:28 2011
@@ -16,8 +16,6 @@
  */
 package org.apache.commons.functor.core.composite;
 
-import java.util.Iterator;
-
 import org.apache.commons.functor.Predicate;
 
 /**
@@ -48,30 +46,21 @@ public final class Or extends BasePredic
     }
 
     /**
-     * Create a new Or.
-     * @param p Predicate to add
+     * Create a new Or instance.
+     *
+     * @param predicates
      */
-    public Or(Predicate p) {
-        super(p);
+    public Or(Iterable<Predicate> predicates) {
+        super(predicates);
     }
 
     /**
-     * Create a new Or.
-     * @param p Predicate to add
-     * @param q Predicate to add
-     */
-    public Or(Predicate p, Predicate q) {
-        super(p, q);
-    }
-
-    /**
-     * Create a new Or.
-     * @param p Predicate to add
-     * @param q Predicate to add
-     * @param r Predicate to add
+     * Create a new Or instance.
+     *
+     * @param predicates
      */
-    public Or(Predicate p, Predicate q, Predicate r) {
-        super(p, q, r);
+    public Or(Predicate... predicates) {
+        super(predicates);
     }
 
     /**
@@ -90,8 +79,8 @@ public final class Or extends BasePredic
      * {@inheritDoc}
      */
     public boolean test() {
-        for (Iterator<Predicate> iter = getPredicateIterator(); iter.hasNext();) {
-            if (iter.next().test()) {
+        for (Predicate p : getPredicateList()) {
+            if (p.test()) {
                 return true;
             }
         }

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=1096509&r1=1096508&r2=1096509&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 Apr 25 16:27:28 2011
@@ -16,8 +16,6 @@
  */
 package org.apache.commons.functor.core.composite;
 
-import java.util.Iterator;
-
 import org.apache.commons.functor.UnaryPredicate;
 
 /**
@@ -48,30 +46,21 @@ public final class UnaryAnd<A> extends B
     }
 
     /**
-     * Create a new UnaryAnd.
-     * @param p UnaryPredicate to add
+     * Create a new UnaryAnd instance.
+     *
+     * @param predicates
      */
-    public UnaryAnd(UnaryPredicate<? super A> p) {
-        super(p);
+    public UnaryAnd(Iterable<UnaryPredicate<? super A>> predicates) {
+        super(predicates);
     }
 
     /**
-     * Create a new UnaryAnd.
-     * @param p UnaryPredicate to add
-     * @param q UnaryPredicate to add
-     */
-    public UnaryAnd(UnaryPredicate<? super A> p, UnaryPredicate<? super A> q)
{
-        super(p, q);
-    }
-
-    /**
-     * Create a new UnaryAnd.
-     * @param p UnaryPredicate to add
-     * @param q UnaryPredicate to add
-     * @param r UnaryPredicate to add
+     * Create a new UnaryAnd instance.
+     *
+     * @param predicates
      */
-    public UnaryAnd(UnaryPredicate<? super A> p, UnaryPredicate<? super A> q,
UnaryPredicate<? super A> r) {
-        super(p, q, r);
+    public UnaryAnd(UnaryPredicate<? super A>... predicates) {
+        super(predicates);
     }
 
     // modifiers
@@ -92,8 +81,8 @@ public final class UnaryAnd<A> extends B
      * {@inheritDoc}
      */
     public boolean test(A obj) {
-        for (Iterator<UnaryPredicate<? super A>> iter = getUnaryPredicateIterator();
iter.hasNext();) {
-            if (!iter.next().test(obj)) {
+        for (UnaryPredicate<? super A> p : getUnaryPredicateList()) {
+            if (!p.test(obj)) {
                 return false;
             }
         }

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=1096509&r1=1096508&r2=1096509&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 Apr 25 16:27:28 2011
@@ -16,8 +16,6 @@
  */
 package org.apache.commons.functor.core.composite;
 
-import java.util.Iterator;
-
 import org.apache.commons.functor.UnaryPredicate;
 
 /**
@@ -48,30 +46,21 @@ public final class UnaryOr<A> extends Ba
     }
 
     /**
-     * Create a new UnaryOr.
-     * @param p Predicate to add
+     * Create a new UnaryOr instance.
+     *
+     * @param predicates
      */
-    public UnaryOr(UnaryPredicate<? super A> p) {
-        super(p);
+    public UnaryOr(Iterable<UnaryPredicate<? super A>> predicates) {
+        super(predicates);
     }
 
     /**
-     * Create a new UnaryOr.
-     * @param p Predicate to add
-     * @param q Predicate to add
-     */
-    public UnaryOr(UnaryPredicate<? super A> p, UnaryPredicate<? super A> q)
{
-        super(p, q);
-    }
-
-    /**
-     * Create a new UnaryOr.
-     * @param p Predicate to add
-     * @param q Predicate to add
-     * @param r Predicate to add
+     * Create a new UnaryOr instance.
+     *
+     * @param predicates
      */
-    public UnaryOr(UnaryPredicate<? super A> p, UnaryPredicate<? super A> q,
UnaryPredicate<? super A> r) {
-        super(p, q, r);
+    public UnaryOr(UnaryPredicate<? super A>... predicates) {
+        super(predicates);
     }
 
     // modifiers
@@ -92,8 +81,8 @@ public final class UnaryOr<A> extends Ba
      * {@inheritDoc}
      */
     public boolean test(A a) {
-        for (Iterator<UnaryPredicate<? super A>> iter = getUnaryPredicateIterator();
iter.hasNext();) {
-            if (iter.next().test(a)) {
+        for (UnaryPredicate<? super A> p : getUnaryPredicateList()) {
+            if (p.test(a)) {
                 return true;
             }
         }



Mime
View raw message