commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ki...@apache.org
Subject svn commit: r1374881 - in /commons/proper/functor/branches/generators-FUNCTOR-14/src: main/java/org/apache/commons/functor/core/algorithm/ main/java/org/apache/commons/functor/generator/ main/java/org/apache/commons/functor/generator/loop/ main/java/or...
Date Sun, 19 Aug 2012 23:44:42 GMT
Author: kinow
Date: Sun Aug 19 23:44:40 2012
New Revision: 1374881

URL: http://svn.apache.org/viewvc?rev=1374881&view=rev
Log:
Removed the "stoppable" behavior from the Generator interface, and also removed 
the wrapped generator from BaseGenerator. Both were moved to a new abstract 
class, LoopGenerator.

The Generator of [functor] is responsible for executing a procedure for each 
element that is generates. However, there are some implementations of the 
Generator interface in [functor] that require special behavior (stoppable and 
wrapped generator). 

Moving this behaviors to a new class, now one can implement a new generator 
without having to implement stop (Liskov principle).

The implementations that control the execution flow were moved to the loop 
package. The existing IntegerRange and LongRange were moved to a range package, 
and an utility class Ranges has been created, but hasn't been implemented yet. 
This class will create ranges (that are generators).

TransformedGenerator has remarks about the suppression of warnings. This is a 
special generator, that wraps a generator, but returns another one. So it 
breaks the interface contract, and we suppress the warnings when we cast the 
wrapped generator. This class has been marked as final, to avoid bogus 
specializations.

The simplification of the Generator interface may be specially useful when 
separating classes for functor-api and functor-impl.

Tests were updated accordingly.

Added:
    commons/proper/functor/branches/generators-FUNCTOR-14/src/main/java/org/apache/commons/functor/generator/loop/
    commons/proper/functor/branches/generators-FUNCTOR-14/src/main/java/org/apache/commons/functor/generator/loop/LoopGenerator.java   (with props)
    commons/proper/functor/branches/generators-FUNCTOR-14/src/main/java/org/apache/commons/functor/generator/loop/package-info.java   (with props)
    commons/proper/functor/branches/generators-FUNCTOR-14/src/main/java/org/apache/commons/functor/generator/range/
    commons/proper/functor/branches/generators-FUNCTOR-14/src/main/java/org/apache/commons/functor/generator/range/Ranges.java   (with props)
    commons/proper/functor/branches/generators-FUNCTOR-14/src/main/java/org/apache/commons/functor/generator/range/package-info.java   (with props)
    commons/proper/functor/branches/generators-FUNCTOR-14/src/test/java/org/apache/commons/functor/generator/TestLoopGenerator.java   (with props)
Removed:
    commons/proper/functor/branches/generators-FUNCTOR-14/src/main/java/org/apache/commons/functor/generator/GenerateUntil.java
    commons/proper/functor/branches/generators-FUNCTOR-14/src/main/java/org/apache/commons/functor/generator/GenerateWhile.java
    commons/proper/functor/branches/generators-FUNCTOR-14/src/main/java/org/apache/commons/functor/generator/IteratorToGeneratorAdapter.java
    commons/proper/functor/branches/generators-FUNCTOR-14/src/main/java/org/apache/commons/functor/generator/TransformedGenerator.java
    commons/proper/functor/branches/generators-FUNCTOR-14/src/main/java/org/apache/commons/functor/generator/UntilGenerate.java
    commons/proper/functor/branches/generators-FUNCTOR-14/src/main/java/org/apache/commons/functor/generator/WhileGenerate.java
    commons/proper/functor/branches/generators-FUNCTOR-14/src/main/java/org/apache/commons/functor/generator/util/IntegerGenerator.java
    commons/proper/functor/branches/generators-FUNCTOR-14/src/main/java/org/apache/commons/functor/generator/util/LongGenerator.java
Modified:
    commons/proper/functor/branches/generators-FUNCTOR-14/src/main/java/org/apache/commons/functor/core/algorithm/IndexOfInGenerator.java
    commons/proper/functor/branches/generators-FUNCTOR-14/src/main/java/org/apache/commons/functor/generator/BaseGenerator.java
    commons/proper/functor/branches/generators-FUNCTOR-14/src/main/java/org/apache/commons/functor/generator/FilteredGenerator.java
    commons/proper/functor/branches/generators-FUNCTOR-14/src/main/java/org/apache/commons/functor/generator/Generator.java
    commons/proper/functor/branches/generators-FUNCTOR-14/src/main/java/org/apache/commons/functor/generator/util/CollectionTransformer.java
    commons/proper/functor/branches/generators-FUNCTOR-14/src/main/java/org/apache/commons/functor/generator/util/EachElement.java
    commons/proper/functor/branches/generators-FUNCTOR-14/src/test/java/org/apache/commons/functor/TestAlgorithms.java
    commons/proper/functor/branches/generators-FUNCTOR-14/src/test/java/org/apache/commons/functor/core/algorithm/TestFindWithinGenerator.java
    commons/proper/functor/branches/generators-FUNCTOR-14/src/test/java/org/apache/commons/functor/core/algorithm/TestFoldLeft.java
    commons/proper/functor/branches/generators-FUNCTOR-14/src/test/java/org/apache/commons/functor/core/algorithm/TestFoldRight.java
    commons/proper/functor/branches/generators-FUNCTOR-14/src/test/java/org/apache/commons/functor/core/algorithm/TestGeneratorContains.java
    commons/proper/functor/branches/generators-FUNCTOR-14/src/test/java/org/apache/commons/functor/core/algorithm/TestIndexOfInGenerator.java
    commons/proper/functor/branches/generators-FUNCTOR-14/src/test/java/org/apache/commons/functor/example/QuicksortExample.java
    commons/proper/functor/branches/generators-FUNCTOR-14/src/test/java/org/apache/commons/functor/example/kata/two/TestBinaryChop.java
    commons/proper/functor/branches/generators-FUNCTOR-14/src/test/java/org/apache/commons/functor/generator/TestBaseGenerator.java
    commons/proper/functor/branches/generators-FUNCTOR-14/src/test/java/org/apache/commons/functor/generator/TestFilteredGenerator.java
    commons/proper/functor/branches/generators-FUNCTOR-14/src/test/java/org/apache/commons/functor/generator/TestGenerateUntil.java
    commons/proper/functor/branches/generators-FUNCTOR-14/src/test/java/org/apache/commons/functor/generator/TestGenerateWhile.java
    commons/proper/functor/branches/generators-FUNCTOR-14/src/test/java/org/apache/commons/functor/generator/TestIteratorToGeneratorAdapter.java
    commons/proper/functor/branches/generators-FUNCTOR-14/src/test/java/org/apache/commons/functor/generator/TestTransformedGenerator.java
    commons/proper/functor/branches/generators-FUNCTOR-14/src/test/java/org/apache/commons/functor/generator/TestUntilGenerate.java
    commons/proper/functor/branches/generators-FUNCTOR-14/src/test/java/org/apache/commons/functor/generator/TestWhileGenerate.java
    commons/proper/functor/branches/generators-FUNCTOR-14/src/test/java/org/apache/commons/functor/generator/util/TestEachElement.java
    commons/proper/functor/branches/generators-FUNCTOR-14/src/test/java/org/apache/commons/functor/generator/util/TestIntegerRange.java
    commons/proper/functor/branches/generators-FUNCTOR-14/src/test/java/org/apache/commons/functor/generator/util/TestLongRange.java

