commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mben...@apache.org
Subject svn commit: r1439123 [1/2] - in /commons/proper/functor/branches/FUNCTOR-14-mm: ./ core/ core/src/main/java/org/apache/commons/functor/core/algorithm/ core/src/main/java/org/apache/commons/functor/generator/ core/src/main/java/org/apache/commons/functo...
Date Sun, 27 Jan 2013 17:32:24 GMT
Author: mbenson
Date: Sun Jan 27 17:32:23 2013
New Revision: 1439123

URL: http://svn.apache.org/viewvc?rev=1439123&view=rev
Log:
apply Bruno's branch commits to a new branch based on the multi-module reorg

Added:
    commons/proper/functor/branches/FUNCTOR-14-mm/
      - copied from r1439120, commons/proper/functor/trunk/
    commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/loop/
      - copied from r1376354, commons/proper/functor/branches/generators-FUNCTOR-14/src/main/java/org/apache/commons/functor/generator/loop/
    commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/range/
      - copied from r1376354, commons/proper/functor/branches/generators-FUNCTOR-14/src/main/java/org/apache/commons/functor/generator/range/
    commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/range/BoundType.java
      - copied unchanged from r1385335, commons/proper/functor/branches/generators-FUNCTOR-14/src/main/java/org/apache/commons/functor/generator/range/BoundType.java
    commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/range/CharacterRange.java
      - copied unchanged from r1385335, commons/proper/functor/branches/generators-FUNCTOR-14/src/main/java/org/apache/commons/functor/generator/range/CharacterRange.java
    commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/range/DoubleRange.java
      - copied unchanged from r1385335, commons/proper/functor/branches/generators-FUNCTOR-14/src/main/java/org/apache/commons/functor/generator/range/DoubleRange.java
    commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/range/Endpoint.java
      - copied unchanged from r1385335, commons/proper/functor/branches/generators-FUNCTOR-14/src/main/java/org/apache/commons/functor/generator/range/Endpoint.java
    commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/range/FloatRange.java
      - copied unchanged from r1385335, commons/proper/functor/branches/generators-FUNCTOR-14/src/main/java/org/apache/commons/functor/generator/range/FloatRange.java
    commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/range/NumericRange.java
      - copied unchanged from r1385335, commons/proper/functor/branches/generators-FUNCTOR-14/src/main/java/org/apache/commons/functor/generator/range/NumericRange.java
    commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/range/Range.java
      - copied unchanged from r1385335, commons/proper/functor/branches/generators-FUNCTOR-14/src/main/java/org/apache/commons/functor/generator/range/Range.java
    commons/proper/functor/branches/FUNCTOR-14-mm/core/src/test/java/org/apache/commons/functor/generator/loop/
      - copied from r1376354, commons/proper/functor/branches/generators-FUNCTOR-14/src/test/java/org/apache/commons/functor/generator/loop/
    commons/proper/functor/branches/FUNCTOR-14-mm/core/src/test/java/org/apache/commons/functor/generator/range/
      - copied from r1376354, commons/proper/functor/branches/generators-FUNCTOR-14/src/test/java/org/apache/commons/functor/generator/range/
    commons/proper/functor/branches/FUNCTOR-14-mm/core/src/test/java/org/apache/commons/functor/generator/range/TestCharacterRange.java
      - copied unchanged from r1385335, commons/proper/functor/branches/generators-FUNCTOR-14/src/test/java/org/apache/commons/functor/generator/range/TestCharacterRange.java
    commons/proper/functor/branches/FUNCTOR-14-mm/core/src/test/java/org/apache/commons/functor/generator/range/TestDoubleRange.java
      - copied unchanged from r1385335, commons/proper/functor/branches/generators-FUNCTOR-14/src/test/java/org/apache/commons/functor/generator/range/TestDoubleRange.java
    commons/proper/functor/branches/FUNCTOR-14-mm/core/src/test/java/org/apache/commons/functor/generator/range/TestEndpoint.java
      - copied unchanged from r1385335, commons/proper/functor/branches/generators-FUNCTOR-14/src/test/java/org/apache/commons/functor/generator/range/TestEndpoint.java
    commons/proper/functor/branches/FUNCTOR-14-mm/core/src/test/java/org/apache/commons/functor/generator/range/TestFloatRange.java
      - copied unchanged from r1385335, commons/proper/functor/branches/generators-FUNCTOR-14/src/test/java/org/apache/commons/functor/generator/range/TestFloatRange.java
Removed:
    commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/GenerateUntil.java
    commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/GenerateWhile.java
    commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/IteratorToGeneratorAdapter.java
    commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/TransformedGenerator.java
    commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/UntilGenerate.java
    commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/WhileGenerate.java
    commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/util/IntegerRange.java
    commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/util/LongRange.java
    commons/proper/functor/branches/FUNCTOR-14-mm/core/src/test/java/org/apache/commons/functor/generator/TestGenerateUntil.java
    commons/proper/functor/branches/FUNCTOR-14-mm/core/src/test/java/org/apache/commons/functor/generator/TestGenerateWhile.java
    commons/proper/functor/branches/FUNCTOR-14-mm/core/src/test/java/org/apache/commons/functor/generator/TestIteratorToGeneratorAdapter.java
    commons/proper/functor/branches/FUNCTOR-14-mm/core/src/test/java/org/apache/commons/functor/generator/TestTransformedGenerator.java
    commons/proper/functor/branches/FUNCTOR-14-mm/core/src/test/java/org/apache/commons/functor/generator/TestUntilGenerate.java
    commons/proper/functor/branches/FUNCTOR-14-mm/core/src/test/java/org/apache/commons/functor/generator/TestWhileGenerate.java
    commons/proper/functor/branches/FUNCTOR-14-mm/core/src/test/java/org/apache/commons/functor/generator/util/TestIntegerRange.java
    commons/proper/functor/branches/FUNCTOR-14-mm/core/src/test/java/org/apache/commons/functor/generator/util/TestLongRange.java
Modified:
    commons/proper/functor/branches/FUNCTOR-14-mm/core/   (props changed)
    commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/core/algorithm/IndexOfInGenerator.java
    commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/BaseGenerator.java
    commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/FilteredGenerator.java
    commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/Generator.java
    commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/range/IntegerRange.java
    commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/range/LongRange.java
    commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/range/Ranges.java
    commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/util/CollectionTransformer.java
    commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/util/EachElement.java
    commons/proper/functor/branches/FUNCTOR-14-mm/core/src/test/java/org/apache/commons/functor/TestAlgorithms.java
    commons/proper/functor/branches/FUNCTOR-14-mm/core/src/test/java/org/apache/commons/functor/core/algorithm/TestFindWithinGenerator.java
    commons/proper/functor/branches/FUNCTOR-14-mm/core/src/test/java/org/apache/commons/functor/core/algorithm/TestFoldLeft.java
    commons/proper/functor/branches/FUNCTOR-14-mm/core/src/test/java/org/apache/commons/functor/core/algorithm/TestFoldRight.java
    commons/proper/functor/branches/FUNCTOR-14-mm/core/src/test/java/org/apache/commons/functor/core/algorithm/TestGeneratorContains.java
    commons/proper/functor/branches/FUNCTOR-14-mm/core/src/test/java/org/apache/commons/functor/core/algorithm/TestIndexOfInGenerator.java
    commons/proper/functor/branches/FUNCTOR-14-mm/core/src/test/java/org/apache/commons/functor/example/QuicksortExample.java
    commons/proper/functor/branches/FUNCTOR-14-mm/core/src/test/java/org/apache/commons/functor/example/kata/two/TestBinaryChop.java
    commons/proper/functor/branches/FUNCTOR-14-mm/core/src/test/java/org/apache/commons/functor/example/lines/Lines.java
    commons/proper/functor/branches/FUNCTOR-14-mm/core/src/test/java/org/apache/commons/functor/example/lines/TestLines.java
    commons/proper/functor/branches/FUNCTOR-14-mm/core/src/test/java/org/apache/commons/functor/example/map/FixedSizeMap.java
    commons/proper/functor/branches/FUNCTOR-14-mm/core/src/test/java/org/apache/commons/functor/generator/TestBaseGenerator.java
    commons/proper/functor/branches/FUNCTOR-14-mm/core/src/test/java/org/apache/commons/functor/generator/TestFilteredGenerator.java
    commons/proper/functor/branches/FUNCTOR-14-mm/core/src/test/java/org/apache/commons/functor/generator/range/TestIntegerRange.java
    commons/proper/functor/branches/FUNCTOR-14-mm/core/src/test/java/org/apache/commons/functor/generator/range/TestLongRange.java
    commons/proper/functor/branches/FUNCTOR-14-mm/core/src/test/java/org/apache/commons/functor/generator/util/TestEachElement.java
    commons/proper/functor/branches/FUNCTOR-14-mm/src/changes/   (props changed)
    commons/proper/functor/branches/FUNCTOR-14-mm/src/changes/changes.xml
    commons/proper/functor/branches/FUNCTOR-14-mm/src/site/   (props changed)
    commons/proper/functor/branches/FUNCTOR-14-mm/src/site/xdoc/examples.xml

