You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by mb...@apache.org on 2008/04/05 01:08:27 UTC

svn commit: r644988 [2/2] - in /commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor: adapter/ core/ core/collection/ core/comparator/ core/composite/ generator/util/

Modified: commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/ConditionalPredicate.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/ConditionalPredicate.java?rev=644988&r1=644987&r2=644988&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/ConditionalPredicate.java (original)
+++ commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/ConditionalPredicate.java Fri Apr  4 16:08:18 2008
@@ -41,10 +41,20 @@
  * @author Rodney Waldhoff
  */
 public final class ConditionalPredicate implements Predicate, Serializable {
+    // attributes
+    // ------------------------------------------------------------------------
+    private Predicate ifPred = null;
+    private Predicate thenPred = null;
+    private Predicate elsePred = null;
 
     // constructor
     // ------------------------------------------------------------------------
-
+    /**
+     * Create a new ConditionalPredicate.
+     * @param ifPred if
+     * @param thenPred then
+     * @param elsePred else
+     */
     public ConditionalPredicate(Predicate ifPred, Predicate thenPred, Predicate elsePred) {
         this.ifPred = ifPred;
         this.thenPred = thenPred;
@@ -53,10 +63,16 @@
 
     // predicate interface
     // ------------------------------------------------------------------------
+    /**
+     * {@inheritDoc}
+     */
     public boolean test() {
         return ifPred.test() ? thenPred.test() : elsePred.test();
     }
 
+    /**
+     * {@inheritDoc}
+     */
     public boolean equals(Object that) {
         if (that instanceof ConditionalPredicate) {
             return equals((ConditionalPredicate) that);
@@ -65,13 +81,21 @@
         }
     }
 
+    /**
+     * Learn whether another ConditionalPredicate is equal to this.
+     * @param that ConditionalPredicate to test
+     * @return boolean
+     */
     public boolean equals(ConditionalPredicate that) {
-        return null != that &&
-                (null == ifPred ? null == that.ifPred : ifPred.equals(that.ifPred)) &&
-                (null == thenPred ? null == that.thenPred : thenPred.equals(that.thenPred)) &&
-                (null == elsePred ? null == that.elsePred : elsePred.equals(that.elsePred));
+        return null != that
+                && (null == ifPred ? null == that.ifPred : ifPred.equals(that.ifPred))
+                && (null == thenPred ? null == that.thenPred : thenPred.equals(that.thenPred))
+                && (null == elsePred ? null == that.elsePred : elsePred.equals(that.elsePred));
     }
 
+    /**
+     * {@inheritDoc}
+     */
     public int hashCode() {
         int hash = "ConditionalPredicate".hashCode();
         if (null != ifPred) {
@@ -89,13 +113,11 @@
         return hash;
     }
 
+    /**
+     * {@inheritDoc}
+     */
     public String toString() {
         return "ConditionalPredicate<" + ifPred + "?" + thenPred + ":" + elsePred + ">";
     }
 
-    // attributes
-    // ------------------------------------------------------------------------
-    private Predicate ifPred = null;
-    private Predicate thenPred = null;
-    private Predicate elsePred = null;
 }

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=644988&r1=644987&r2=644988&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 Fri Apr  4 16:08:18 2008
@@ -41,10 +41,20 @@
  * @author Rodney Waldhoff
  */
 public final class ConditionalUnaryPredicate implements UnaryPredicate, Serializable {
+    // attributes
+    // ------------------------------------------------------------------------
+    private UnaryPredicate ifPred = null;
+    private UnaryPredicate thenPred = null;
+    private UnaryPredicate elsePred = null;
 
     // constructor
     // ------------------------------------------------------------------------
-
+    /**
+     * Create a new ConditionalUnaryPredicate.
+     * @param ifPred if
+     * @param thenPred then
+     * @param elsePred else
+     */
     public ConditionalUnaryPredicate(UnaryPredicate ifPred, UnaryPredicate thenPred, UnaryPredicate elsePred) {
         this.ifPred = ifPred;
         this.thenPred = thenPred;
@@ -53,10 +63,16 @@
 
     // predicate interface
     // ------------------------------------------------------------------------
+    /**
+     * {@inheritDoc}
+     */
     public boolean test(Object obj) {
         return ifPred.test(obj) ? thenPred.test(obj) : elsePred.test(obj);
     }
 
+    /**
+     * {@inheritDoc}
+     */
     public boolean equals(Object that) {
         if (that instanceof ConditionalUnaryPredicate) {
             return equals((ConditionalUnaryPredicate) that);
@@ -65,13 +81,21 @@
         }
     }
 
+    /**
+     * Learn whether another ConditionalUnaryPredicate is equal to this.
+     * @param that ConditionalUnaryPredicate to test
+     * @return boolean
+     */
     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)) &&
-                (null == elsePred ? null == that.elsePred : elsePred.equals(that.elsePred));
+        return null != that
+                && (null == ifPred ? null == that.ifPred : ifPred.equals(that.ifPred))
+                && (null == thenPred ? null == that.thenPred : thenPred.equals(that.thenPred))
+                && (null == elsePred ? null == that.elsePred : elsePred.equals(that.elsePred));
     }
 
+    /**
+     * {@inheritDoc}
+     */
     public int hashCode() {
         int hash = "ConditionalUnaryPredicate".hashCode();
         if (null != ifPred) {
@@ -89,13 +113,11 @@
         return hash;
     }
 
+    /**
+     * {@inheritDoc}
+     */
     public String toString() {
         return "ConditionalUnaryPredicate<" + ifPred + "?" + thenPred + ":" + elsePred + ">";
     }
 
-    // attributes
-    // ------------------------------------------------------------------------
-    private UnaryPredicate ifPred = null;
-    private UnaryPredicate thenPred = null;
-    private UnaryPredicate elsePred = null;
 }

Modified: commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/DoWhileProcedure.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/DoWhileProcedure.java?rev=644988&r1=644987&r2=644988&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/DoWhileProcedure.java (original)
+++ commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/DoWhileProcedure.java Fri Apr  4 16:08:18 2008
@@ -39,8 +39,8 @@
 public class DoWhileProcedure extends AbstractLoopProcedure {
     /**
      * Create a new DoWhileProcedure.
-     * @param action
-     * @param condition
+     * @param action to do
+     * @param condition while true
      */
     public DoWhileProcedure(Procedure action, Predicate condition) {
         super(condition, action);
@@ -60,9 +60,9 @@
      */
     public boolean equals(Object object) {
         if (object instanceof DoWhileProcedure) {
-        	return super.equals(object);
+            return super.equals(object);
         } else {
-        	return false;
+            return false;
         }
     }
 
@@ -70,7 +70,7 @@
      * {@inheritDoc}
      */
     public int hashCode() {
-    	return super.hashCode("DoWhileProcedure".hashCode());
+        return super.hashCode("DoWhileProcedure".hashCode());
     }
 
     /**

Modified: commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/Not.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/Not.java?rev=644988&r1=644987&r2=644988&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/Not.java (original)
+++ commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/Not.java Fri Apr  4 16:08:18 2008
@@ -35,30 +35,33 @@
  * @author Rodney Waldhoff
  */
 public final class Not implements Predicate, Serializable {
-    
-    // static
-    // ------------------------------------------------------------------------
-    public static Predicate not(Predicate that) {
-        return null == that ? null : new Not(that);
-    }
-    
+
     // attributes
     // ------------------------------------------------------------------------
     private Predicate predicate = null;
 
     // constructor
     // ------------------------------------------------------------------------
-
+    /**
+     * Create a new Not.
+     * @param p Predicate to negate
+     */
     public Not(Predicate p) {
         this.predicate = p;
     }
 
     // predicate interface
     // ------------------------------------------------------------------------
+    /**
+     * {@inheritDoc}
+     */
     public boolean test() {
         return !(predicate.test());
     }
 
+    /**
+     * {@inheritDoc}
+     */
     public boolean equals(Object that) {
         if (that instanceof Not) {
             return equals((Not) that);
@@ -67,10 +70,18 @@
         }
     }
 
+    /**
+     * Learn whether another Not is equal to this.
+     * @param that the Not to test
+     * @return boolean
+     */
     public boolean equals(Not that) {
         return null != that && (null == predicate ? null == that.predicate : predicate.equals(that.predicate));
     }
 
+    /**
+     * {@inheritDoc}
+     */
     public int hashCode() {
         int hash = "Not".hashCode();
         if (null != predicate) {
@@ -79,7 +90,21 @@
         return hash;
     }
 
+    /**
+     * {@inheritDoc}
+     */
     public String toString() {
         return "Not<" + predicate + ">";
+    }
+
+    // static
+    // ------------------------------------------------------------------------
+    /**
+     * Get a Not instance for <code>that</code>.
+     * @param that Predicate to negate
+     * @return Not
+     */
+    public static Predicate not(Predicate that) {
+        return null == that ? null : new Not(that);
     }
 }

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=644988&r1=644987&r2=644988&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 Fri Apr  4 16:08:18 2008
@@ -42,15 +42,31 @@
  */
 public class Sequence implements Procedure, Serializable {
 
+    // attributes
+    // ------------------------------------------------------------------------
+    private List list = new ArrayList();
+
     // constructor
     // ------------------------------------------------------------------------
+    /**
+     * Create a new Sequence.
+     */
     public Sequence() {
     }
 
+    /**
+     * Create a new Sequence.
+     * @param p Procedure to add
+     */
     public Sequence(Procedure p) {
         then(p);
     }
 
+    /**
+     * Create a new Sequence.
+     * @param p Procedure to add
+     * @param q Procedure to add
+     */
     public Sequence(Procedure p, Procedure q) {
         then(p);
         then(q);
@@ -58,6 +74,11 @@
 
     // modifiers
     // ------------------------------------------------------------------------
+    /**
+     * Fluently add a Procedure.
+     * @param p Procedure to add
+     * @return this
+     */
     public Sequence then(Procedure p) {
         list.add(p);
         return this;
@@ -65,12 +86,18 @@
 
     // predicate interface
     // ------------------------------------------------------------------------
+    /**
+     * {@inheritDoc}
+     */
     public void run() {
         for (ListIterator iter = list.listIterator(list.size()); iter.hasPrevious();) {
             ((Procedure) iter.previous()).run();
         }
     }
 
+    /**
+     * {@inheritDoc}
+     */
     public boolean equals(Object that) {
         if (that instanceof Sequence) {
             return equals((Sequence) that);
@@ -79,23 +106,29 @@
         }
     }
 
+    /**
+     * Learn whether a given Sequence is equal to this.
+     * @param that Sequence to test
+     * @return boolean
+     */
     public boolean equals(Sequence that) {
         // by construction, list is never null
         return null != that && list.equals(that.list);
     }
 
+    /**
+     * {@inheritDoc}
+     */
     public int hashCode() {
         // by construction, list is never null
         return "Sequence".hashCode() ^ list.hashCode();
     }
 
+    /**
+     * {@inheritDoc}
+     */
     public String toString() {
         return "Sequence<" + list + ">";
     }
-
-
-    // attributes
-    // ------------------------------------------------------------------------
-    private List list = new ArrayList();
 
 }

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=644988&r1=644987&r2=644988&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 Fri Apr  4 16:08:18 2008
@@ -25,14 +25,18 @@
 import org.apache.commons.functor.generator.IteratorToGeneratorAdapter;
 
 /**
- * Generator for each element of a collection.
+ * Generator factory for each element of a "collection".
  *
  * @since 1.0
  * @version $Revision$ $Date$
  * @author  Jason Horman (jason@jhorman.org)
  */
-
 public final class EachElement {
+    /**
+     * Get a Generator for each element of a Collection.
+     * @param collection to iterate
+     * @return Generator
+     */
     public static final Generator from(Collection collection) {
         if (null == collection) {
             return null;
@@ -41,6 +45,11 @@
         }
     }
 
+    /**
+     * Get a Generator for each entry of a Map.
+     * @param map to iterate
+     * @return Generator
+     */
     public static final Generator from(Map map) {
         if (null == map) {
             return null;
@@ -49,6 +58,11 @@
         }
     }
 
+    /**
+     * Get a Generator for each element of an Object[]. 
+     * @param array to iterate
+     * @return Generator
+     */
     public static final Generator from(Object[] array) {
         if (null == array) {
             return null;
@@ -57,6 +71,11 @@
         }
     }
 
+    /**
+     * Get a Generator for each element of an Iterator. 
+     * @param iter to iterate
+     * @return Generator
+     */
     public static final Generator from(Iterator iter) {
         if (null == iter) {
             return null;