Modified: commons/proper/functor/branches/generators-FUNCTOR-14/src/main/java/org/apache/commons/functor/core/algorithm/IndexOfInGenerator.java
URL: http://svn.apache.org/viewvc/commons/proper/functor/branches/generators-FUNCTOR-14/src/main/java/org/apache/commons/functor/core/algorithm/IndexOfInGenerator.java?rev=1374881&r1=1374880&r2=1374881&view=diff
==============================================================================
--- commons/proper/functor/branches/generators-FUNCTOR-14/src/main/java/org/apache/commons/functor/core/algorithm/IndexOfInGenerator.java (original)
+++ commons/proper/functor/branches/generators-FUNCTOR-14/src/main/java/org/apache/commons/functor/core/algorithm/IndexOfInGenerator.java Sun Aug 19 23:44:40 2012
@@ -49,7 +49,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 +70,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 +92,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/generators-FUNCTOR-14/src/main/java/org/apache/commons/functor/generator/BaseGenerator.java
URL: http://svn.apache.org/viewvc/commons/proper/functor/branches/generators-FUNCTOR-14/src/main/java/org/apache/commons/functor/generator/BaseGenerator.java?rev=1374881&r1=1374880&r2=1374881&view=diff
==============================================================================
--- commons/proper/functor/branches/generators-FUNCTOR-14/src/main/java/org/apache/commons/functor/generator/BaseGenerator.java (original)
+++ commons/proper/functor/branches/generators-FUNCTOR-14/src/main/java/org/apache/commons/functor/generator/BaseGenerator.java Sun Aug 19 23:44:40 2012
@@ -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/generators-FUNCTOR-14/src/main/java/org/apache/commons/functor/generator/FilteredGenerator.java
URL: http://svn.apache.org/viewvc/commons/proper/functor/branches/generators-FUNCTOR-14/src/main/java/org/apache/commons/functor/generator/FilteredGenerator.java?rev=1374881&r1=1374880&r2=1374881&view=diff
==============================================================================
--- commons/proper/functor/branches/generators-FUNCTOR-14/src/main/java/org/apache/commons/functor/generator/FilteredGenerator.java (original)
+++ commons/proper/functor/branches/generators-FUNCTOR-14/src/main/java/org/apache/commons/functor/generator/FilteredGenerator.java Sun Aug 19 23:44:40 2012
@@ -33,6 +33,11 @@ public class FilteredGenerator<E> extend
     /**
      * The wrapped generator.
      */
+    private final Generator<? extends E> wrappedGenerator;
+
+    /**
+     * The predicate used for filtering.
+     */
     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");
     }
 