Propchange: commons/proper/functor/branches/FUNCTOR-14-mm/core/
------------------------------------------------------------------------------
--- svn:mergeinfo (added)
+++ svn:mergeinfo Sun Jan 27 17:32:23 2013
@@ -0,0 +1 @@
+/commons/proper/functor/branches/generators-FUNCTOR-14:1373984,1376354,1385335

Modified: commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/core/algorithm/IndexOfInGenerator.java
URL: http://svn.apache.org/viewvc/commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/core/algorithm/IndexOfInGenerator.java?rev=1439123&r1=1439120&r2=1439123&view=diff
==============================================================================
--- commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/core/algorithm/IndexOfInGenerator.java (original)
+++ commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/core/algorithm/IndexOfInGenerator.java Sun Jan 27 17:32:23 2013
@@ -21,20 +21,21 @@ import java.io.Serializable;
 import org.apache.commons.functor.BinaryFunction;
 import org.apache.commons.functor.UnaryPredicate;
 import org.apache.commons.functor.UnaryProcedure;
-import org.apache.commons.functor.generator.Generator;
+import org.apache.commons.functor.generator.loop.LoopGenerator;
 
 /**
- * Return the index of the first Object in a {@link Generator} matching a {@link UnaryPredicate}, or -1 if not found.
+ * Return the index of the first Object in a {@link LoopGenerator} matching a
+ * {@link UnaryPredicate}, or -1 if not found.
  *
  * @param <T> the procedure argument types
  * @version $Revision$ $Date$
  */
 public final class IndexOfInGenerator<T>