@@ -49,16 +54,7 @@ public class FilteredGenerator<E> extend
      * {@inheritDoc}
      */
     public void run(UnaryProcedure<? super E> proc) {
-        getWrappedGenerator().run(new ConditionalUnaryProcedure<E>(pred, proc));
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    @SuppressWarnings("unchecked")
-    @Override
-    protected Generator<? extends E> getWrappedGenerator() {
-        return (Generator<? extends E>) super.getWrappedGenerator();
+        this.wrappedGenerator.run(new ConditionalUnaryProcedure<E>(pred, proc));
     }
 
     /**
@@ -73,7 +69,7 @@ public class FilteredGenerator<E> extend
             return false;
         }
         FilteredGenerator<?> other = (FilteredGenerator<?>) obj;
-        return other.getWrappedGenerator().equals(getWrappedGenerator()) && other.pred.equals(pred);
+        return other.wrappedGenerator.equals(this.wrappedGenerator) && other.pred.equals(pred);
     }
 
     /**
@@ -83,7 +79,7 @@ public class FilteredGenerator<E> extend
     public int hashCode() {
         int result = "FilteredGenerator".hashCode();
         result <<= 2;
-        Generator<?> gen = getWrappedGenerator();
+        Generator<?> gen = this.wrappedGenerator;
         result ^= gen.hashCode();
         result <<= 2;
         result ^= pred.hashCode();

Modified: commons/proper/functor/branches/generators-FUNCTOR-14/src/main/java/org/apache/commons/functor/generator/Generator.java
URL: http://svn.apache.org/viewvc/commons/proper/functor/branches/generators-FUNCTOR-14/src/main/java/org/apache/commons/functor/generator/Generator.java?rev=1374881&r1=1374880&r2=1374881&view=diff
==============================================================================
--- commons/proper/functor/branches/generators-FUNCTOR-14/src/main/java/org/apache/commons/functor/generator/Generator.java (original)
+++ commons/proper/functor/branches/generators-FUNCTOR-14/src/main/java/org/apache/commons/functor/generator/Generator.java Sun Aug 19 23:44:40 2012
@@ -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,7 +44,8 @@ public interface Generator<E> {
 
     /**
      * Same as to(new CollectionTransformer(collection)).
-     * @param collection Collection to which my elements should be added
+     * @param <C> the returned type of the collection.
+     * @param collection Collection to which my elements should be added.
      * @return <code>collection</code>
      */
     <C extends Collection<? super E>> C to(C collection);

Added: commons/proper/functor/branches/generators-FUNCTOR-14/src/main/java/org/apache/commons/functor/generator/loop/LoopGenerator.java
URL: http://svn.apache.org/viewvc/commons/proper/functor/branches/generators-FUNCTOR-14/src/main/java/org/apache/commons/functor/generator/loop/LoopGenerator.java?rev=1374881&view=auto
==============================================================================
--- commons/proper/functor/branches/generators-FUNCTOR-14/src/main/java/org/apache/commons/functor/generator/loop/LoopGenerator.java (added)
+++ commons/proper/functor/branches/generators-FUNCTOR-14/src/main/java/org/apache/commons/functor/generator/loop/LoopGenerator.java Sun Aug 19 23:44:40 2012
@@ -0,0 +1,79 @@
+/*
+ * 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.
+ */
+package org.apache.commons.functor.generator.loop;
+
+import org.apache.commons.functor.generator.BaseGenerator;
+import org.apache.commons.functor.generator.Generator;
+
+/**
+ * Base class for generators that control execution flow, and may need to
+ * stop the generation.
+ *
+ * @param <E> the type of elements held in this generator.
+ * @since 1.0
+ * @version $Revision:  $ $Date:  $
+ */
+public abstract class LoopGenerator<E> extends BaseGenerator<E> {
+
+    /** A generator can wrap another generator. */
+    private final Generator<? extends E> wrappedGenerator;
+
+    /** Set to true when the generator is {@link #stop stopped}. */
+    private boolean stopped = false;
+
+    /** Create a new generator. */
+    public LoopGenerator() {
+        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 LoopGenerator(Generator<? extends E> generator) {
+        this.wrappedGenerator = generator;
+    }
+
+    /**
+     * Get the generator that is being wrapped.
+     * @return Generator
+     */
+    protected Generator<? extends E> getWrappedGenerator() {
+        return wrappedGenerator;
+    }
+
+    /**
+     * Stop the generator. Will stop the wrapped generator if one was set.
+     */
+    public void stop() {
+        if (wrappedGenerator != null && wrappedGenerator instanceof LoopGenerator<?>) {
+            ((LoopGenerator<?>) wrappedGenerator).stop();
+        }
+        stopped = true;
+    }
+
+    /**
+     * Check if the generator is stopped.
+     * @return true if stopped
+     */
+    public boolean isStopped() {
+        return stopped;
+    }
+
+}

Propchange: commons/proper/functor/branches/generators-FUNCTOR-14/src/main/java/org/apache/commons/functor/generator/loop/LoopGenerator.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: commons/proper/functor/branches/generators-FUNCTOR-14/src/main/java/org/apache/commons/functor/generator/loop/package-info.java
URL: http://svn.apache.org/viewvc/commons/proper/functor/branches/generators-FUNCTOR-14/src/main/java/org/apache/commons/functor/generator/loop/package-info.java?rev=1374881&view=auto
==============================================================================
--- commons/proper/functor/branches/generators-FUNCTOR-14/src/main/java/org/apache/commons/functor/generator/loop/package-info.java (added)
+++ commons/proper/functor/branches/generators-FUNCTOR-14/src/main/java/org/apache/commons/functor/generator/loop/package-info.java Sun Aug 19 23:44:40 2012
@@ -0,0 +1,23 @@
+/*
+ * 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.
+ */
+
+/**
+ * <p>
+ * Contains code related to Generators that control execution flow.
+ * </p>
+ */
+package org.apache.commons.functor.generator.loop;

Propchange: commons/proper/functor/branches/generators-FUNCTOR-14/src/main/java/org/apache/commons/functor/generator/loop/package-info.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: commons/proper/functor/branches/generators-FUNCTOR-14/src/main/java/org/apache/commons/functor/generator/range/Ranges.java
URL: http://svn.apache.org/viewvc/commons/proper/functor/branches/generators-FUNCTOR-14/src/main/java/org/apache/commons/functor/generator/range/Ranges.java?rev=1374881&view=auto
==============================================================================
--- commons/proper/functor/branches/generators-FUNCTOR-14/src/main/java/org/apache/commons/functor/generator/range/Ranges.java (added)
+++ commons/proper/functor/branches/generators-FUNCTOR-14/src/main/java/org/apache/commons/functor/generator/range/Ranges.java Sun Aug 19 23:44:40 2012
@@ -0,0 +1,27 @@
+/*
+ * 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.
+ */
+package org.apache.commons.functor.generator.range;
+
+/**
+ * Utility class for creating ranges.
+ *
+ * @since 1.0
+ * @version $Revision:  $ $Date:  $
+ */
+public class Ranges {
+
+}

Propchange: commons/proper/functor/branches/generators-FUNCTOR-14/src/main/java/org/apache/commons/functor/generator/range/Ranges.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: commons/proper/functor/branches/generators-FUNCTOR-14/src/main/java/org/apache/commons/functor/generator/range/package-info.java
URL: http://svn.apache.org/viewvc/commons/proper/functor/branches/generators-FUNCTOR-14/src/main/java/org/apache/commons/functor/generator/range/package-info.java?rev=1374881&view=auto
==============================================================================
--- commons/proper/functor/branches/generators-FUNCTOR-14/src/main/java/org/apache/commons/functor/generator/range/package-info.java (added)
+++ commons/proper/functor/branches/generators-FUNCTOR-14/src/main/java/org/apache/commons/functor/generator/range/package-info.java Sun Aug 19 23:44:40 2012
@@ -0,0 +1,23 @@
+/*
+ * 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.
+ */
+
+/**
+ * <p>
+ * Contains utility code for Ranges.
+ * </p>
+ */
+package org.apache.commons.functor.generator.range;

Propchange: commons/proper/functor/branches/generators-FUNCTOR-14/src/main/java/org/apache/commons/functor/generator/range/package-info.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: commons/proper/functor/branches/generators-FUNCTOR-14/src/main/java/org/apache/commons/functor/generator/util/CollectionTransformer.java
URL: http://svn.apache.org/viewvc/commons/proper/functor/branches/generators-FUNCTOR-14/src/main/java/org/apache/commons/functor/generator/util/CollectionTransformer.java?rev=1374881&r1=1374880&r2=1374881&view=diff
==============================================================================
--- commons/proper/functor/branches/generators-FUNCTOR-14/src/main/java/org/apache/commons/functor/generator/util/CollectionTransformer.java (original)
+++ commons/proper/functor/branches/generators-FUNCTOR-14/src/main/java/org/apache/commons/functor/generator/util/CollectionTransformer.java Sun Aug 19 23:44:40 2012
@@ -72,6 +72,7 @@ public class CollectionTransformer<E, C 
 
     /**
      * Get a {@link CollectionTransformer} instance that simply returns any {@link Collection}.
+     * @param <E> the type of elements of the collection.
      * @return {@link CollectionTransformer}
      */
     public static <E> CollectionTransformer<E, Collection<E>> toCollection() {

Modified: commons/proper/functor/branches/generators-FUNCTOR-14/src/main/java/org/apache/commons/functor/generator/util/EachElement.java
URL: http://svn.apache.org/viewvc/commons/proper/functor/branches/generators-FUNCTOR-14/src/main/java/org/apache/commons/functor/generator/util/EachElement.java?rev=1374881&r1=1374880&r2=1374881&view=diff
==============================================================================
--- commons/proper/functor/branches/generators-FUNCTOR-14/src/main/java/org/apache/commons/functor/generator/util/EachElement.java (original)
+++ commons/proper/functor/branches/generators-FUNCTOR-14/src/main/java/org/apache/commons/functor/generator/util/EachElement.java Sun Aug 19 23:44:40 2012
@@ -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/generators-FUNCTOR-14/src/test/java/org/apache/commons/functor/TestAlgorithms.java
URL: http://svn.apache.org/viewvc/commons/proper/functor/branches/generators-FUNCTOR-14/src/test/java/org/apache/commons/functor/TestAlgorithms.java?rev=1374881&r1=1374880&r2=1374881&view=diff
==============================================================================
--- commons/proper/functor/branches/generators-FUNCTOR-14/src/test/java/org/apache/commons/functor/TestAlgorithms.java (original)
+++ commons/proper/functor/branches/generators-FUNCTOR-14/src/test/java/org/apache/commons/functor/TestAlgorithms.java Sun Aug 19 23:44:40 2012
@@ -32,9 +32,9 @@ import org.apache.commons.functor.core.I
 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.IntegerGenerator;
+import org.apache.commons.functor.generator.loop.IteratorToGeneratorAdapter;
+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 IntegerGenerator(1,5);
+        Generator<Integer> gen = new IntegerRange(1,5);
         Summer summer = new Summer();
 
         new TransformedGenerator<Integer, Integer>(gen, new Doubler()).run(summer);

Modified: commons/proper/functor/branches/generators-FUNCTOR-14/src/test/java/org/apache/commons/functor/core/algorithm/TestFindWithinGenerator.java
URL: http://svn.apache.org/viewvc/commons/proper/functor/branches/generators-FUNCTOR-14/src/test/java/org/apache/commons/functor/core/algorithm/TestFindWithinGenerator.java?rev=1374881&r1=1374880&r2=1374881&view=diff
==============================================================================
--- commons/proper/functor/branches/generators-FUNCTOR-14/src/test/java/org/apache/commons/functor/core/algorithm/TestFindWithinGenerator.java (original)
+++ commons/proper/functor/branches/generators-FUNCTOR-14/src/test/java/org/apache/commons/functor/core/algorithm/TestFindWithinGenerator.java Sun Aug 19 23:44:40 2012
@@ -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/generators-FUNCTOR-14/src/test/java/org/apache/commons/functor/core/algorithm/TestFoldLeft.java
URL: http://svn.apache.org/viewvc/commons/proper/functor/branches/generators-FUNCTOR-14/src/test/java/org/apache/commons/functor/core/algorithm/TestFoldLeft.java?rev=1374881&r1=1374880&r2=1374881&view=diff
==============================================================================
--- commons/proper/functor/branches/generators-FUNCTOR-14/src/test/java/org/apache/commons/functor/core/algorithm/TestFoldLeft.java (original)
+++ commons/proper/functor/branches/generators-FUNCTOR-14/src/test/java/org/apache/commons/functor/core/algorithm/TestFoldLeft.java Sun Aug 19 23:44:40 2012
@@ -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/generators-FUNCTOR-14/src/test/java/org/apache/commons/functor/core/algorithm/TestFoldRight.java
URL: http://svn.apache.org/viewvc/commons/proper/functor/branches/generators-FUNCTOR-14/src/test/java/org/apache/commons/functor/core/algorithm/TestFoldRight.java?rev=1374881&r1=1374880&r2=1374881&view=diff
==============================================================================
--- commons/proper/functor/branches/generators-FUNCTOR-14/src/test/java/org/apache/commons/functor/core/algorithm/TestFoldRight.java (original)
+++ commons/proper/functor/branches/generators-FUNCTOR-14/src/test/java/org/apache/commons/functor/core/algorithm/TestFoldRight.java Sun Aug 19 23:44:40 2012
@@ -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/generators-FUNCTOR-14/src/test/java/org/apache/commons/functor/core/algorithm/TestGeneratorContains.java
URL: http://svn.apache.org/viewvc/commons/proper/functor/branches/generators-FUNCTOR-14/src/test/java/org/apache/commons/functor/core/algorithm/TestGeneratorContains.java?rev=1374881&r1=1374880&r2=1374881&view=diff
==============================================================================
--- commons/proper/functor/branches/generators-FUNCTOR-14/src/test/java/org/apache/commons/functor/core/algorithm/TestGeneratorContains.java (original)
+++ commons/proper/functor/branches/generators-FUNCTOR-14/src/test/java/org/apache/commons/functor/core/algorithm/TestGeneratorContains.java Sun Aug 19 23:44:40 2012
@@ -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/generators-FUNCTOR-14/src/test/java/org/apache/commons/functor/core/algorithm/TestIndexOfInGenerator.java
URL: http://svn.apache.org/viewvc/commons/proper/functor/branches/generators-FUNCTOR-14/src/test/java/org/apache/commons/functor/core/algorithm/TestIndexOfInGenerator.java?rev=1374881&r1=1374880&r2=1374881&view=diff
==============================================================================
--- commons/proper/functor/branches/generators-FUNCTOR-14/src/test/java/org/apache/commons/functor/core/algorithm/TestIndexOfInGenerator.java (original)
+++ commons/proper/functor/branches/generators-FUNCTOR-14/src/test/java/org/apache/commons/functor/core/algorithm/TestIndexOfInGenerator.java Sun Aug 19 23:44:40 2012
@@ -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/generators-FUNCTOR-14/src/test/java/org/apache/commons/functor/example/QuicksortExample.java
URL: http://svn.apache.org/viewvc/commons/proper/functor/branches/generators-FUNCTOR-14/src/test/java/org/apache/commons/functor/example/QuicksortExample.java?rev=1374881&r1=1374880&r2=1374881&view=diff
==============================================================================
--- commons/proper/functor/branches/generators-FUNCTOR-14/src/test/java/org/apache/commons/functor/example/QuicksortExample.java (original)
+++ commons/proper/functor/branches/generators-FUNCTOR-14/src/test/java/org/apache/commons/functor/example/QuicksortExample.java Sun Aug 19 23:44:40 2012
@@ -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/generators-FUNCTOR-14/src/test/java/org/apache/commons/functor/example/kata/two/TestBinaryChop.java
URL: http://svn.apache.org/viewvc/commons/proper/functor/branches/generators-FUNCTOR-14/src/test/java/org/apache/commons/functor/example/kata/two/TestBinaryChop.java?rev=1374881&r1=1374880&r2=1374881&view=diff
==============================================================================
--- commons/proper/functor/branches/generators-FUNCTOR-14/src/test/java/org/apache/commons/functor/example/kata/two/TestBinaryChop.java (original)
+++ commons/proper/functor/branches/generators-FUNCTOR-14/src/test/java/org/apache/commons/functor/example/kata/two/TestBinaryChop.java Sun Aug 19 23:44:40 2012
@@ -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.IntegerGenerator;
+import org.apache.commons.functor.generator.range.IntegerRange;
 import org.junit.Test;
 
 /**
@@ -102,7 +102,7 @@ public class TestBinaryChop {
         assertEquals(-1, chopper.find(6, new int[] { 1, 3, 5, 7 }));
         assertEquals(-1, chopper.find(8, new int[] { 1, 3, 5, 7 }));
 
-        List<Integer> largeList = (List<Integer>) (new IntegerGenerator(0, 100001).toCollection());
+        List<Integer> largeList = (List<Integer>) (new IntegerRange(0, 100001).toCollection());
         assertEquals(-1, chopper.find(new Integer(-5), largeList));
         assertEquals(100000, chopper.find(new Integer(100000), largeList));
         assertEquals(0, chopper.find(new Integer(0), largeList));

Modified: commons/proper/functor/branches/generators-FUNCTOR-14/src/test/java/org/apache/commons/functor/generator/TestBaseGenerator.java
URL: http://svn.apache.org/viewvc/commons/proper/functor/branches/generators-FUNCTOR-14/src/test/java/org/apache/commons/functor/generator/TestBaseGenerator.java?rev=1374881&r1=1374880&r2=1374881&view=diff
==============================================================================
--- commons/proper/functor/branches/generators-FUNCTOR-14/src/test/java/org/apache/commons/functor/generator/TestBaseGenerator.java (original)
+++ commons/proper/functor/branches/generators-FUNCTOR-14/src/test/java/org/apache/commons/functor/generator/TestBaseGenerator.java Sun Aug 19 23:44:40 2012
@@ -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/generators-FUNCTOR-14/src/test/java/org/apache/commons/functor/generator/TestFilteredGenerator.java
URL: http://svn.apache.org/viewvc/commons/proper/functor/branches/generators-FUNCTOR-14/src/test/java/org/apache/commons/functor/generator/TestFilteredGenerator.java?rev=1374881&r1=1374880&r2=1374881&view=diff
==============================================================================
--- commons/proper/functor/branches/generators-FUNCTOR-14/src/test/java/org/apache/commons/functor/generator/TestFilteredGenerator.java (original)
+++ commons/proper/functor/branches/generators-FUNCTOR-14/src/test/java/org/apache/commons/functor/generator/TestFilteredGenerator.java Sun Aug 19 23:44:40 2012
@@ -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.IntegerGenerator;
+import org.apache.commons.functor.generator.range.IntegerRange;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
@@ -39,7 +39,7 @@ public class TestFilteredGenerator
 
     @Before
     public void setUp() throws Exception {
-        wrappedGenerator = new IntegerGenerator(1, 10);
+        wrappedGenerator = new IntegerRange(1, 10);
         filteredGenerator = new FilteredGenerator<Integer>(wrappedGenerator, isEven);
     }
 
@@ -70,13 +70,13 @@ public class TestFilteredGenerator
 
     @Test
     public void testEquals() {
-        Generator<Integer> anotherGenerate = new FilteredGenerator<Integer>(new IntegerGenerator(1, 10), isEven);
+        Generator<Integer> anotherGenerate = new FilteredGenerator<Integer>(new IntegerRange(1, 10), isEven);
         assertEquals(filteredGenerator, filteredGenerator);
         assertEquals(filteredGenerator, anotherGenerate);
         assertTrue(!filteredGenerator.equals((FilteredGenerator<Integer>)null));
 
 		Generator<Integer> aGenerateWithADifferentPredicate = new FilteredGenerator<Integer>(
-			new IntegerGenerator(1, 10), new UnaryPredicate<Integer>() {
+			new IntegerRange(1, 10), new UnaryPredicate<Integer>() {
 				public boolean test(Integer obj) {
 					return obj % 2 == 0;
 				}
@@ -84,7 +84,7 @@ public class TestFilteredGenerator
 
         assertTrue(!filteredGenerator.equals(aGenerateWithADifferentPredicate));
 
-        Generator<Integer> aGenerateWithADifferentWrapped = new FilteredGenerator<Integer>(new IntegerGenerator(1,11), isEven);
+        Generator<Integer> aGenerateWithADifferentWrapped = new FilteredGenerator<Integer>(new IntegerRange(1,11), isEven);
         assertTrue(!filteredGenerator.equals(aGenerateWithADifferentWrapped));
     }
 

Modified: commons/proper/functor/branches/generators-FUNCTOR-14/src/test/java/org/apache/commons/functor/generator/TestGenerateUntil.java
URL: http://svn.apache.org/viewvc/commons/proper/functor/branches/generators-FUNCTOR-14/src/test/java/org/apache/commons/functor/generator/TestGenerateUntil.java?rev=1374881&r1=1374880&r2=1374881&view=diff
==============================================================================
--- commons/proper/functor/branches/generators-FUNCTOR-14/src/test/java/org/apache/commons/functor/generator/TestGenerateUntil.java (original)
+++ commons/proper/functor/branches/generators-FUNCTOR-14/src/test/java/org/apache/commons/functor/generator/TestGenerateUntil.java Sun Aug 19 23:44:40 2012
@@ -20,7 +20,8 @@ import static org.junit.Assert.assertEqu
 import static org.junit.Assert.assertTrue;
 
 import org.apache.commons.functor.UnaryPredicate;
-import org.apache.commons.functor.generator.util.IntegerGenerator;
+import org.apache.commons.functor.generator.loop.GenerateUntil;
+import org.apache.commons.functor.generator.range.IntegerRange;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
@@ -34,7 +35,7 @@ public class TestGenerateUntil
 
     @Before
     public void setUp() throws Exception {
-        wrappedGenerator = new IntegerGenerator(1, 10);
+        wrappedGenerator = new IntegerRange(1, 10);
         generateUntil = new GenerateUntil<Integer>(wrappedGenerator, isMoreThanFive);
     }
 
@@ -65,13 +66,13 @@ public class TestGenerateUntil
 
     @Test
     public void testEquals() {
-        Generator<Integer> anotherGenerate = new GenerateUntil<Integer>(new IntegerGenerator(1, 10), isMoreThanFive);
+        Generator<Integer> anotherGenerate = new GenerateUntil<Integer>(new IntegerRange(1, 10), isMoreThanFive);
         assertEquals(generateUntil, generateUntil);
         assertEquals(generateUntil, anotherGenerate);
         assertTrue(!generateUntil.equals((GenerateUntil<Integer>)null));
 
 		Generator<Integer> aGenerateWithADifferentPredicate = new GenerateUntil<Integer>(
-				new IntegerGenerator(1, 10),
+				new IntegerRange(1, 10),
 				new UnaryPredicate<Integer>() {
 				public boolean test(Integer obj) {
 					return obj > FIVE;
@@ -79,7 +80,7 @@ public class TestGenerateUntil
 			});
         assertTrue(!generateUntil.equals(aGenerateWithADifferentPredicate));
 
-        Generator<Integer> aGenerateWithADifferentWrapped = new GenerateUntil<Integer>(new IntegerGenerator(1,2), isMoreThanFive);
+        Generator<Integer> aGenerateWithADifferentWrapped = new GenerateUntil<Integer>(new IntegerRange(1,2), isMoreThanFive);
         assertTrue(!generateUntil.equals(aGenerateWithADifferentWrapped));
     }
 

Modified: commons/proper/functor/branches/generators-FUNCTOR-14/src/test/java/org/apache/commons/functor/generator/TestGenerateWhile.java
URL: http://svn.apache.org/viewvc/commons/proper/functor/branches/generators-FUNCTOR-14/src/test/java/org/apache/commons/functor/generator/TestGenerateWhile.java?rev=1374881&r1=1374880&r2=1374881&view=diff
==============================================================================
--- commons/proper/functor/branches/generators-FUNCTOR-14/src/test/java/org/apache/commons/functor/generator/TestGenerateWhile.java (original)
+++ commons/proper/functor/branches/generators-FUNCTOR-14/src/test/java/org/apache/commons/functor/generator/TestGenerateWhile.java Sun Aug 19 23:44:40 2012
@@ -20,7 +20,8 @@ import static org.junit.Assert.assertEqu
 import static org.junit.Assert.assertTrue;
 
 import org.apache.commons.functor.UnaryPredicate;
-import org.apache.commons.functor.generator.util.IntegerGenerator;
+import org.apache.commons.functor.generator.loop.GenerateWhile;
+import org.apache.commons.functor.generator.range.IntegerRange;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
@@ -34,7 +35,7 @@ public class TestGenerateWhile
 
     @Before
     public void setUp() throws Exception {
-        wrappedGenerator = new IntegerGenerator(1, 10);
+        wrappedGenerator = new IntegerRange(1, 10);
         generateWhile = new GenerateWhile<Integer>(wrappedGenerator, isLessThanFive);
     }
 
@@ -65,13 +66,13 @@ public class TestGenerateWhile
 
     @Test
     public void testEquals() {
-        Generator<Integer> anotherGenerate = new GenerateWhile<Integer>(new IntegerGenerator(1, 10), isLessThanFive);
+        Generator<Integer> anotherGenerate = new GenerateWhile<Integer>(new IntegerRange(1, 10), isLessThanFive);
         assertEquals(generateWhile, generateWhile);
         assertEquals(generateWhile, anotherGenerate);
         assertTrue(!generateWhile.equals((GenerateWhile<Integer>)null));
 
 		Generator<Integer> aGenerateWithADifferentPredicate = new GenerateWhile<Integer>(
-			new IntegerGenerator(1, 10), new UnaryPredicate<Integer>() {
+			new IntegerRange(1, 10), new UnaryPredicate<Integer>() {
 				public boolean test(Integer obj) {
 					return obj < FIVE;
 				}
@@ -79,7 +80,7 @@ public class TestGenerateWhile
 
         assertTrue(!generateWhile.equals(aGenerateWithADifferentPredicate));
 
-        Generator<Integer> aGenerateWithADifferentWrapped = new GenerateWhile<Integer>(new IntegerGenerator(1,11), isLessThanFive);
+        Generator<Integer> aGenerateWithADifferentWrapped = new GenerateWhile<Integer>(new IntegerRange(1,11), isLessThanFive);
         assertTrue(!generateWhile.equals(aGenerateWithADifferentWrapped));
     }
 

Modified: commons/proper/functor/branches/generators-FUNCTOR-14/src/test/java/org/apache/commons/functor/generator/TestIteratorToGeneratorAdapter.java
URL: http://svn.apache.org/viewvc/commons/proper/functor/branches/generators-FUNCTOR-14/src/test/java/org/apache/commons/functor/generator/TestIteratorToGeneratorAdapter.java?rev=1374881&r1=1374880&r2=1374881&view=diff
==============================================================================
--- commons/proper/functor/branches/generators-FUNCTOR-14/src/test/java/org/apache/commons/functor/generator/TestIteratorToGeneratorAdapter.java (original)
+++ commons/proper/functor/branches/generators-FUNCTOR-14/src/test/java/org/apache/commons/functor/generator/TestIteratorToGeneratorAdapter.java Sun Aug 19 23:44:40 2012
@@ -26,6 +26,7 @@ import java.util.Iterator;
 import java.util.List;
 
 import org.apache.commons.functor.BaseFunctorTest;
+import org.apache.commons.functor.generator.loop.IteratorToGeneratorAdapter;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;

Added: commons/proper/functor/branches/generators-FUNCTOR-14/src/test/java/org/apache/commons/functor/generator/TestLoopGenerator.java
URL: http://svn.apache.org/viewvc/commons/proper/functor/branches/generators-FUNCTOR-14/src/test/java/org/apache/commons/functor/generator/TestLoopGenerator.java?rev=1374881&view=auto
==============================================================================
--- commons/proper/functor/branches/generators-FUNCTOR-14/src/test/java/org/apache/commons/functor/generator/TestLoopGenerator.java (added)
+++ commons/proper/functor/branches/generators-FUNCTOR-14/src/test/java/org/apache/commons/functor/generator/TestLoopGenerator.java Sun Aug 19 23:44:40 2012
@@ -0,0 +1,206 @@
+/*
+ * 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.
+ */
+package org.apache.commons.functor.generator;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertSame;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.LinkedList;
+import java.util.List;
+
+import org.apache.commons.functor.UnaryProcedure;
+import org.apache.commons.functor.generator.loop.LoopGenerator;
+import org.apache.commons.functor.generator.util.CollectionTransformer;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * Tests the Base Generator class.
+ */
+@SuppressWarnings("unchecked")
+public class TestLoopGenerator {
+
+    private LoopGenerator<Integer> simpleGenerator = null;
+
+    // Lifecycle
+    // ------------------------------------------------------------------------
+
+    @Before
+    public void setUp() throws Exception {
+        simpleGenerator = new LoopGenerator<Integer>() {
+            public void run(UnaryProcedure<? super Integer> proc) {
+                for (int i=0;i<5;i++) {
+                    proc.run(new Integer(i));
+                    if (isStopped()) {
+                        break;
+                    }
+                }
+            }
+        };
+
+        list = new ArrayList<Integer>();
+        evens = new ArrayList<Integer>();
+        doubled = new ArrayList<Integer>();
+        listWithDuplicates = new ArrayList<Integer>();
+        sum = 0;
+        for (int i=0;i<10;i++) {
+            list.add(new Integer(i));
+            doubled.add(new Integer(i*2));
+            listWithDuplicates.add(new Integer(i));
+            listWithDuplicates.add(new Integer(i));
+            sum += i;
+            if (i%2 == 0) {
+                evens.add(new Integer(i));
+            }
+        }
+    }
+
+    @After
+    public void tearDown() throws Exception {
+        simpleGenerator = null;
+        list = null;
+        evens = null;
+        listWithDuplicates = null;
+        sum = 0;
+    }
+
+    // Tests
+    // ------------------------------------------------------------------------
+
+    @Test
+    public void testSimpleGenerator() {
+        final StringBuffer result = new StringBuffer();
+        simpleGenerator.run(new UnaryProcedure<Integer>() {
+            public void run(Integer obj) {
+                result.append(obj);
+            }
+        });
+
+        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 LoopGenerator<Integer> gen = new LoopGenerator<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
+    // ------------------------------------------------------------------------
+
+    @Test
+    public void testTo() {
+        Collection<Integer> col = simpleGenerator.to(CollectionTransformer.<Integer> toCollection());
+        assertEquals("[0, 1, 2, 3, 4]", col.toString());
+
+        Collection<Integer> fillThis = new LinkedList<Integer>();
+        col = simpleGenerator.to(new CollectionTransformer<Integer, Collection<Integer>>(fillThis));
+        assertSame(fillThis, col);
+        assertEquals("[0, 1, 2, 3, 4]", col.toString());
+
+        col = (Collection<Integer>)simpleGenerator.toCollection();
+        assertEquals("[0, 1, 2, 3, 4]", col.toString());
+        assertEquals("[0, 1, 2, 3, 4]", col.toString());
+
+        fillThis = new LinkedList<Integer>();
+        col = (Collection<Integer>)simpleGenerator.to(fillThis);
+        assertSame(fillThis, col);
+        assertEquals("[0, 1, 2, 3, 4]", col.toString());
+    }
+
+    // Attributes
+    // ------------------------------------------------------------------------
+    private List<Integer> list = null;
+    private List<Integer> doubled = null;
+    private List<Integer> evens = null;
+    private List<Integer> listWithDuplicates = null;
+    @SuppressWarnings("unused")
+    private int sum = 0;
+//    private UnaryPredicate equalsThree = LeftBoundPredicate.bind(IsEqual.instance(),new Integer(3));
+//    private UnaryPredicate equalsTwentyThree = LeftBoundPredicate.bind(IsEqual.instance(),new Integer(23));
+//    private UnaryPredicate isEven = new UnaryPredicate() {
+//        public boolean test(Object obj) {
+//            return ((Number) obj).intValue() % 2 == 0;
+//        }
+//    };
+//    private UnaryPredicate isOdd = new UnaryPredicate() {
+//        public boolean test(Object obj) {
+//            return ((Number) obj).intValue() % 2 != 0;
+//        }
+//    };
+
+    // Classes
+    // ------------------------------------------------------------------------
+
+    static class Summer implements UnaryProcedure<Number> {
+        public void run(Number that) {
+            sum += (that).intValue();
+        }
+        public int sum = 0;
+    }
+}
\ No newline at end of file

Propchange: commons/proper/functor/branches/generators-FUNCTOR-14/src/test/java/org/apache/commons/functor/generator/TestLoopGenerator.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: commons/proper/functor/branches/generators-FUNCTOR-14/src/test/java/org/apache/commons/functor/generator/TestTransformedGenerator.java
URL: http://svn.apache.org/viewvc/commons/proper/functor/branches/generators-FUNCTOR-14/src/test/java/org/apache/commons/functor/generator/TestTransformedGenerator.java?rev=1374881&r1=1374880&r2=1374881&view=diff
==============================================================================
--- commons/proper/functor/branches/generators-FUNCTOR-14/src/test/java/org/apache/commons/functor/generator/TestTransformedGenerator.java (original)
+++ commons/proper/functor/branches/generators-FUNCTOR-14/src/test/java/org/apache/commons/functor/generator/TestTransformedGenerator.java Sun Aug 19 23:44:40 2012
@@ -22,7 +22,8 @@ import java.util.List;
 
 import org.apache.commons.functor.UnaryFunction;
 import org.apache.commons.functor.UnaryProcedure;
-import org.apache.commons.functor.generator.util.IntegerGenerator;
+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;
@@ -36,7 +37,7 @@ public class TestTransformedGenerator
 
     @Before
     public void setUp() throws Exception {
-        wrappedGenerator = new IntegerGenerator(1, 10);
+        wrappedGenerator = new IntegerRange(1, 10);
         sumsTwoGenerator = new TransformedGenerator<Integer, Integer>(wrappedGenerator, sumsTwo);
     }
 
@@ -82,7 +83,7 @@ public class TestTransformedGenerator
         assertTrue( !sumsTwoGenerator.equals(aGenerateWithADifferentFunction));
 
         TransformedGenerator<Integer, Integer> aTransformedGeneratorWithADifferentWrapped =
-        		new TransformedGenerator<Integer, Integer>(new IntegerGenerator(1,2), sumsTwo);
+        		new TransformedGenerator<Integer, Integer>(new IntegerRange(1,2), sumsTwo);
         assertTrue(!sumsTwoGenerator.equals(aTransformedGeneratorWithADifferentWrapped));
     }
 

Modified: commons/proper/functor/branches/generators-FUNCTOR-14/src/test/java/org/apache/commons/functor/generator/TestUntilGenerate.java
URL: http://svn.apache.org/viewvc/commons/proper/functor/branches/generators-FUNCTOR-14/src/test/java/org/apache/commons/functor/generator/TestUntilGenerate.java?rev=1374881&r1=1374880&r2=1374881&view=diff
==============================================================================
--- commons/proper/functor/branches/generators-FUNCTOR-14/src/test/java/org/apache/commons/functor/generator/TestUntilGenerate.java (original)
+++ commons/proper/functor/branches/generators-FUNCTOR-14/src/test/java/org/apache/commons/functor/generator/TestUntilGenerate.java Sun Aug 19 23:44:40 2012
@@ -25,7 +25,8 @@ import java.util.List;
 
 import org.apache.commons.functor.UnaryPredicate;
 import org.apache.commons.functor.UnaryProcedure;
-import org.apache.commons.functor.generator.util.IntegerGenerator;
+import org.apache.commons.functor.generator.loop.UntilGenerate;
+import org.apache.commons.functor.generator.range.IntegerRange;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
@@ -39,7 +40,7 @@ public class TestUntilGenerate
 
     @Before
     public void setUp() throws Exception {
-        wrappedGenerator = new IntegerGenerator(1, 10);
+        wrappedGenerator = new IntegerRange(1, 10);
         untilGenerate = new UntilGenerate<Integer>(isLessThanFive, wrappedGenerator);
     }
 
@@ -70,7 +71,7 @@ public class TestUntilGenerate
 
     @Test
     public void testEquals() {
-        Generator<Integer> anotherGenerate = new UntilGenerate<Integer>(isLessThanFive, new IntegerGenerator(1, 10));
+        Generator<Integer> anotherGenerate = new UntilGenerate<Integer>(isLessThanFive, new IntegerRange(1, 10));
         assertEquals(untilGenerate, untilGenerate);
         assertEquals(untilGenerate, anotherGenerate);
         assertTrue(!untilGenerate.equals((UntilGenerate<Integer>)null));
@@ -80,10 +81,10 @@ public class TestUntilGenerate
 				public boolean test(Integer obj) {
 					return obj < FIVE;
 				}
-			}, new IntegerGenerator(1, 10));
+			}, new IntegerRange(1, 10));
         assertTrue(!untilGenerate.equals(aGenerateWithADifferentPredicate));
 
-        Generator<Integer> aGenerateWithADifferentWrapped = new UntilGenerate<Integer>(isLessThanFive, new IntegerGenerator(1,2));
+        Generator<Integer> aGenerateWithADifferentWrapped = new UntilGenerate<Integer>(isLessThanFive, new IntegerRange(1,2));
         assertTrue(!untilGenerate.equals(aGenerateWithADifferentWrapped));
     }
 

Modified: commons/proper/functor/branches/generators-FUNCTOR-14/src/test/java/org/apache/commons/functor/generator/TestWhileGenerate.java
URL: http://svn.apache.org/viewvc/commons/proper/functor/branches/generators-FUNCTOR-14/src/test/java/org/apache/commons/functor/generator/TestWhileGenerate.java?rev=1374881&r1=1374880&r2=1374881&view=diff
==============================================================================
--- commons/proper/functor/branches/generators-FUNCTOR-14/src/test/java/org/apache/commons/functor/generator/TestWhileGenerate.java (original)
+++ commons/proper/functor/branches/generators-FUNCTOR-14/src/test/java/org/apache/commons/functor/generator/TestWhileGenerate.java Sun Aug 19 23:44:40 2012
@@ -25,7 +25,8 @@ import java.util.List;
 
 import org.apache.commons.functor.UnaryPredicate;
 import org.apache.commons.functor.UnaryProcedure;