-    implements BinaryFunction<Generator<? extends T>, UnaryPredicate<? super T>, Number>, Serializable {
+    implements BinaryFunction<LoopGenerator<? extends T>, UnaryPredicate<? super T>, Number>, Serializable {
     /**
      * serialVersionUID declaration.
      */
-    private static final long serialVersionUID = -11365986575536471L;
+    private static final long serialVersionUID = -2672603607256310480L;
     /**
      * A static {@code IndexOfInGenerator} instance reference.
      */
@@ -49,7 +50,7 @@ public final class IndexOfInGenerator<T>
         /**
          * The wrapped generator.
          */
-        private final Generator<? extends T> generator;
+        private final LoopGenerator<? extends T> generator;
         /**
          * The wrapped predicate.
          */
@@ -70,7 +71,7 @@ public final class IndexOfInGenerator<T>
          * @param generator The wrapped generator
          * @param pred The wrapped predicate
          */
-        IndexProcedure(Generator<? extends T> generator, UnaryPredicate<? super T> pred) {
+        IndexProcedure(LoopGenerator<? extends T> generator, UnaryPredicate<? super T> pred) {
             this.generator = generator;
             this.pred = pred;
         }
@@ -92,7 +93,7 @@ public final class IndexOfInGenerator<T>
      * @param left Generator
      * @param right UnaryPredicate
      */
-    public Number evaluate(Generator<? extends T> left, UnaryPredicate<? super T> right) {
+    public Number evaluate(LoopGenerator<? extends T> left, UnaryPredicate<? super T> right) {
         IndexProcedure<T> findProcedure = new IndexProcedure<T>(left, right);
         left.run(findProcedure);
         return Long.valueOf(findProcedure.index);

Modified: commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/BaseGenerator.java
URL: http://svn.apache.org/viewvc/commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/BaseGenerator.java?rev=1439123&r1=1439120&r2=1439123&view=diff
==============================================================================
--- commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/BaseGenerator.java (original)
+++ commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/BaseGenerator.java Sun Jan 27 17:32:23 2013
@@ -29,52 +29,9 @@ import org.apache.commons.functor.genera
  */
 public abstract class BaseGenerator<E> implements Generator<E> {
 
-    /** A generator can wrap another generator. */
-    private final Generator<?> wrappedGenerator;
-
-    /** Set to true when the generator is {@link #stop stopped}. */
-    private boolean stopped = false;
-
     /** Create a new generator. */
     public BaseGenerator() {
-        this(null);
-    }
-
-    /**
-     * A generator can wrap another generator. When wrapping generators you
-     * should use probably this constructor since doing so will cause the
-     * {@link #stop} method to stop the wrapped generator as well.
-     * @param generator Generator to wrap
-     */
-    public BaseGenerator(Generator<?> generator) {
-        this.wrappedGenerator = generator;
-    }
-
-    /**
-     * Get the generator that is being wrapped.
-     * @return Generator
-     */
-    protected Generator<?> getWrappedGenerator() {
-        return wrappedGenerator;
-    }
-
-    /**
-     * {@inheritDoc}
-     * Stop the generator. Will stop the wrapped generator if one was set.
-     */
-    public void stop() {
-        if (wrappedGenerator != null) {
-            wrappedGenerator.stop();
-        }
-        stopped = true;
-    }
-
-    /**
-     * {@inheritDoc}
-     * Check if the generator is stopped.
-     */
-    public boolean isStopped() {
-        return stopped;
+        super();
     }
 
     /**

Modified: commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/FilteredGenerator.java
URL: http://svn.apache.org/viewvc/commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/FilteredGenerator.java?rev=1439123&r1=1439120&r2=1439123&view=diff
==============================================================================
--- commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/FilteredGenerator.java (original)
+++ commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/FilteredGenerator.java Sun Jan 27 17:32:23 2013
@@ -31,7 +31,12 @@ import org.apache.commons.lang3.Validate
 public class FilteredGenerator<E> extends BaseGenerator<E> {
 
     /**
-     * The wrapped generator.
+     * A generator can wrap another generator.
+     * */
+    private Generator<? extends E> wrappedGenerator;
+
+    /**
+     * The predicate used to filter.
      */
     private final UnaryPredicate<? super E> pred;
 
@@ -41,7 +46,7 @@ public class FilteredGenerator<E> extend
      * @param pred filtering UnaryPredicate
      */
     public FilteredGenerator(Generator<? extends E> wrapped, UnaryPredicate<? super E> pred) {
-        super(Validate.notNull(wrapped, "Generator argument was null"));
+        this.wrappedGenerator = Validate.notNull(wrapped, "Generator argument was null");
         this.pred = Validate.notNull(pred, "UnaryPredicate argument was null");
     }
 
@@ -53,12 +58,11 @@ public class FilteredGenerator<E> extend
     }
 
     /**
-     * {@inheritDoc}
+     * Gets the wrapped generator.
+     * @return the wrapped Generator.
      */
-    @SuppressWarnings("unchecked")
-    @Override
     protected Generator<? extends E> getWrappedGenerator() {
-        return (Generator<? extends E>) super.getWrappedGenerator();
+        return this.wrappedGenerator;
     }
 
     /**

Modified: commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/Generator.java
URL: http://svn.apache.org/viewvc/commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/Generator.java?rev=1439123&r1=1439120&r2=1439123&view=diff
==============================================================================
--- commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/Generator.java (original)
+++ commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/Generator.java Sun Jan 27 17:32:23 2013
@@ -33,17 +33,6 @@ public interface Generator<E> {
     void run(UnaryProcedure<? super E> proc);
 
     /**
-     * Stop the generator. Will stop the wrapped generator if one was set.
-     */
-    void stop();
-
-    /**
-     * Check if the generator is stopped.
-     * @return true if stopped
-     */
-    boolean isStopped();
-
-    /**
      * Transforms this generator using the passed in
      * transformer. An example transformer might turn the contents of the
      * generator into a {@link Collection} of elements.
@@ -55,6 +44,7 @@ public interface Generator<E> {
 
     /**
      * Same as to(new CollectionTransformer(collection)).
+     * @param <C> the returned collection type.
      * @param collection Collection to which my elements should be added
      * @return <code>collection</code>
      */

Modified: commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/range/IntegerRange.java
URL: http://svn.apache.org/viewvc/commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/range/IntegerRange.java?rev=1439123&r1=1376354&r2=1439123&view=diff
==============================================================================
--- commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/range/IntegerRange.java (original)
+++ commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/range/IntegerRange.java Sun Jan 27 17:32:23 2013
@@ -1,7 +1,10 @@
 /*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
  *
  *      http://www.apache.org/licenses/LICENSE-2.0
  *
@@ -14,39 +17,51 @@
 
 package org.apache.commons.functor.generator.range;
 
+import org.apache.commons.functor.BinaryFunction;
 import org.apache.commons.functor.UnaryProcedure;
-import org.apache.commons.functor.generator.loop.LoopGenerator;
-
+import org.apache.commons.lang3.Validate;
 
 /**
- * A generator for the range <i>from</i> (inclusive) to <i>to</i> (exclusive).
+ * A range of integers.
  *
  * @since 1.0
  * @version $Revision$ $Date$
  */
-public final class IntegerRange extends LoopGenerator<Integer> {
-    // attributes
-    //---------------------------------------------------------------
+public class IntegerRange extends NumericRange<Integer> {
 
+    // attributes
+    // ---------------------------------------------------------------
     /**
-     * The start index.
+     * Left limit.
      */
-    private final int from;
+    private final Endpoint<Integer> leftEndpoint;
 
     /**
-     * The end index.
+     * Right limit.
      */
-    private final int to;
+    private final Endpoint<Integer> rightEndpoint;
 
     /**
-     * The increment counter.
+     * Increment step.
      */
     private final int step;
 
+    /**
+     * Calculate default step.
+     */
+    public static final BinaryFunction<Integer, Integer, Integer> DEFAULT_STEP =
+            new BinaryFunction<Integer, Integer, Integer>() {
+
+        public Integer evaluate(Integer left, Integer right) {
+            return left > right ? -1 : 1;
+        }
+    };
+
     // constructors
-    //---------------------------------------------------------------
+    // ---------------------------------------------------------------
     /**
      * Create a new IntegerRange.
+     *
      * @param from start
      * @param to end
      */
@@ -56,6 +71,7 @@ public final class IntegerRange extends 
 
     /**
      * Create a new IntegerRange.
+     *
      * @param from start
      * @param to end
      * @param step increment
@@ -66,41 +82,127 @@ public final class IntegerRange extends 
 
     /**
      * Create a new IntegerRange.
+     *
      * @param from start
      * @param to end
      */
     public IntegerRange(int from, int to) {
-        this(from, to, defaultStep(from, to));
+        this(from, to, DEFAULT_STEP.evaluate(from, to).intValue());
     }
 
     /**
      * Create a new IntegerRange.
+     *
      * @param from start
      * @param to end
      * @param step increment
      */
     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);
+        this(from, DEFAULT_LEFT_BOUND_TYPE, to, DEFAULT_RIGHT_BOUND_TYPE, step);
+    }
+
+    /**
+     * Create a new IntegerRange.
+     *
+     * @param from start
+     * @param leftBoundType type of left bound
+     * @param to end
+     * @param rightBoundType type of right bound
+     * @param step increment
+     */
+    public IntegerRange(int from, BoundType leftBoundType, int to,
+                        BoundType rightBoundType, int step) {
+        this.leftEndpoint = Validate
+            .notNull(new Endpoint<Integer>(from, leftBoundType),
+                     "Left Endpoint argument must not be null");
+        this.rightEndpoint = Validate
+            .notNull(new Endpoint<Integer>(to, rightBoundType),
+                     "Right Endpoint argument must not be null");
+        this.step = step;
+        if (from != to && Integer.signum(step) != Integer.signum(to - from)) {
+            throw new IllegalArgumentException("Will never reach " + to
+                                               + " from " + from
+                                               + " using step " + step);
         }
-        this.from = from;
-        this.to = to;
+    }
+
+    /**
+     * Create a new IntegerRange.
+     *
+     * @param from start
+     * @param to end
+     * @param step increment
+     */
+    public IntegerRange(Endpoint<Integer> from, Endpoint<Integer> to, int step) {
+        this.leftEndpoint = Validate
+            .notNull(from, "Left Endpoint argument must not be null");
+        this.rightEndpoint = Validate
+            .notNull(to, "Right Endpoint argument must not be null");
         this.step = step;
+        if (from != to
+            && Integer.signum(step) != Integer.signum(to.getValue()
+                                                   - from.getValue())) {
+            throw new IllegalArgumentException("Will never reach " + to
+                                               + " from " + from
+                                               + " using step " + step);
+        }
     }
 
     // methods
-    //---------------------------------------------------------------
+    // ---------------------------------------------------------------
+    /**
+     * {@inheritDoc}
+     */
+    public Endpoint<Integer> getLeftEndpoint() {
+        return this.leftEndpoint;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public Endpoint<Integer> getRightEndpoint() {
+        return this.rightEndpoint;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public Integer getStep() {
+        return this.step;
+    }
+
     /**
      * {@inheritDoc}
      */
     public void run(UnaryProcedure<? super Integer> proc) {
-        if (signOf(step) == -1) {
-            for (int i = from; i > to; i += step) {
-                proc.run(Integer.valueOf(i));
+        final int step = this.getStep();
+        final boolean includeLeftValue = this.getLeftEndpoint()
+            .getBoundType() == BoundType.CLOSED;
+        final boolean includeRightValue = this.getRightEndpoint()
+            .getBoundType() == BoundType.CLOSED;
+        final int leftValue = this.getLeftEndpoint().getValue();
+        final int rightValue = this.getRightEndpoint().getValue();
+        if (step < 0) {
+            final int from = includeLeftValue ? leftValue : leftValue + step;
+            if (includeRightValue) {
+                for (int i = from; i >= rightValue; i += step) {
+                    proc.run(i);
+                }
+            } else {
+                for (int i = from; i > rightValue; i += step) {
+                    proc.run(i);
+                }
             }
         } else {
-            for (int i = from; i < to; i += step) {
-                proc.run(Integer.valueOf(i));
+            final int from = includeLeftValue ? leftValue : leftValue + step;
+            if (includeRightValue) {
+                for (int i = from; i <= rightValue; i += step) {
+                    proc.run(i);
+                }
+            } else {
+                for (int i = from; i < rightValue; i += step) {
+                    proc.run(i);
+                }
             }
         }
     }
@@ -110,7 +212,9 @@ public final class IntegerRange extends 
      */
     @Override
     public String toString() {
-        return "IntegerRange<" + from + "," + to + "," + step + ">";
+        return "IntegerRange<" + this.leftEndpoint.toLeftString()
+                + ", " + this.rightEndpoint.toRightString()
+                + ", " + this.step + ">";
     }
 
     /**
@@ -125,7 +229,9 @@ public final class IntegerRange extends 
             return false;
         }
         IntegerRange that = (IntegerRange) obj;
-        return this.from == that.from && this.to == that.to && this.step == that.step;
+        return this.leftEndpoint.equals(that.leftEndpoint)
+                && this.rightEndpoint.equals(that.rightEndpoint)
+                && this.step == that.step;
     }
 
     /**
@@ -135,33 +241,11 @@ public final class IntegerRange extends 
     public int hashCode() {
         int hash = "IntegerRange".hashCode();
         hash <<= 2;
-        hash ^= from;
+        hash ^= this.leftEndpoint.getValue();
         hash <<= 2;
-        hash ^= to;
+        hash ^= this.rightEndpoint.getValue();
         hash <<= 2;
-        hash ^= step;
+        hash ^= this.step;
         return hash;
     }
-
-    // private methods
-    //---------------------------------------------------------------
-    /**
-     * Get <code>value/|value|</code> (0 when value == 0).
-     * @param value to test
-     * @return int
-     */
-    private static int signOf(int value) {
-        return value < 0 ? -1 : value > 0 ? 1 : 0;
-    }
-
-    /**
-     * Calculate default step to get from <code>from</code> to <code>to</code>.
-     * @param from start
-     * @param to end
-     * @return int
-     */
-    private static int defaultStep(int from, int to) {
-        return from > to ? -1 : 1;
-    }
-
 }

Modified: commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/range/LongRange.java
URL: http://svn.apache.org/viewvc/commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/range/LongRange.java?rev=1439123&r1=1376354&r2=1439123&view=diff
==============================================================================
--- commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/range/LongRange.java (original)
+++ commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/range/LongRange.java Sun Jan 27 17:32:23 2013
@@ -14,38 +14,50 @@
 
 package org.apache.commons.functor.generator.range;
 
+import org.apache.commons.functor.BinaryFunction;
 import org.apache.commons.functor.UnaryProcedure;
-import org.apache.commons.functor.generator.loop.LoopGenerator;
+import org.apache.commons.lang3.Validate;
 
 /**
- * A generator for the range <i>from</i> (inclusive) to <i>to</i> (exclusive).
+ * A range of longs.
  *
  * @since 1.0
  * @version $Revision$ $Date$
  */
-public final class LongRange extends LoopGenerator<Long> {
+public final class LongRange extends NumericRange<Long> {
     // attributes
     //---------------------------------------------------------------
 
     /**
-     * The start index.
+     * Left limit.
      */
-    private final long from;
+    private final Endpoint<Long> leftEndpoint;
 
     /**
-     * The end index.
+     * Right limit.
      */
-    private final long to;
+    private final Endpoint<Long> rightEndpoint;
 
     /**
-     * The increment counter.
+     * Increment step.
      */
     private final long step;
 
+    /**
+     * Calculate default step.
+     */
+    public static final BinaryFunction<Long, Long, Long> DEFAULT_STEP = new BinaryFunction<Long, Long, Long>() {
+
+        public Long evaluate(Long left, Long right) {
+            return left > right ? -1L : 1L;
+        }
+    };
+
     // constructors
-    //---------------------------------------------------------------
+    // ---------------------------------------------------------------
     /**
      * Create a new LongRange.
+     *
      * @param from start
      * @param to end
      */
@@ -55,6 +67,7 @@ public final class LongRange extends Loo
 
     /**
      * Create a new LongRange.
+     *
      * @param from start
      * @param to end
      * @param step increment
@@ -65,26 +78,69 @@ public final class LongRange extends Loo
 
     /**
      * Create a new LongRange.
+     *
      * @param from start
      * @param to end
      */
     public LongRange(long from, long to) {
-        this(from, to, defaultStep(from, to));
+        this(from, to, DEFAULT_STEP.evaluate(from, to).longValue());
     }
 
     /**
      * Create a new LongRange.
+     *
      * @param from start
      * @param to end
      * @param step increment
      */
     public LongRange(long from, long to, long step) {
-        if (from != to && signOf(step) != signOf(to - from)) {
-            throw new IllegalArgumentException("Will never reach " + to + " from " + from + " using step " + step);
+        this(from, DEFAULT_LEFT_BOUND_TYPE, to, DEFAULT_RIGHT_BOUND_TYPE, step);
+    }
+
+    /**
+     * Create a new LongRange.
+     *
+     * @param from start
+     * @param leftBoundType type of left bound
+     * @param to end
+     * @param rightBoundType type of right bound
+     * @param step increment
+     */
+    public LongRange(long from, BoundType leftBoundType, long to,
+                     BoundType rightBoundType, long step) {
+        this.leftEndpoint = Validate
+            .notNull(new Endpoint<Long>(from, leftBoundType),
+                     "Left Endpoint argument must not be null");
+        this.rightEndpoint = Validate
+            .notNull(new Endpoint<Long>(to, rightBoundType),
+                     "Right Endpoint argument must not be null");
+        this.step = step;
+        if (from != to && Long.signum(step) != Long.signum(to - from)) {
+            throw new IllegalArgumentException("Will never reach " + to
+                                               + " from " + from
+                                               + " using step " + step);
         }
-        this.from = from;
-        this.to = to;
+    }
+
+    /**
+     * Create a new LongRange.
+     *
+     * @param from start
+     * @param to end
+     * @param step increment
+     */
+    public LongRange(Endpoint<Long> from, Endpoint<Long> to, long step) {
+        this.leftEndpoint = Validate
+            .notNull(from, "Left Endpoint argument must not be null");
+        this.rightEndpoint = Validate
+            .notNull(to, "Right Endpoint argument must not be null");
         this.step = step;
+        if (from.equals(to) == Boolean.FALSE
+            && Long.signum(step) != Long.signum(to.getValue() - from.getValue())) {
+            throw new IllegalArgumentException("Will never reach " + to
+                                               + " from " + from
+                                               + " using step " + step);
+        }
     }
 
     // methods
@@ -93,13 +149,34 @@ public final class LongRange extends Loo
      * {@inheritDoc}
      */
     public void run(UnaryProcedure<? super Long> proc) {
-        if (signOf(step) == -1L) {
-            for (long i = from; i > to; i += step) {
-                proc.run(Long.valueOf(i));
+        final long step = this.getStep();
+        final boolean includeLeftValue = this.getLeftEndpoint()
+            .getBoundType() == BoundType.CLOSED;
+        final boolean includeRightValue = this.getRightEndpoint()
+            .getBoundType() == BoundType.CLOSED;
+        final long leftValue = this.getLeftEndpoint().getValue();
+        final long rightValue = this.getRightEndpoint().getValue();
+        if (step < 0) {
+            final long from = includeLeftValue ? leftValue : leftValue + step;
+            if (includeRightValue) {
+                for (long i = from; i >= rightValue; i += step) {
+                    proc.run(i);
+                }
+            } else {
+                for (long i = from; i > rightValue; i += step) {
+                    proc.run(i);
+                }
             }
         } else {
-            for (long i = from; i < to; i += step) {
-                proc.run(Long.valueOf(i));
+            final long from = includeLeftValue ? leftValue : leftValue + step;
+            if (includeRightValue) {
+                for (long i = from; i <= rightValue; i += step) {
+                    proc.run(i);
+                }
+            } else {
+                for (long i = from; i < rightValue; i += step) {
+                    proc.run(i);
+                }
             }
         }
     }
@@ -107,9 +184,31 @@ public final class LongRange extends Loo
     /**
      * {@inheritDoc}
      */
+    public Endpoint<Long> getLeftEndpoint() {
+        return this.leftEndpoint;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public Endpoint<Long> getRightEndpoint() {
+        return this.rightEndpoint;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public Long getStep() {
+        return this.step;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
     @Override
     public String toString() {
-        return "LongRange<" + from + "," + to + "," + step + ">";
+        return "LongRange<" + this.leftEndpoint.toLeftString() + ", "
+                + this.rightEndpoint.toRightString() + ", " + step + ">";
     }
 
     /**
@@ -124,7 +223,9 @@ public final class LongRange extends Loo
             return false;
         }
         LongRange that = (LongRange) obj;
-        return this.from == that.from && this.to == that.to && this.step == that.step;
+        return this.leftEndpoint.equals(that.leftEndpoint)
+                && this.rightEndpoint.equals(that.rightEndpoint)
+                && this.step == that.step;
     }
 
     /**
@@ -134,33 +235,12 @@ public final class LongRange extends Loo
     public int hashCode() {
         int hash = "LongRange".hashCode();
         hash <<= 2;
-        hash ^= from;
+        hash ^= this.leftEndpoint.getValue();
         hash <<= 2;
-        hash ^= to;
+        hash ^= this.rightEndpoint.getValue();
         hash <<= 2;
-        hash ^= step;
+        hash ^= this.step;
         return hash;
     }
 
-    // private methods
-    //---------------------------------------------------------------
-    /**
-     * Get <code>value/|value|</code> (0L when value == 0L).
-     * @param value to test
-     * @return long
-     */
-    private static long signOf(long value) {
-        return value < 0L ? -1L : value > 0L ? 1L : 0L;
-    }
-
-    /**
-     * Calculate default step to get from <code>from</code> to <code>to</code>.
-     * @param from start
-     * @param to end
-     * @return long
-     */
-    private static long defaultStep(long from, long to) {
-        return from > to ? -1L : 1L;
-    }
-
 }

Modified: commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/range/Ranges.java
URL: http://svn.apache.org/viewvc/commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/range/Ranges.java?rev=1439123&r1=1376354&r2=1439123&view=diff
==============================================================================
--- commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/range/Ranges.java (original)
+++ commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/range/Ranges.java Sun Jan 27 17:32:23 2013
@@ -1,18 +1,15 @@
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law
+ * or agreed to in writing, software distributed under the License is
+ * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the specific language
+ * governing permissions and limitations under the License.
  */
 package org.apache.commons.functor.generator.range;
 
@@ -22,6 +19,370 @@ package org.apache.commons.functor.gener
  * @since 1.0
  * @version $Revision: $ $Date: $
  */
-public class Ranges {
+public final class Ranges {
+
+    /**
+     * Hidden constructor as this only is a helper class with static methods.
+     */
+    private Ranges() {
+    }
+
+    /**
+     * Create a new IntegerRange.
+     *
+     * @param from start
+     * @param to end
+     * @return IntegerRange
+     */
+    public static IntegerRange integerRange(Number from, Number to) {
+        return new IntegerRange(from, to);
+    }
+
+    /**
+     * Create a new IntegerRange.
+     *
+     * @param from start
+     * @param to end
+     * @param step increment
+     * @return IntegerRange
+     */
+    public static IntegerRange integerRange(Number from, Number to, Number step) {
+        return new IntegerRange(from, to, step);
+    }
+
+    /**
+     * Create a new IntegerRange.
+     *
+     * @param from start
+     * @param to end
+     * @return IntegerRange
+     */
+    public static IntegerRange integerRange(int from, int to) {
+        return new IntegerRange(from, to);
+    }
+
+    /**
+     * Create a new IntegerRange.
+     *
+     * @param from start
+     * @param to end
+     * @param step increment
+     * @return IntegerRange
+     */
+    public static IntegerRange integerRange(int from, int to, int step) {
+        return new IntegerRange(from, to, step);
+    }
+
+    /**
+     * Create a new IntegerRange.
+     *
+     * @param from start
+     * @param leftBoundType type of left bound
+     * @param to end
+     * @param rightBoundType type of right bound
+     * @param step increment
+     * @return IntegerRange
+     */
+    public static IntegerRange integerRange(int from, BoundType leftBoundType,
+                                            int to, BoundType rightBoundType,
+                                            int step) {
+        return new IntegerRange(from, leftBoundType, to, rightBoundType, step);
+    }
+
+    /**
+     * Create a new IntegerRange.
+     *
+     * @param leftEndpoint start
+     * @param rightEndpoint end
+     * @param step increment
+     * @return IntegerRange
+     */
+    public static IntegerRange integerRange(Endpoint<Integer> leftEndpoint,
+                                                Endpoint<Integer> rightEndpoint,
+                                                int step) {
+        return new IntegerRange(leftEndpoint, rightEndpoint, step);
+    }
+
+    /**
+     * Create a new LongRange.
+     *
+     * @param from start
+     * @param to end
+     * @return LongRange
+     */
+    public static LongRange longRange(Number from, Number to) {
+        return new LongRange(from, to);
+    }
+
+    /**
+     * Create a new IntegerRange.
+     *
+     * @param from start
+     * @param to end
+     * @param step increment
+     * @return LongRange
+     */
+    public static LongRange longRange(Number from, Number to, Number step) {
+        return new LongRange(from, to, step);
+    }
+
+    /**
+     * Create a new LongRange.
+     *
+     * @param from start
+     * @param to end
+     * @return LongRange
+     */
+    public static LongRange longRange(long from, long to) {
+        return new LongRange(from, to);
+    }
+
+    /**
+     * Create a new LongRange.
+     *
+     * @param from start
+     * @param to end
+     * @param step increment
+     * @return LongRange
+     */
+    public static LongRange longRange(long from, long to, long step) {
+        return new LongRange(from, to, step);
+    }
+
+    /**
+     * Create a new LongRange.
+     *
+     * @param from start
+     * @param leftBoundType type of left bound
+     * @param to end
+     * @param rightBoundType type of right bound
+     * @param step increment
+     * @return LongRange
+     */
+    public static LongRange longRange(long from, BoundType leftBoundType,
+                                      long to, BoundType rightBoundType,
+                                      long step) {
+        return new LongRange(from, leftBoundType, to, rightBoundType, step);
+    }
+
+    /**
+     * Create a new LongRange.
+     *
+     * @param leftEndpoint start
+     * @param rightEndpoint end
+     * @param step increment
+     * @return LongRange
+     */
+    public static LongRange longRange(Endpoint<Long> leftEndpoint,
+                                                Endpoint<Long> rightEndpoint,
+                                                long step) {
+        return new LongRange(leftEndpoint, rightEndpoint, step);
+    }
+
+    /**
+     * Create a new FloatRange.
+     *
+     * @param from start
+     * @param to end
+     * @return FloatRange
+     */
+    public static FloatRange floatRange(Number from, Number to) {
+        return new FloatRange(from, to);
+    }
+
+    /**
+     * Create a new FloatRange.
+     *
+     * @param from start
+     * @param to end
+     * @param step increment
+     * @return FloatRange
+     */
+    public static FloatRange floatRange(Number from, Number to, Number step) {
+        return new FloatRange(from, to, step);
+    }
+
+    /**
+     * Create a new FloatRange.
+     *
+     * @param from start
+     * @param to end
+     * @return FloatRange
+     */
+    public static FloatRange floatRange(float from, float to) {
+        return new FloatRange(from, to);
+    }
+
+    /**
+     * Create a new FloatRange.
+     *
+     * @param from start
+     * @param to end
+     * @param step increment
+     * @return FloatRange
+     */
+    public static FloatRange floatRange(float from, float to, float step) {
+        return new FloatRange(from, to, step);
+    }
+
+    /**
+     * Create a new FloatRange.
+     *
+     * @param from start
+     * @param leftBoundType type of left bound
+     * @param to end
+     * @param rightBoundType type of right bound
+     * @param step increment
+     * @return FloatRange
+     */
+    public static FloatRange floatRange(float from, BoundType leftBoundType,
+                                        float to, BoundType rightBoundType,
+                                        float step) {
+        return new FloatRange(from, leftBoundType, to, rightBoundType, step);
+    }
+
+    /**
+     * Create a new FloatRange.
+     *
+     * @param leftEndpoint start
+     * @param rightEndpoint end
+     * @param step increment
+     * @return FloatRange
+     */
+    public static FloatRange floatRange(Endpoint<Float> leftEndpoint,
+                                                Endpoint<Float> rightEndpoint,
+                                                float step) {
+        return new FloatRange(leftEndpoint, rightEndpoint, step);
+    }
+
+    /**
+     * Create a new DoubleRange.
+     *
+     * @param from start
+     * @param to end
+     * @return DoubleRange
+     */
+    public static DoubleRange doubleRange(Number from, Number to) {
+        return new DoubleRange(from, to);
+    }
+
+    /**
+     * Create a new DoubleRange.
+     *
+     * @param from start
+     * @param to end
+     * @param step increment
+     * @return DoubleRange
+     */
+    public static DoubleRange doubleRange(Number from, Number to, Number step) {
+        return new DoubleRange(from, to, step);
+    }
+
+    /**
+     * Create a new DoubleRange.
+     *
+     * @param from start
+     * @param to end
+     * @return DoubleRange
+     */
+    public static DoubleRange doubleRange(double from, double to) {
+        return new DoubleRange(from, to);
+    }
+
+    /**
+     * Create a new DoubleRange.
+     *
+     * @param from start
+     * @param to end
+     * @param step increment
+     * @return DoubleRange
+     */
+    public static DoubleRange doubleRange(double from, double to, double step) {
+        return new DoubleRange(from, to, step);
+    }
+
+    /**
+     * Create a new DoubleRange.
+     *
+     * @param from start
+     * @param leftBoundType type of left bound
+     * @param to end
+     * @param rightBoundType type of right bound
+     * @param step increment
+     * @return DoubleRange
+     */
+    public static DoubleRange doubleRange(double from, BoundType leftBoundType,
+                                          double to, BoundType rightBoundType,
+                                          double step) {
+        return new DoubleRange(from, leftBoundType, to, rightBoundType, step);
+    }
+
+    /**
+     * Create a new DoubleRange.
+     *
+     * @param leftEndpoint start
+     * @param rightEndpoint end
+     * @param step increment
+     * @return DoubleRange
+     */
+    public static DoubleRange doubleRange(Endpoint<Double> leftEndpoint,
+                                                Endpoint<Double> rightEndpoint,
+                                                double step) {
+        return new DoubleRange(leftEndpoint, rightEndpoint, step);
+    }
+
+    /**
+     * Create a new CharacterRange.
+     *
+     * @param from start
+     * @param to end
+     * @return CharacterRange
+     */
+    public static CharacterRange characterRange(char from, char to) {
+        return new CharacterRange(from, to);
+    }
+
+    /**
+     * Create a new CharacterRange.
+     *
+     * @param from start
+     * @param to end
+     * @param step increment
+     * @return CharacterRange
+     */
+    public static CharacterRange characterRange(char from, char to, int step) {
+        return new CharacterRange(from, to, step);
+    }
+
+    /**
+     * Create a new CharacterRange.
+     *
+     * @param from start
+     * @param leftBoundType type of left bound
+     * @param to end
+     * @param rightBoundType type of right bound
+     * @param step increment
+     * @return CharacterRange
+     */
+    public static CharacterRange characterRange(char from,
+                                                BoundType leftBoundType,
+                                                char to,
+                                                BoundType rightBoundType,
+                                                int step) {
+        return new CharacterRange(from, leftBoundType, to, rightBoundType, step);
+    }
 
+    /**
+     * Create a new CharacterRange.
+     *
+     * @param leftEndpoint start
+     * @param rightEndpoint end
+     * @param step increment
+     * @return CharacterRange
+     */
+    public static CharacterRange characterRange(Endpoint<Character> leftEndpoint,
+                                                Endpoint<Character> rightEndpoint,
+                                                int step) {
+        return new CharacterRange(leftEndpoint, rightEndpoint, step);
+    }
 }

Modified: commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/util/CollectionTransformer.java
URL: http://svn.apache.org/viewvc/commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/util/CollectionTransformer.java?rev=1439123&r1=1439120&r2=1439123&view=diff
==============================================================================
--- commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/util/CollectionTransformer.java (original)
+++ commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/util/CollectionTransformer.java Sun Jan 27 17:32:23 2013
@@ -27,10 +27,12 @@ import org.apache.commons.lang3.Validate
  * the constructor an ArrayList will be returned from the transform method.
  *
  * @param <E> the type of elements held in the adapted collection.
+ * @param <C> the type of collection to be filled.
  * @since 1.0
  * @version $Revision$ $Date$
  */
-public class CollectionTransformer<E, C extends Collection<? super E>> implements UnaryFunction<Generator<? extends E>, C> {
+public class CollectionTransformer<E, C extends Collection<? super E>>
+                        implements UnaryFunction<Generator<? extends E>, C> {
     /*
      * TODO revisit this class... it could stand a more-descriptive name.  Also, it's a little
      * hard to say whether, for an instance constructed without a specific target collection,
@@ -72,6 +74,7 @@ public class CollectionTransformer<E, C 
 
     /**
      * Get a {@link CollectionTransformer} instance that simply returns any {@link Collection}.
+     * @param <E> the returned collection type.
      * @return {@link CollectionTransformer}
      */
     public static <E> CollectionTransformer<E, Collection<E>> toCollection() {

Modified: commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/util/EachElement.java
URL: http://svn.apache.org/viewvc/commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/util/EachElement.java?rev=1439123&r1=1439120&r2=1439123&view=diff
==============================================================================
--- commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/util/EachElement.java (original)
+++ commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/util/EachElement.java Sun Jan 27 17:32:23 2013
@@ -19,7 +19,7 @@ import java.util.Iterator;
 import java.util.Map;
 
 import org.apache.commons.functor.generator.Generator;
-import org.apache.commons.functor.generator.IteratorToGeneratorAdapter;
+import org.apache.commons.functor.generator.loop.IteratorToGeneratorAdapter;
 
 /**
  * Generator factory for each element of a "collection".

Modified: commons/proper/functor/branches/FUNCTOR-14-mm/core/src/test/java/org/apache/commons/functor/TestAlgorithms.java
URL: http://svn.apache.org/viewvc/commons/proper/functor/branches/FUNCTOR-14-mm/core/src/test/java/org/apache/commons/functor/TestAlgorithms.java?rev=1439123&r1=1439120&r2=1439123&view=diff
==============================================================================
--- commons/proper/functor/branches/FUNCTOR-14-mm/core/src/test/java/org/apache/commons/functor/TestAlgorithms.java (original)
+++ commons/proper/functor/branches/FUNCTOR-14-mm/core/src/test/java/org/apache/commons/functor/TestAlgorithms.java Sun Jan 27 17:32:23 2013
@@ -31,10 +31,10 @@ import java.util.Set;
 import org.apache.commons.functor.core.Identity;
 import org.apache.commons.functor.core.composite.UnaryNot;
 import org.apache.commons.functor.generator.FilteredGenerator;
-import org.apache.commons.functor.generator.Generator;
-import org.apache.commons.functor.generator.IteratorToGeneratorAdapter;
-import org.apache.commons.functor.generator.TransformedGenerator;
-import org.apache.commons.functor.generator.util.IntegerRange;
+import org.apache.commons.functor.generator.loop.IteratorToGeneratorAdapter;
+import org.apache.commons.functor.generator.loop.LoopGenerator;
+import org.apache.commons.functor.generator.loop.TransformedGenerator;
+import org.apache.commons.functor.generator.range.IntegerRange;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
@@ -116,7 +116,7 @@ public class TestAlgorithms {
 
     @Test
     public void testApplyToGenerator() {
-        Generator<Integer> gen = new IntegerRange(1,5);
+        LoopGenerator<Integer> gen = new IntegerRange(1,5);
         Summer summer = new Summer();
 
         new TransformedGenerator<Integer, Integer>(gen, new Doubler()).run(summer);

Modified: commons/proper/functor/branches/FUNCTOR-14-mm/core/src/test/java/org/apache/commons/functor/core/algorithm/TestFindWithinGenerator.java
URL: http://svn.apache.org/viewvc/commons/proper/functor/branches/FUNCTOR-14-mm/core/src/test/java/org/apache/commons/functor/core/algorithm/TestFindWithinGenerator.java?rev=1439123&r1=1439120&r2=1439123&view=diff
==============================================================================
--- commons/proper/functor/branches/FUNCTOR-14-mm/core/src/test/java/org/apache/commons/functor/core/algorithm/TestFindWithinGenerator.java (original)
+++ commons/proper/functor/branches/FUNCTOR-14-mm/core/src/test/java/org/apache/commons/functor/core/algorithm/TestFindWithinGenerator.java Sun Jan 27 17:32:23 2013
@@ -28,7 +28,7 @@ import org.apache.commons.functor.BaseFu
 import org.apache.commons.functor.UnaryPredicate;
 import org.apache.commons.functor.adapter.LeftBoundPredicate;
 import org.apache.commons.functor.core.IsEqual;
-import org.apache.commons.functor.generator.IteratorToGeneratorAdapter;
+import org.apache.commons.functor.generator.loop.IteratorToGeneratorAdapter;
 import org.junit.Test;
 
 /**

Modified: commons/proper/functor/branches/FUNCTOR-14-mm/core/src/test/java/org/apache/commons/functor/core/algorithm/TestFoldLeft.java
URL: http://svn.apache.org/viewvc/commons/proper/functor/branches/FUNCTOR-14-mm/core/src/test/java/org/apache/commons/functor/core/algorithm/TestFoldLeft.java?rev=1439123&r1=1439120&r2=1439123&view=diff
==============================================================================
--- commons/proper/functor/branches/FUNCTOR-14-mm/core/src/test/java/org/apache/commons/functor/core/algorithm/TestFoldLeft.java (original)
+++ commons/proper/functor/branches/FUNCTOR-14-mm/core/src/test/java/org/apache/commons/functor/core/algorithm/TestFoldLeft.java Sun Jan 27 17:32:23 2013
@@ -25,7 +25,7 @@ import java.util.List;
 
 import org.apache.commons.functor.BaseFunctorTest;
 import org.apache.commons.functor.BinaryFunction;
-import org.apache.commons.functor.generator.IteratorToGeneratorAdapter;
+import org.apache.commons.functor.generator.loop.IteratorToGeneratorAdapter;
 import org.junit.Test;
 
 /**

Modified: commons/proper/functor/branches/FUNCTOR-14-mm/core/src/test/java/org/apache/commons/functor/core/algorithm/TestFoldRight.java
URL: http://svn.apache.org/viewvc/commons/proper/functor/branches/FUNCTOR-14-mm/core/src/test/java/org/apache/commons/functor/core/algorithm/TestFoldRight.java?rev=1439123&r1=1439120&r2=1439123&view=diff
==============================================================================
--- commons/proper/functor/branches/FUNCTOR-14-mm/core/src/test/java/org/apache/commons/functor/core/algorithm/TestFoldRight.java (original)
+++ commons/proper/functor/branches/FUNCTOR-14-mm/core/src/test/java/org/apache/commons/functor/core/algorithm/TestFoldRight.java Sun Jan 27 17:32:23 2013
@@ -25,7 +25,7 @@ import java.util.List;
 
 import org.apache.commons.functor.BaseFunctorTest;
 import org.apache.commons.functor.BinaryFunction;
-import org.apache.commons.functor.generator.IteratorToGeneratorAdapter;
+import org.apache.commons.functor.generator.loop.IteratorToGeneratorAdapter;
 import org.junit.Test;
 
 /**

Modified: commons/proper/functor/branches/FUNCTOR-14-mm/core/src/test/java/org/apache/commons/functor/core/algorithm/TestGeneratorContains.java
URL: http://svn.apache.org/viewvc/commons/proper/functor/branches/FUNCTOR-14-mm/core/src/test/java/org/apache/commons/functor/core/algorithm/TestGeneratorContains.java?rev=1439123&r1=1439120&r2=1439123&view=diff
==============================================================================
--- commons/proper/functor/branches/FUNCTOR-14-mm/core/src/test/java/org/apache/commons/functor/core/algorithm/TestGeneratorContains.java (original)
+++ commons/proper/functor/branches/FUNCTOR-14-mm/core/src/test/java/org/apache/commons/functor/core/algorithm/TestGeneratorContains.java Sun Jan 27 17:32:23 2013
@@ -27,7 +27,7 @@ import org.apache.commons.functor.UnaryP
 import org.apache.commons.functor.adapter.LeftBoundPredicate;
 import org.apache.commons.functor.core.IsEqual;
 import org.apache.commons.functor.core.algorithm.GeneratorContains;
-import org.apache.commons.functor.generator.IteratorToGeneratorAdapter;
+import org.apache.commons.functor.generator.loop.IteratorToGeneratorAdapter;
 import org.junit.Test;
 
 /**

Modified: commons/proper/functor/branches/FUNCTOR-14-mm/core/src/test/java/org/apache/commons/functor/core/algorithm/TestIndexOfInGenerator.java
URL: http://svn.apache.org/viewvc/commons/proper/functor/branches/FUNCTOR-14-mm/core/src/test/java/org/apache/commons/functor/core/algorithm/TestIndexOfInGenerator.java?rev=1439123&r1=1439120&r2=1439123&view=diff
==============================================================================
--- commons/proper/functor/branches/FUNCTOR-14-mm/core/src/test/java/org/apache/commons/functor/core/algorithm/TestIndexOfInGenerator.java (original)
+++ commons/proper/functor/branches/FUNCTOR-14-mm/core/src/test/java/org/apache/commons/functor/core/algorithm/TestIndexOfInGenerator.java Sun Jan 27 17:32:23 2013
@@ -25,7 +25,7 @@ import org.apache.commons.functor.BaseFu
 import org.apache.commons.functor.UnaryPredicate;
 import org.apache.commons.functor.adapter.LeftBoundPredicate;
 import org.apache.commons.functor.core.IsEqual;
-import org.apache.commons.functor.generator.IteratorToGeneratorAdapter;
+import org.apache.commons.functor.generator.loop.IteratorToGeneratorAdapter;
 import org.junit.Test;
 
 /**

Modified: commons/proper/functor/branches/FUNCTOR-14-mm/core/src/test/java/org/apache/commons/functor/example/QuicksortExample.java
URL: http://svn.apache.org/viewvc/commons/proper/functor/branches/FUNCTOR-14-mm/core/src/test/java/org/apache/commons/functor/example/QuicksortExample.java?rev=1439123&r1=1439120&r2=1439123&view=diff
==============================================================================
--- commons/proper/functor/branches/FUNCTOR-14-mm/core/src/test/java/org/apache/commons/functor/example/QuicksortExample.java (original)
+++ commons/proper/functor/branches/FUNCTOR-14-mm/core/src/test/java/org/apache/commons/functor/example/QuicksortExample.java Sun Jan 27 17:32:23 2013
@@ -33,7 +33,7 @@ import org.apache.commons.functor.core.c
 import org.apache.commons.functor.core.comparator.IsLessThan;
 import org.apache.commons.functor.core.composite.ConditionalUnaryFunction;
 import org.apache.commons.functor.generator.FilteredGenerator;
-import org.apache.commons.functor.generator.IteratorToGeneratorAdapter;
+import org.apache.commons.functor.generator.loop.IteratorToGeneratorAdapter;
 import org.junit.Test;
 
 /*

Modified: commons/proper/functor/branches/FUNCTOR-14-mm/core/src/test/java/org/apache/commons/functor/example/kata/two/TestBinaryChop.java
URL: http://svn.apache.org/viewvc/commons/proper/functor/branches/FUNCTOR-14-mm/core/src/test/java/org/apache/commons/functor/example/kata/two/TestBinaryChop.java?rev=1439123&r1=1439120&r2=1439123&view=diff
==============================================================================
--- commons/proper/functor/branches/FUNCTOR-14-mm/core/src/test/java/org/apache/commons/functor/example/kata/two/TestBinaryChop.java (original)
+++ commons/proper/functor/branches/FUNCTOR-14-mm/core/src/test/java/org/apache/commons/functor/example/kata/two/TestBinaryChop.java Sun Jan 27 17:32:23 2013
@@ -26,7 +26,7 @@ import org.apache.commons.functor.Predic
 import org.apache.commons.functor.Procedure;
 import org.apache.commons.functor.core.algorithm.RecursiveEvaluation;
 import org.apache.commons.functor.core.algorithm.UntilDo;
-import org.apache.commons.functor.generator.util.IntegerRange;
+import org.apache.commons.functor.generator.range.IntegerRange;
 import org.junit.Test;
 
 /**

Modified: commons/proper/functor/branches/FUNCTOR-14-mm/core/src/test/java/org/apache/commons/functor/example/lines/Lines.java
URL: http://svn.apache.org/viewvc/commons/proper/functor/branches/FUNCTOR-14-mm/core/src/test/java/org/apache/commons/functor/example/lines/Lines.java?rev=1439123&r1=1439120&r2=1439123&view=diff
==============================================================================
--- commons/proper/functor/branches/FUNCTOR-14-mm/core/src/test/java/org/apache/commons/functor/example/lines/Lines.java (original)
+++ commons/proper/functor/branches/FUNCTOR-14-mm/core/src/test/java/org/apache/commons/functor/example/lines/Lines.java Sun Jan 27 17:32:23 2013
@@ -23,12 +23,12 @@ import java.io.FileReader;
 import java.io.Reader;
 
 import org.apache.commons.functor.UnaryProcedure;
-import org.apache.commons.functor.generator.BaseGenerator;
+import org.apache.commons.functor.generator.loop.LoopGenerator;
 
 /**
  * @version $Revision$ $Date$
  */
-public class Lines extends BaseGenerator<String> {
+public class Lines extends LoopGenerator<String> {
     public static Lines from(Reader reader) {
         return new Lines(reader);
     }

Modified: commons/proper/functor/branches/FUNCTOR-14-mm/core/src/test/java/org/apache/commons/functor/example/lines/TestLines.java
URL: http://svn.apache.org/viewvc/commons/proper/functor/branches/FUNCTOR-14-mm/core/src/test/java/org/apache/commons/functor/example/lines/TestLines.java?rev=1439123&r1=1439120&r2=1439123&view=diff
==============================================================================
--- commons/proper/functor/branches/FUNCTOR-14-mm/core/src/test/java/org/apache/commons/functor/example/lines/TestLines.java (original)
+++ commons/proper/functor/branches/FUNCTOR-14-mm/core/src/test/java/org/apache/commons/functor/example/lines/TestLines.java Sun Jan 27 17:32:23 2013
@@ -31,7 +31,7 @@ import org.apache.commons.functor.core.c
 import org.apache.commons.functor.core.composite.UnaryAnd;
 import org.apache.commons.functor.core.composite.UnaryNot;
 import org.apache.commons.functor.generator.FilteredGenerator;
-import org.apache.commons.functor.generator.TransformedGenerator;
+import org.apache.commons.functor.generator.loop.TransformedGenerator;
 
 /**
  * @version $Revision$ $Date$

Modified: commons/proper/functor/branches/FUNCTOR-14-mm/core/src/test/java/org/apache/commons/functor/example/map/FixedSizeMap.java
URL: http://svn.apache.org/viewvc/commons/proper/functor/branches/FUNCTOR-14-mm/core/src/test/java/org/apache/commons/functor/example/map/FixedSizeMap.java?rev=1439123&r1=1439120&r2=1439123&view=diff
==============================================================================
--- commons/proper/functor/branches/FUNCTOR-14-mm/core/src/test/java/org/apache/commons/functor/example/map/FixedSizeMap.java (original)
+++ commons/proper/functor/branches/FUNCTOR-14-mm/core/src/test/java/org/apache/commons/functor/example/map/FixedSizeMap.java Sun Jan 27 17:32:23 2013
@@ -24,7 +24,7 @@ import org.apache.commons.functor.Binary
 import org.apache.commons.functor.adapter.BinaryProcedureBinaryFunction;
 import org.apache.commons.functor.core.algorithm.GeneratorContains;
 import org.apache.commons.functor.core.composite.UnaryNot;
-import org.apache.commons.functor.generator.IteratorToGeneratorAdapter;
+import org.apache.commons.functor.generator.loop.IteratorToGeneratorAdapter;
 
 /**
  * @version $Revision$ $Date$

Modified: commons/proper/functor/branches/FUNCTOR-14-mm/core/src/test/java/org/apache/commons/functor/generator/TestBaseGenerator.java
URL: http://svn.apache.org/viewvc/commons/proper/functor/branches/FUNCTOR-14-mm/core/src/test/java/org/apache/commons/functor/generator/TestBaseGenerator.java?rev=1439123&r1=1439120&r2=1439123&view=diff
==============================================================================
--- commons/proper/functor/branches/FUNCTOR-14-mm/core/src/test/java/org/apache/commons/functor/generator/TestBaseGenerator.java (original)
+++ commons/proper/functor/branches/FUNCTOR-14-mm/core/src/test/java/org/apache/commons/functor/generator/TestBaseGenerator.java Sun Jan 27 17:32:23 2013
@@ -47,9 +47,6 @@ public class TestBaseGenerator {
             public void run(UnaryProcedure<? super Integer> proc) {
                 for (int i=0;i<5;i++) {
                     proc.run(new Integer(i));
-                    if (isStopped()) {
-                        break;
-                    }
                 }
             }
         };
@@ -95,60 +92,6 @@ public class TestBaseGenerator {
         assertEquals("01234", result.toString());
     }
 
-    @Test
-    public void testStop() {
-        final StringBuffer result = new StringBuffer();
-        simpleGenerator.run(new UnaryProcedure<Integer>() {
-            int i=0;
-            public void run(Integer obj) {
-                result.append(obj);
-                if (i++ > 1) {
-                    simpleGenerator.stop();
-                }
-            }
-        });
-
-        assertEquals("012", result.toString());
-    }
-
-    @Test
-    public void testWrappingGenerator() {
-        final StringBuffer result = new StringBuffer();
-        final Generator<Integer> gen = new BaseGenerator<Integer>(simpleGenerator) {
-            public void run(final UnaryProcedure<? super Integer> proc) {
-                Generator<Integer> wrapped = (Generator<Integer>)getWrappedGenerator();
-                assertSame(simpleGenerator, wrapped);
-                wrapped.run(new UnaryProcedure<Integer>() {
-                    public void run(Integer obj) {
-                        proc.run(new Integer(obj.intValue() + 1));
-                    }
-                });
-            }
-        };
-
-        gen.run(new UnaryProcedure<Integer>() {
-            public void run(Integer obj) {
-                result.append(obj);
-            }
-        });
-
-        assertEquals("12345", result.toString());
-
-        // try to stop the wrapped generator
-        final StringBuffer result2 = new StringBuffer();
-        gen.run(new UnaryProcedure<Integer>() {
-            int i=0;
-            public void run(Integer obj) {
-                result2.append(obj);
-                if (i++ > 1) {
-                    gen.stop();
-                }
-            }
-        });
-
-        assertEquals("123", result2.toString());
-    }
-
     // Tests
     // ------------------------------------------------------------------------
 

Modified: commons/proper/functor/branches/FUNCTOR-14-mm/core/src/test/java/org/apache/commons/functor/generator/TestFilteredGenerator.java
URL: http://svn.apache.org/viewvc/commons/proper/functor/branches/FUNCTOR-14-mm/core/src/test/java/org/apache/commons/functor/generator/TestFilteredGenerator.java?rev=1439123&r1=1439120&r2=1439123&view=diff
==============================================================================
--- commons/proper/functor/branches/FUNCTOR-14-mm/core/src/test/java/org/apache/commons/functor/generator/TestFilteredGenerator.java (original)
+++ commons/proper/functor/branches/FUNCTOR-14-mm/core/src/test/java/org/apache/commons/functor/generator/TestFilteredGenerator.java Sun Jan 27 17:32:23 2013
@@ -25,7 +25,7 @@ import java.util.List;
 
 import org.apache.commons.functor.UnaryPredicate;
 import org.apache.commons.functor.UnaryProcedure;
-import org.apache.commons.functor.generator.util.IntegerRange;
+import org.apache.commons.functor.generator.range.IntegerRange;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;



Mime
View raw message