-import org.apache.commons.functor.generator.util.IntegerGenerator;
+import org.apache.commons.functor.generator.loop.WhileGenerate;
+import org.apache.commons.functor.generator.range.IntegerRange;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
@@ -38,7 +39,7 @@ public class TestWhileGenerate {
 
     @Before
     public void setUp() throws Exception {
-        wrappedGenerator = new IntegerGenerator(1, 10);
+        wrappedGenerator = new IntegerRange(1, 10);
         whileGenerate = new WhileGenerate<Integer>(isLessThanFive, wrappedGenerator);
     }
 
@@ -69,7 +70,7 @@ public class TestWhileGenerate {
 
     @Test
     public void testEquals() {
-        Generator<Integer> anotherGenerate = new WhileGenerate<Integer>(isLessThanFive, new IntegerGenerator(1, 10));
+        Generator<Integer> anotherGenerate = new WhileGenerate<Integer>(isLessThanFive, new IntegerRange(1, 10));
         assertEquals(whileGenerate, whileGenerate);
         assertEquals(whileGenerate, anotherGenerate);
         assertTrue(!whileGenerate.equals((WhileGenerate<Integer>)null));
@@ -79,10 +80,10 @@ public class TestWhileGenerate {
 				public boolean test(Integer obj) {
 					return obj < FIVE;
 				}
-			}, new IntegerGenerator(1, 10));
+			}, new IntegerRange(1, 10));
         assertTrue(!whileGenerate.equals(aGenerateWithADifferentPredicate));
 
-        Generator<Integer> aGenerateWithADifferentWrapped = new WhileGenerate<Integer>(isLessThanFive, new IntegerGenerator(1,11));
+        Generator<Integer> aGenerateWithADifferentWrapped = new WhileGenerate<Integer>(isLessThanFive, new IntegerRange(1,11));
         assertTrue(!whileGenerate.equals(aGenerateWithADifferentWrapped));
     }
 

Modified: commons/proper/functor/branches/generators-FUNCTOR-14/src/test/java/org/apache/commons/functor/generator/util/TestEachElement.java
URL: http://svn.apache.org/viewvc/commons/proper/functor/branches/generators-FUNCTOR-14/src/test/java/org/apache/commons/functor/generator/util/TestEachElement.java?rev=1374881&r1=1374880&r2=1374881&view=diff
==============================================================================
--- commons/proper/functor/branches/generators-FUNCTOR-14/src/test/java/org/apache/commons/functor/generator/util/TestEachElement.java (original)
+++ commons/proper/functor/branches/generators-FUNCTOR-14/src/test/java/org/apache/commons/functor/generator/util/TestEachElement.java Sun Aug 19 23:44:40 2012
@@ -30,10 +30,10 @@ import java.util.Map;
 import org.apache.commons.functor.BaseFunctorTest;
 import org.apache.commons.functor.core.Limit;
 import org.apache.commons.functor.core.Offset;
-import org.apache.commons.functor.generator.GenerateUntil;
-import org.apache.commons.functor.generator.GenerateWhile;
-import org.apache.commons.functor.generator.UntilGenerate;
-import org.apache.commons.functor.generator.WhileGenerate;
+import org.apache.commons.functor.generator.loop.GenerateUntil;
+import org.apache.commons.functor.generator.loop.GenerateWhile;
+import org.apache.commons.functor.generator.loop.UntilGenerate;
+import org.apache.commons.functor.generator.loop.WhileGenerate;
 import org.junit.Before;
 import org.junit.Test;
 

Modified: commons/proper/functor/branches/generators-FUNCTOR-14/src/test/java/org/apache/commons/functor/generator/util/TestIntegerRange.java
URL: http://svn.apache.org/viewvc/commons/proper/functor/branches/generators-FUNCTOR-14/src/test/java/org/apache/commons/functor/generator/util/TestIntegerRange.java?rev=1374881&r1=1374880&r2=1374881&view=diff
==============================================================================
--- commons/proper/functor/branches/generators-FUNCTOR-14/src/test/java/org/apache/commons/functor/generator/util/TestIntegerRange.java (original)
+++ commons/proper/functor/branches/generators-FUNCTOR-14/src/test/java/org/apache/commons/functor/generator/util/TestIntegerRange.java Sun Aug 19 23:44:40 2012
@@ -23,6 +23,7 @@ import java.util.ArrayList;
 import java.util.List;
 
 import org.apache.commons.functor.BaseFunctorTest;
+import org.apache.commons.functor.generator.range.IntegerRange;
 import org.junit.Test;
 
 /**
@@ -32,7 +33,7 @@ public class TestIntegerRange extends Ba
 
     @Override
     protected Object makeFunctor() throws Exception {
-        return new IntegerGenerator(10, 20);
+        return new IntegerRange(10, 20);
     }
 
     // Tests
@@ -42,7 +43,7 @@ public class TestIntegerRange extends Ba
     public void testGenerateListExample() {
         // generates a collection of Integers from 0 (inclusive) to 10 (exclusive)
         {
-            List<? super Integer> list = (List<? super Integer>)(new IntegerGenerator(0,10).to(new ArrayList<Integer>()));
+            List<? super Integer> list = (List<? super Integer>)(new IntegerRange(0,10).to(new ArrayList<Integer>()));
             for (int i=0;i<10;i++) {
                 assertEquals(new Integer(i),list.get(i));
             }
@@ -50,7 +51,7 @@ public class TestIntegerRange extends Ba
 
         // generates a collection of Integers from 10 (inclusive) to 0 (exclusive)
         {
-            List<? super Integer> list = (List<? super Integer>)(new IntegerGenerator(10,0).to(new ArrayList<Integer>()));
+            List<? super Integer> list = (List<? super Integer>)(new IntegerRange(10,0).to(new ArrayList<Integer>()));
             for (int i=10;i>0;i--) {
                 assertEquals(new Integer(i),list.get(10-i));
             }
@@ -60,34 +61,34 @@ public class TestIntegerRange extends Ba
     @Test
     public void testStepChecking() {
         {
-            new IntegerGenerator(2, 2, 0); // step of 0 is ok when range is empty
+            new IntegerRange(2, 2, 0); // step of 0 is ok when range is empty
         }
         {
-            new IntegerGenerator(2, 2, 1); // positive step is ok when range is empty
+            new IntegerRange(2, 2, 1); // positive step is ok when range is empty
         }
         {
-            new IntegerGenerator(2, 2, -1); // negative step is ok when range is empty
+            new IntegerRange(2, 2, -1); // negative step is ok when range is empty
         }
         {
-            new IntegerGenerator(0, 1, 10); // big steps are ok
+            new IntegerRange(0, 1, 10); // big steps are ok
         }
         {
-            new IntegerGenerator(1, 0, -10); // big steps are ok
+            new IntegerRange(1, 0, -10); // big steps are ok
         }
         try {
-            new IntegerGenerator(0, 1, 0);
+            new IntegerRange(0, 1, 0);
             fail("Expected IllegalArgumentException");
         } catch(IllegalArgumentException e) {
             // expected
         }
         try {
-            new IntegerGenerator(0, 1, -1);
+            new IntegerRange(0, 1, -1);
             fail("Expected IllegalArgumentException");
         } catch(IllegalArgumentException e) {
             // expected
         }
         try {
-            new IntegerGenerator(0, -1, 1);
+            new IntegerRange(0, -1, 1);
             fail("Expected IllegalArgumentException");
         } catch(IllegalArgumentException e) {
             // expected
@@ -96,59 +97,59 @@ public class TestIntegerRange extends Ba
 
     @Test
     public void testObjectConstructor() {
-        IntegerGenerator range = new IntegerGenerator(new Integer(0), new Integer(5));
+        IntegerRange range = new IntegerRange(new Integer(0), new Integer(5));
         assertEquals("[0, 1, 2, 3, 4]", range.toCollection().toString());
-        range = new IntegerGenerator(new Integer(0), new Integer(5), new Integer(1));
+        range = new IntegerRange(new Integer(0), new Integer(5), new Integer(1));
         assertEquals("[0, 1, 2, 3, 4]", range.toCollection().toString());
     }
 
 
     @Test
     public void testReverseStep() {
-        IntegerGenerator range = new IntegerGenerator(10, 0, -2);
+        IntegerRange range = new IntegerRange(10, 0, -2);
         assertEquals("[10, 8, 6, 4, 2]", range.toCollection().toString());
         assertEquals("[10, 8, 6, 4, 2]", range.toCollection().toString());
     }
 
     @Test
     public void testStep() {
-        IntegerGenerator range = new IntegerGenerator(0, 10, 2);
+        IntegerRange range = new IntegerRange(0, 10, 2);
         assertEquals("[0, 2, 4, 6, 8]", range.toCollection().toString());
         assertEquals("[0, 2, 4, 6, 8]", range.toCollection().toString());
     }
 
     @Test
     public void testForwardRange() {
-        IntegerGenerator range = new IntegerGenerator(0, 5);
+        IntegerRange range = new IntegerRange(0, 5);
         assertEquals("[0, 1, 2, 3, 4]", range.toCollection().toString());
         assertEquals("[0, 1, 2, 3, 4]", range.toCollection().toString());
     }
 
     @Test
     public void testReverseRange() {
-        IntegerGenerator range = new IntegerGenerator(5, 0);
+        IntegerRange range = new IntegerRange(5, 0);
         assertEquals("[5, 4, 3, 2, 1]", range.toCollection().toString());
         assertEquals("[5, 4, 3, 2, 1]", range.toCollection().toString());
     }
 
     @Test
     public void testEdgeCase() {
-        IntegerGenerator range = new IntegerGenerator(Integer.MAX_VALUE - 3, Integer.MAX_VALUE);
+        IntegerRange range = new IntegerRange(Integer.MAX_VALUE - 3, Integer.MAX_VALUE);
         assertEquals("[2147483644, 2147483645, 2147483646]", range.toCollection().toString());
         assertEquals("[2147483644, 2147483645, 2147483646]", range.toCollection().toString());
     }
 
     @Test
     public void testEquals() {
-        IntegerGenerator range = new IntegerGenerator(1, 5);
+        IntegerRange range = new IntegerRange(1, 5);
         assertObjectsAreEqual(range, range);
-        assertObjectsAreEqual(range, new IntegerGenerator(1, 5));
-        assertObjectsAreEqual(range, new IntegerGenerator(1, 5, 1));
-        assertObjectsAreEqual(range, new IntegerGenerator(new Long(1), new Long(5)));
-        assertObjectsAreEqual(range, new IntegerGenerator(new Long(1), new Long(5), new Long(1)));
-        assertObjectsAreNotEqual(range, new IntegerGenerator(2, 5));
-        assertObjectsAreNotEqual(range, new IntegerGenerator(1, 6));
-        assertObjectsAreNotEqual(range, new IntegerGenerator(1, 5, 2));
+        assertObjectsAreEqual(range, new IntegerRange(1, 5));
+        assertObjectsAreEqual(range, new IntegerRange(1, 5, 1));
+        assertObjectsAreEqual(range, new IntegerRange(new Long(1), new Long(5)));
+        assertObjectsAreEqual(range, new IntegerRange(new Long(1), new Long(5), new Long(1)));
+        assertObjectsAreNotEqual(range, new IntegerRange(2, 5));
+        assertObjectsAreNotEqual(range, new IntegerRange(1, 6));
+        assertObjectsAreNotEqual(range, new IntegerRange(1, 5, 2));
     }
 
 }
\ No newline at end of file

Modified: commons/proper/functor/branches/generators-FUNCTOR-14/src/test/java/org/apache/commons/functor/generator/util/TestLongRange.java
URL: http://svn.apache.org/viewvc/commons/proper/functor/branches/generators-FUNCTOR-14/src/test/java/org/apache/commons/functor/generator/util/TestLongRange.java?rev=1374881&r1=1374880&r2=1374881&view=diff
==============================================================================
--- commons/proper/functor/branches/generators-FUNCTOR-14/src/test/java/org/apache/commons/functor/generator/util/TestLongRange.java (original)
+++ commons/proper/functor/branches/generators-FUNCTOR-14/src/test/java/org/apache/commons/functor/generator/util/TestLongRange.java Sun Aug 19 23:44:40 2012
@@ -23,6 +23,7 @@ import java.util.ArrayList;
 import java.util.List;
 
 import org.apache.commons.functor.BaseFunctorTest;
+import org.apache.commons.functor.generator.range.LongRange;
 import org.junit.Test;
 
 /**
@@ -32,7 +33,7 @@ public class TestLongRange extends BaseF
 
     @Override
     protected Object makeFunctor() throws Exception {
-        return new LongGenerator(10, 20);
+        return new LongRange(10, 20);
     }
 
     // Tests
@@ -42,7 +43,7 @@ public class TestLongRange extends BaseF
     public void testGenerateListExample() {
         // generates a collection of Integers from 0 (inclusive) to 10 (exclusive)
         {
-            List<? super Long> list = (List<? super Long>)(new LongGenerator(0,10).to(new ArrayList<Long>()));
+            List<? super Long> list = (List<? super Long>)(new LongRange(0,10).to(new ArrayList<Long>()));
             for (int i=0;i<10;i++) {
                 assertEquals(new Long(i),list.get(i));
             }
@@ -50,7 +51,7 @@ public class TestLongRange extends BaseF
 
         // generates a collection of Integers from 10 (inclusive) to 0 (exclusive)
         {
-            List<? super Long> list = (List<? super Long>)(new LongGenerator(10,0).to(new ArrayList<Long>()));
+            List<? super Long> list = (List<? super Long>)(new LongRange(10,0).to(new ArrayList<Long>()));
             for (int i=10;i>0;i--) {
                 assertEquals(new Long(i),list.get(10-i));
             }
@@ -60,34 +61,34 @@ public class TestLongRange extends BaseF
     @Test
     public void testStepChecking() {
         {
-            new LongGenerator(2, 2, 0); // step of 0 is ok when range is empty
+            new LongRange(2, 2, 0); // step of 0 is ok when range is empty
         }
         {
-            new LongGenerator(2, 2, 1); // positive step is ok when range is empty
+            new LongRange(2, 2, 1); // positive step is ok when range is empty
         }
         {
-            new LongGenerator(2, 2, -1); // negative step is ok when range is empty
+            new LongRange(2, 2, -1); // negative step is ok when range is empty
         }
         {
-            new LongGenerator(0, 1, 10); // big steps are ok
+            new LongRange(0, 1, 10); // big steps are ok
         }
         {
-            new LongGenerator(1, 0, -10); // big steps are ok
+            new LongRange(1, 0, -10); // big steps are ok
         }
         try {
-            new LongGenerator(0, 1, 0);
+            new LongRange(0, 1, 0);
             fail("Expected IllegalArgumentException");
         } catch(IllegalArgumentException e) {
             // expected
         }
         try {
-            new LongGenerator(0, 1, -1);
+            new LongRange(0, 1, -1);
             fail("Expected IllegalArgumentException");
         } catch(IllegalArgumentException e) {
             // expected
         }
         try {
-            new LongGenerator(0, -1, 1);
+            new LongRange(0, -1, 1);
             fail("Expected IllegalArgumentException");
         } catch(IllegalArgumentException e) {
             // expected
@@ -96,59 +97,59 @@ public class TestLongRange extends BaseF
 
     @Test
     public void testObjectConstructor() {
-        LongGenerator range = new LongGenerator(new Long(0), new Long(5));
+        LongRange range = new LongRange(new Long(0), new Long(5));
         assertEquals("[0, 1, 2, 3, 4]", range.toCollection().toString());
-        range = new LongGenerator(new Integer(0), new Long(5), new Long(1));
+        range = new LongRange(new Integer(0), new Long(5), new Long(1));
         assertEquals("[0, 1, 2, 3, 4]", range.toCollection().toString());
     }
 
 
     @Test
     public void testReverseStep() {
-        LongGenerator range = new LongGenerator(10, 0, -2);
+        LongRange range = new LongRange(10, 0, -2);
         assertEquals("[10, 8, 6, 4, 2]", range.toCollection().toString());
         assertEquals("[10, 8, 6, 4, 2]", range.toCollection().toString());
     }
 
     @Test
     public void testStep() {
-        LongGenerator range = new LongGenerator(0, 10, 2);
+        LongRange range = new LongRange(0, 10, 2);
         assertEquals("[0, 2, 4, 6, 8]", range.toCollection().toString());
         assertEquals("[0, 2, 4, 6, 8]", range.toCollection().toString());
     }
 
     @Test
     public void testForwardRange() {
-        LongGenerator range = new LongGenerator(0, 5);
+        LongRange range = new LongRange(0, 5);
         assertEquals("[0, 1, 2, 3, 4]", range.toCollection().toString());
         assertEquals("[0, 1, 2, 3, 4]", range.toCollection().toString());
     }
 
     @Test
     public void testReverseRange() {
-        LongGenerator range = new LongGenerator(5, 0);
+        LongRange range = new LongRange(5, 0);
         assertEquals("[5, 4, 3, 2, 1]", range.toCollection().toString());
         assertEquals("[5, 4, 3, 2, 1]", range.toCollection().toString());
     }
 
     @Test
     public void testEdgeCase() {
-        LongGenerator range = new LongGenerator(Long.MAX_VALUE - 3L, Long.MAX_VALUE);
+        LongRange range = new LongRange(Long.MAX_VALUE - 3L, Long.MAX_VALUE);
         assertEquals("[9223372036854775804, 9223372036854775805, 9223372036854775806]", range.toCollection().toString());
         assertEquals("[9223372036854775804, 9223372036854775805, 9223372036854775806]", range.toCollection().toString());
     }
 
     @Test
     public void testEquals() {
-        LongGenerator range = new LongGenerator(1, 5);
+        LongRange range = new LongRange(1, 5);
         assertObjectsAreEqual(range, range);
-        assertObjectsAreEqual(range, new LongGenerator(1, 5));
-        assertObjectsAreEqual(range, new LongGenerator(1, 5, 1));
-        assertObjectsAreEqual(range, new LongGenerator(new Integer(1), new Long(5)));
-        assertObjectsAreEqual(range, new LongGenerator(new Long(1), new Short((short)5), new Long(1)));
-        assertObjectsAreNotEqual(range, new LongGenerator(2, 5));
-        assertObjectsAreNotEqual(range, new LongGenerator(1, 6));
-        assertObjectsAreNotEqual(range, new LongGenerator(1, 5, 2));
+        assertObjectsAreEqual(range, new LongRange(1, 5));
+        assertObjectsAreEqual(range, new LongRange(1, 5, 1));
+        assertObjectsAreEqual(range, new LongRange(new Integer(1), new Long(5)));
+        assertObjectsAreEqual(range, new LongRange(new Long(1), new Short((short)5), new Long(1)));
+        assertObjectsAreNotEqual(range, new LongRange(2, 5));
+        assertObjectsAreNotEqual(range, new LongRange(1, 6));
+        assertObjectsAreNotEqual(range, new LongRange(1, 5, 2));
     }
 
 }
\ No newline at end of file



Mime
View raw message