You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by "Bruno P. Kinoshita" <br...@yahoo.com.br> on 2013/01/29 02:23:57 UTC

Re: svn commit: r1439683 - in /commons/proper/functor/branches/FUNCTOR-14-mm/core/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/org/a...

Thanks Matt! The name is more intuitive now. What about the package name? Should we rename it as well? 

Cheers, 
 
Bruno P. Kinoshita
http://kinoshita.eti.br
http://tupilabs.com


----- Original Message -----
> From: "mbenson@apache.org" <mb...@apache.org>
> To: commits@commons.apache.org
> Cc: 
> Sent: Monday, January 28, 2013 8:49 PM
> Subject: svn commit: r1439683 - in /commons/proper/functor/branches/FUNCTOR-14-mm/core/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/org/a...
> 
> Author: mbenson
> Date: Mon Jan 28 22:49:36 2013
> New Revision: 1439683
> 
> URL: http://svn.apache.org/viewvc?rev=1439683&view=rev
> Log:
> refactor LoopGenerator to PredicatedGenerator
> 
> Added:
>     
> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/loop/PredicatedGenerator.java
>       - copied, changed from r1439123, 
> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/loop/LoopGenerator.java
> Removed:
>     
> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/loop/LoopGenerator.java
>     
> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/test/java/org/apache/commons/functor/generator/loop/TestLoopGenerator.java
> Modified:
>     
> 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/loop/GenerateUntil.java
>     
> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/loop/GenerateWhile.java
>     
> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/loop/IteratorToGeneratorAdapter.java
>     
> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/loop/TransformedGenerator.java
>     
> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/loop/UntilGenerate.java
>     
> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/loop/WhileGenerate.java
>     
> commons/proper/functor/branches/FUNCTOR-14-mm/core/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/NumericRange.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/example/lines/Lines.java
>     
> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/test/java/org/apache/commons/functor/generator/loop/TestGenerateUntil.java
>     
> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/test/java/org/apache/commons/functor/generator/loop/TestGenerateWhile.java
>     
> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/test/java/org/apache/commons/functor/generator/loop/TestTransformedGenerator.java
>     
> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/test/java/org/apache/commons/functor/generator/loop/TestUntilGenerate.java
>     
> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/test/java/org/apache/commons/functor/generator/loop/TestWhileGenerate.java
> 
> 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=1439683&r1=1439682&r2=1439683&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 
> Mon Jan 28 22:49:36 2013
> @@ -21,17 +21,19 @@ 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.loop.LoopGenerator;
> +import org.apache.commons.functor.generator.Generator;
> +import org.apache.commons.functor.generator.loop.PredicatedGenerator;
> +import org.apache.commons.functor.generator.loop.UntilGenerate;
> 
> /**
> - * Return the index of the first Object in a {@link LoopGenerator} matching a
> + * Return the index of the first Object in a {@link PredicatedGenerator} 
> 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<LoopGenerator<? extends T>, 
> UnaryPredicate<? super T>, Number>, Serializable {
> +    implements BinaryFunction<Generator<? extends T>, 
> UnaryPredicate<? super T>, Number>, Serializable {
>      /**
>       * serialVersionUID declaration.
>       */
> @@ -48,42 +50,14 @@ public final class IndexOfInGenerator<T>
>       */
>      private static class IndexProcedure<T> implements 
> UnaryProcedure<T> {
>          /**
> -         * The wrapped generator.
> -         */
> -        private final LoopGenerator<? extends T> generator;
> -        /**
> -         * The wrapped predicate.
> -         */
> -        private final UnaryPredicate<? super T> pred;
> -        /**
> -         * The number of iterations needed before the wrapped predicate found 
> the target,
> -         * {@code -1} means the target was not found.
> -         */
> -        private long index = -1L;
> -        /**
>           * A local accumulator to increment the number of attempts.
>           */
>          private long current = 0L;
> 
>          /**
> -         * Create a new IndexProcedure.
> -         *
> -         * @param generator The wrapped generator
> -         * @param pred The wrapped predicate
> -         */
> -        IndexProcedure(LoopGenerator<? extends T> generator, 
> UnaryPredicate<? super T> pred) {
> -            this.generator = generator;
> -            this.pred = pred;
> -        }
> -
> -        /**
>           * {@inheritDoc}
>           */
>          public void run(T obj) {
> -            if (index < 0 && pred.test(obj)) {
> -                index = current;
> -                generator.stop();
> -            }
>              current++;
>          }
>      }
> @@ -93,10 +67,10 @@ public final class IndexOfInGenerator<T>
>       * @param left Generator
>       * @param right UnaryPredicate
>       */
> -    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);
> +    public Number evaluate(Generator<? extends T> left, 
> UnaryPredicate<? super T> right) {
> +        final IndexProcedure<T> findProcedure = new 
> IndexProcedure<T>();
> +        new UntilGenerate<T>(right, left).run(findProcedure);
> +        return Long.valueOf(findProcedure.current);
>      }
> 
>      /**
> 
> 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=1439683&r1=1439682&r2=1439683&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 
> Mon Jan 28 22:49:36 2013
> @@ -29,8 +29,10 @@ import org.apache.commons.functor.genera
>   */
> public abstract class BaseGenerator<E> implements Generator<E> {
> 
> -    /** Create a new generator. */
> -    public BaseGenerator() {
> +    /**
> +     * Create a new BaseGenerator instance.
> +     */
> +    protected BaseGenerator() {
>          super();
>      }
> 
> 
> Modified: 
> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/loop/GenerateUntil.java
> URL: 
> http://svn.apache.org/viewvc/commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/loop/GenerateUntil.java?rev=1439683&r1=1439682&r2=1439683&view=diff
> ==============================================================================
> --- 
> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/loop/GenerateUntil.java 
> (original)
> +++ 
> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/loop/GenerateUntil.java 
> Mon Jan 28 22:49:36 2013
> @@ -18,6 +18,7 @@ package org.apache.commons.functor.gener
> 
> import org.apache.commons.functor.UnaryPredicate;
> import org.apache.commons.functor.UnaryProcedure;
> +import org.apache.commons.functor.core.composite.UnaryNot;
> import org.apache.commons.functor.generator.Generator;
> import org.apache.commons.lang3.Validate;
> 
> @@ -28,12 +29,7 @@ import org.apache.commons.lang3.Validate
>   * @param <E> the type of elements held in this generator.
>   * @version $Revision$ $Date$
>   */
> -public class GenerateUntil<E> extends LoopGenerator<E> {
> -
> -    /**
> -     * The condition has to verified in order to execute the generation.
> -     */
> -    private final UnaryPredicate<? super E> test;
> +public class GenerateUntil<E> extends PredicatedGenerator<E> {
> 
>      /**
>       * Create a new GenerateUntil.
> @@ -41,53 +37,8 @@ public class GenerateUntil<E> extends Lo
>       * @param test {@link UnaryPredicate}
>       */
>      public GenerateUntil(Generator<? extends E> wrapped, 
> UnaryPredicate<? super E> test) {
> -        super(Validate.notNull(wrapped, "Generator argument was 
> null"));
> -        this.test = Validate.notNull(test, "UnaryPredicate argument was 
> null");
> -    }
> -
> -    /**
> -     * {@inheritDoc}
> -     */
> -    public void run(final UnaryProcedure<? super E> proc) {
> -        getWrappedGenerator().run(new UnaryProcedure<E>() {
> -            public void run(E obj) {
> -                if (isStopped()) {
> -                    return;
> -                }
> -                proc.run(obj);
> -                if (test.test(obj)) {
> -                    stop();
> -                }
> -            }
> -        });
> +        super(Validate.notNull(wrapped, "Generator argument was 
> null"), UnaryNot.not(Validate.notNull(test,
> +            "UnaryPredicate argument was null")), 
> Behavior.TEST_AFTER);
>      }
> 
> -    /**
> -     * {@inheritDoc}
> -     */
> -    @Override
> -    public boolean equals(Object obj) {
> -        if (obj == this) {
> -            return true;
> -        }
> -        if (!(obj instanceof GenerateUntil<?>)) {
> -            return false;
> -        }
> -        GenerateUntil<?> other = (GenerateUntil<?>) obj;
> -        return other.getWrappedGenerator().equals(getWrappedGenerator()) 
> && other.test.equals(test);
> -    }
> -
> -    /**
> -     * {@inheritDoc}
> -     */
> -    @Override
> -    public int hashCode() {
> -        int result = "GenerateUntil".hashCode();
> -        result <<= 2;
> -        Generator<?> gen = getWrappedGenerator();
> -        result ^= gen.hashCode();
> -        result <<= 2;
> -        result ^= test.hashCode();
> -        return result;
> -    }
> }
> 
> Modified: 
> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/loop/GenerateWhile.java
> URL: 
> http://svn.apache.org/viewvc/commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/loop/GenerateWhile.java?rev=1439683&r1=1439682&r2=1439683&view=diff
> ==============================================================================
> --- 
> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/loop/GenerateWhile.java 
> (original)
> +++ 
> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/loop/GenerateWhile.java 
> Mon Jan 28 22:49:36 2013
> @@ -28,12 +28,7 @@ import org.apache.commons.lang3.Validate
>   * @param <E> the type of elements held in this generator.
>   * @version $Revision$ $Date$
>   */
> -public class GenerateWhile<E> extends LoopGenerator<E> {
> -
> -    /**
> -     * The condition has to verified in order to execute the generation.
> -     */
> -    private final UnaryPredicate<? super E> test;
> +public class GenerateWhile<E> extends PredicatedGenerator<E> {
> 
>      /**
>       * Create a new GenerateWhile.
> @@ -41,53 +36,8 @@ public class GenerateWhile<E> extends Lo
>       * @param test {@link UnaryPredicate}
>       */
>      public GenerateWhile(Generator<? extends E> wrapped, 
> UnaryPredicate<? super E> test) {
> -        super(Validate.notNull(wrapped, "Generator argument was 
> null"));
> -        this.test = Validate.notNull(test, "UnaryPredicate argument was 
> null");
> -    }
> -
> -    /**
> -     * {@inheritDoc}
> -     */
> -    public void run(final UnaryProcedure<? super E> proc) {
> -        getWrappedGenerator().run(new UnaryProcedure<E>() {
> -            public void run(E obj) {
> -                if (isStopped()) {
> -                    return;
> -                }
> -                proc.run(obj);
> -                if (!test.test(obj)) {
> -                    stop();
> -                }
> -            }
> -        });
> +        super(Validate.notNull(wrapped, "Generator argument was 
> null"),
> +        Validate.notNull(test, "UnaryPredicate argument was null"), 
> Behavior.TEST_AFTER);
>      }
> 
> -    /**
> -     * {@inheritDoc}
> -     */
> -    @Override
> -    public boolean equals(Object obj) {
> -        if (obj == this) {
> -            return true;
> -        }
> -        if (!(obj instanceof GenerateWhile<?>)) {
> -            return false;
> -        }
> -        GenerateWhile<?> other = (GenerateWhile<?>) obj;
> -        return other.getWrappedGenerator().equals(getWrappedGenerator()) 
> && other.test.equals(test);
> -    }
> -
> -    /**
> -     * {@inheritDoc}
> -     */
> -    @Override
> -    public int hashCode() {
> -        int result = "GenerateWhile".hashCode();
> -        result <<= 2;
> -        Generator<?> gen = getWrappedGenerator();
> -        result ^= gen.hashCode();
> -        result <<= 2;
> -        result ^= test.hashCode();
> -        return result;
> -    }
> }
> 
> Modified: 
> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/loop/IteratorToGeneratorAdapter.java
> URL: 
> http://svn.apache.org/viewvc/commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/loop/IteratorToGeneratorAdapter.java?rev=1439683&r1=1439682&r2=1439683&view=diff
> ==============================================================================
> --- 
> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/loop/IteratorToGeneratorAdapter.java 
> (original)
> +++ 
> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/loop/IteratorToGeneratorAdapter.java 
> Mon Jan 28 22:49:36 2013
> @@ -14,19 +14,23 @@
> 
> package org.apache.commons.functor.generator.loop;
> 
> +import java.util.Collection;
> import java.util.Iterator;
> 
> +import org.apache.commons.functor.UnaryFunction;
> import org.apache.commons.functor.UnaryProcedure;
> +import org.apache.commons.functor.generator.BaseGenerator;
> +import org.apache.commons.functor.generator.Generator;
> import org.apache.commons.lang3.Validate;
> 
> /**
> - * Adapts an {@link Iterator} to the {@link LoopGenerator} interface.
> + * Adapts an {@link Iterator} to the {@link PredicatedGenerator} interface.
>   *
>   * @param <E> the type of elements held in this generator.
>   * @since 1.0
>   * @version $Revision$ $Date$
>   */
> -public final class IteratorToGeneratorAdapter<E> extends 
> LoopGenerator<E> {
> +public final class IteratorToGeneratorAdapter<E> extends 
> BaseGenerator<E> {
>      // instance variables
>      //-----------------------------------------------------
> 
> @@ -53,9 +57,6 @@ public final class IteratorToGeneratorAd
>      public void run(UnaryProcedure<? super E> proc) {
>          while (iter.hasNext()) {
>              proc.run(iter.next());
> -            if (isStopped()) {
> -                break;
> -            }
>          }
>      }
> 
> 
> Copied: 
> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/loop/PredicatedGenerator.java 
> (from r1439123, 
> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/loop/LoopGenerator.java)
> URL: 
> http://svn.apache.org/viewvc/commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/loop/PredicatedGenerator.java?p2=commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/loop/PredicatedGenerator.java&p1=commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/loop/LoopGenerator.java&r1=1439123&r2=1439683&rev=1439683&view=diff
> ==============================================================================
> --- 
> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/loop/LoopGenerator.java 
> (original)
> +++ 
> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/loop/PredicatedGenerator.java 
> Mon Jan 28 22:49:36 2013
> @@ -14,6 +14,8 @@
> 
> package org.apache.commons.functor.generator.loop;
> 
> +import org.apache.commons.functor.UnaryPredicate;
> +import org.apache.commons.functor.UnaryProcedure;
> import org.apache.commons.functor.generator.BaseGenerator;
> import org.apache.commons.functor.generator.Generator;
> 
> @@ -25,27 +27,29 @@ import org.apache.commons.functor.genera
>   * @since 1.0
>   * @version $Revision:$ $Date:$
>   */
> -public abstract class LoopGenerator<E> extends BaseGenerator<E> {
> +public abstract class PredicatedGenerator<E> extends 
> BaseGenerator<E> {
> +    public enum Behavior {
> +        TEST_BEFORE, TEST_AFTER;
> +    }
> 
> -    /** A generator can wrap another generator. */
>      private final Generator<? extends E> wrappedGenerator;
> +    private final UnaryPredicate<? super E> continuePredicate;
> +    private final Behavior behavior;
> 
> -    /** Set to true when the generator is {@link #stop stopped}. */
> +    /** 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
> +     * Create a new PredicatedGenerator instance.
> +     * @param wrappedGenerator
> +     * @param continuePredicate
> +     * @param behavior
>       */
> -    public LoopGenerator(Generator<? extends E> generator) {
> -        this.wrappedGenerator = generator;
> +    protected PredicatedGenerator(Generator<? extends E> 
> wrappedGenerator, UnaryPredicate<? super E> continuePredicate, Behavior 
> behavior) {
> +        super();
> +        this.wrappedGenerator = wrappedGenerator;
> +        this.continuePredicate = continuePredicate;
> +        this.behavior = behavior;
>      }
> 
>      /**
> @@ -58,21 +62,58 @@ public abstract class LoopGenerator<E> e
> 
>      /**
>       * {@inheritDoc}
> -     * Stop the generator. Will stop the wrapped generator if one was set.
>       */
> -    public void stop() {
> -        if (wrappedGenerator != null && wrappedGenerator instanceof 
> LoopGenerator<?>) {
> -            ((LoopGenerator<?>) wrappedGenerator).stop();
> +    public void run(final UnaryProcedure<? super E> proc) {
> +        wrappedGenerator.run(new UnaryProcedure<E>() {
> +            public void run(E obj) {
> +                if (stopped) {
> +                    return;
> +                }
> +                if (behavior == Behavior.TEST_BEFORE && 
> !continuePredicate.test(obj)) {
> +                    stop();
> +                    return;
> +                }
> +                proc.run(obj);
> +                if (behavior == Behavior.TEST_AFTER && 
> !continuePredicate.test(obj)) {
> +                    stop();
> +                }
> +            }
> +        });
> +    }
> +    /**
> +     * {@inheritDoc}
> +     */
> +    @Override
> +    public boolean equals(Object obj) {
> +        if (obj == this) {
> +            return true;
>          }
> -        stopped = true;
> +        if (!(obj instanceof PredicatedGenerator<?>)) {
> +            return false;
> +        }
> +        PredicatedGenerator<?> other = (PredicatedGenerator<?>) 
> obj;
> +        return other.getWrappedGenerator().equals(getWrappedGenerator())
> +            && other.continuePredicate.equals(continuePredicate) 
> && other.behavior == behavior;
>      }
> 
>      /**
>       * {@inheritDoc}
> -     * Check if the generator is stopped.
>       */
> -    public boolean isStopped() {
> -        return stopped;
> +    @Override
> +    public int hashCode() {
> +        int result = getClass().getSimpleName().hashCode();
> +        result <<= 2;
> +        Generator<?> gen = getWrappedGenerator();
> +        result ^= gen.hashCode();
> +        result <<= 2;
> +        result ^= continuePredicate.hashCode();
> +        result <<= 2;
> +        result ^= behavior.ordinal();
> +        return result;
> +    }
> +
> +    private void stop() {
> +        stopped = true;
>      }
> 
> }
> 
> Modified: 
> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/loop/TransformedGenerator.java
> URL: 
> http://svn.apache.org/viewvc/commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/loop/TransformedGenerator.java?rev=1439683&r1=1439682&r2=1439683&view=diff
> ==============================================================================
> --- 
> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/loop/TransformedGenerator.java 
> (original)
> +++ 
> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/loop/TransformedGenerator.java 
> Mon Jan 28 22:49:36 2013
> @@ -18,6 +18,7 @@ package org.apache.commons.functor.gener
> 
> import org.apache.commons.functor.UnaryFunction;
> import org.apache.commons.functor.UnaryProcedure;
> +import org.apache.commons.functor.generator.BaseGenerator;
> import org.apache.commons.functor.generator.Generator;
> import org.apache.commons.lang3.Validate;
> 
> @@ -28,34 +29,34 @@ import org.apache.commons.lang3.Validate
>   * @param <E> the type of elements held in this generator.
>   * @version $Revision$ $Date$
>   */
> -public class TransformedGenerator<I, E> extends LoopGenerator<E> {
> +public class TransformedGenerator<I, E> extends BaseGenerator<E> {
> +
> +    /**
> +     * The wrapped/<em>I</em>nput generator.
> +     */
> +    private final Generator<? extends I> wrappedGenerator;
> 
>      /**
>       * The UnaryFunction to apply to each element.
>       */
>      private final UnaryFunction<? super I, ? extends E> func;
> 
> -    // 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.
>      /**
>       * Create a new TransformedGenerator.
>       * @param wrapped Generator to transform
>       * @param func UnaryFunction to apply to each element
>       */
> -    @SuppressWarnings("unchecked")
>      public TransformedGenerator(Generator<? extends I> wrapped, 
> UnaryFunction<? super I, ? extends E> func) {
> -        super((Generator<? extends E>) Validate.notNull(wrapped, 
> "Generator argument was null"));
> +        this.wrappedGenerator =
> +        Validate.notNull(wrapped, "Generator argument was null");
>          this.func = Validate.notNull(func, "UnaryFunction argument was 
> null");
>      }
> 
>      /**
>       * {@inheritDoc}
>       */
> -    @SuppressWarnings("unchecked")
>      public void run(final UnaryProcedure<? super E> proc) {
> -        ((Generator<? extends I>) getWrappedGenerator()).run(new 
> UnaryProcedure<I>() {
> +        wrappedGenerator.run(new UnaryProcedure<I>() {
>              public void run(I obj) {
>                  proc.run(func.evaluate(obj));
>              }
> @@ -74,7 +75,7 @@ public class TransformedGenerator<I, E> 
>              return false;
>          }
>          TransformedGenerator<?, ?> other = (TransformedGenerator<?, 
> ?>) obj;
> -        return other.getWrappedGenerator().equals(getWrappedGenerator()) 
> && other.func == func;
> +        return other.wrappedGenerator.equals(wrappedGenerator) && 
> other.func.equals(func);
>      }
> 
>      /**
> @@ -84,7 +85,7 @@ public class TransformedGenerator<I, E> 
>      public int hashCode() {
>          int result = "TransformedGenerator".hashCode();
>          result <<= 2;
> -        Generator<?> gen = getWrappedGenerator();
> +        Generator<?> gen = wrappedGenerator;
>          result ^= gen.hashCode();
>          result <<= 2;
>          result ^= func.hashCode();
> 
> Modified: 
> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/loop/UntilGenerate.java
> URL: 
> http://svn.apache.org/viewvc/commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/loop/UntilGenerate.java?rev=1439683&r1=1439682&r2=1439683&view=diff
> ==============================================================================
> --- 
> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/loop/UntilGenerate.java 
> (original)
> +++ 
> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/loop/UntilGenerate.java 
> Mon Jan 28 22:49:36 2013
> @@ -18,6 +18,7 @@ package org.apache.commons.functor.gener
> 
> import org.apache.commons.functor.UnaryPredicate;
> import org.apache.commons.functor.UnaryProcedure;
> +import org.apache.commons.functor.core.composite.UnaryNot;
> import org.apache.commons.functor.generator.Generator;
> import org.apache.commons.lang3.Validate;
> 
> @@ -28,12 +29,7 @@ import org.apache.commons.lang3.Validate
>   * @param <E> the type of elements held in this generator.
>   * @version $Revision$ $Date$
>   */
> -public class UntilGenerate<E> extends LoopGenerator<E> {
> -
> -    /**
> -     * The condition has to verified in order to execute the generation.
> -     */
> -    private final UnaryPredicate<? super E> test;
> +public class UntilGenerate<E> extends PredicatedGenerator<E> {
> 
>      /**
>       * Create a new UntilGenerate.
> @@ -41,54 +37,8 @@ public class UntilGenerate<E> extends Lo
>       * @param test {@link UnaryPredicate}
>       */
>      public UntilGenerate(UnaryPredicate<? super E> test, Generator<? 
> extends E> wrapped) {
> -        super(Validate.notNull(wrapped, "Generator argument was 
> null"));
> -        this.test = Validate.notNull(test, "UnaryPredicate argument was 
> null");
> -    }
> -
> -    /**
> -     * {@inheritDoc}
> -     */
> -    public void run(final UnaryProcedure<? super E> proc) {
> -        getWrappedGenerator().run(new UnaryProcedure<E>() {
> -            public void run(E obj) {
> -                if (isStopped()) {
> -                    return;
> -                }
> -                if (test.test(obj)) {
> -                    stop();
> -                } else {
> -                    proc.run(obj);
> -                }
> -            }
> -        });
> +        super(Validate.notNull(wrapped, "Generator argument was 
> null"), UnaryNot.not(Validate.notNull(test,
> +            "UnaryPredicate argument was null")), 
> Behavior.TEST_BEFORE);
>      }
> 
> -    /**
> -     * {@inheritDoc}
> -     */
> -    @Override
> -    public boolean equals(Object obj) {
> -        if (obj == this) {
> -            return true;
> -        }
> -        if (!(obj instanceof UntilGenerate<?>)) {
> -            return false;
> -        }
> -        UntilGenerate<?> other = (UntilGenerate<?>) obj;
> -        return other.getWrappedGenerator().equals(getWrappedGenerator()) 
> && other.test.equals(test);
> -    }
> -
> -    /**
> -     * {@inheritDoc}
> -     */
> -    @Override
> -    public int hashCode() {
> -        int result = "UntilGenerate".hashCode();
> -        result <<= 2;
> -        Generator<?> gen = getWrappedGenerator();
> -        result ^= gen.hashCode();
> -        result <<= 2;
> -        result ^= test.hashCode();
> -        return result;
> -    }
> }
> 
> Modified: 
> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/loop/WhileGenerate.java
> URL: 
> http://svn.apache.org/viewvc/commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/loop/WhileGenerate.java?rev=1439683&r1=1439682&r2=1439683&view=diff
> ==============================================================================
> --- 
> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/loop/WhileGenerate.java 
> (original)
> +++ 
> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/loop/WhileGenerate.java 
> Mon Jan 28 22:49:36 2013
> @@ -28,12 +28,7 @@ import org.apache.commons.lang3.Validate
>   * @param <E> the type of elements held in this generator.
>   * @version $Revision$ $Date$
>   */
> -public class WhileGenerate<E> extends LoopGenerator<E> {
> -
> -    /**
> -     * The condition has to verified in order to execute the generation.
> -     */
> -    private final UnaryPredicate<? super E> test;
> +public class WhileGenerate<E> extends PredicatedGenerator<E> {
> 
>      /**
>       * Create a new WhileGenerate.
> @@ -41,54 +36,8 @@ public class WhileGenerate<E> extends Lo
>       * @param wrapped {@link Generator}
>       */
>      public WhileGenerate(UnaryPredicate<? super E> test, Generator<? 
> extends E> wrapped) {
> -        super(Validate.notNull(wrapped, "Generator argument was 
> null"));
> -        this.test = Validate.notNull(test, "UnaryPredicate argument was 
> null");
> -    }
> -
> -    /**
> -     * {@inheritDoc}
> -     */
> -    public void run(final UnaryProcedure<? super E> proc) {
> -        getWrappedGenerator().run(new UnaryProcedure<E>() {
> -            public void run(E obj) {
> -                if (isStopped()) {
> -                    return;
> -                }
> -                if (!test.test(obj)) {
> -                    stop();
> -                } else {
> -                    proc.run(obj);
> -                }
> -            }
> -        });
> +        super(Validate.notNull(wrapped, "Generator argument was 
> null"), Validate.notNull(test,
> +            "UnaryPredicate argument was null"), 
> Behavior.TEST_BEFORE);
>      }
> 
> -    /**
> -     * {@inheritDoc}
> -     */
> -    @Override
> -    public boolean equals(Object obj) {
> -        if (obj == this) {
> -            return true;
> -        }
> -        if (!(obj instanceof WhileGenerate<?>)) {
> -            return false;
> -        }
> -        WhileGenerate<?> other = (WhileGenerate<?>) obj;
> -        return other.getWrappedGenerator().equals(getWrappedGenerator()) 
> && other.test.equals(test);
> -    }
> -
> -    /**
> -     * {@inheritDoc}
> -     */
> -    @Override
> -    public int hashCode() {
> -        int result = "WhileGenerate".hashCode();
> -        result <<= 2;
> -        Generator<?> gen = getWrappedGenerator();
> -        result ^= gen.hashCode();
> -        result <<= 2;
> -        result ^= test.hashCode();
> -        return result;
> -    }
> }
> 
> Modified: 
> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/range/CharacterRange.java
> URL: 
> http://svn.apache.org/viewvc/commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/range/CharacterRange.java?rev=1439683&r1=1439682&r2=1439683&view=diff
> ==============================================================================
> --- 
> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/range/CharacterRange.java 
> (original)
> +++ 
> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/range/CharacterRange.java 
> Mon Jan 28 22:49:36 2013
> @@ -21,7 +21,7 @@ import java.util.Collection;
> 
> import org.apache.commons.functor.BinaryFunction;
> import org.apache.commons.functor.UnaryProcedure;
> -import org.apache.commons.functor.generator.loop.LoopGenerator;
> +import org.apache.commons.functor.generator.BaseGenerator;
> import org.apache.commons.lang3.Validate;
> 
> /**
> @@ -30,7 +30,7 @@ import org.apache.commons.lang3.Validate
>   * @since 1.0
>   * @version $Revision$ $Date$
>   */
> -public final class CharacterRange extends LoopGenerator<Character> 
> implements Range<Character, Integer> {
> +public final class CharacterRange extends BaseGenerator<Character> 
> implements Range<Character, Integer> {
> 
>      // attributes
>      // ---------------------------------------------------------------
> 
> Modified: 
> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/range/NumericRange.java
> URL: 
> http://svn.apache.org/viewvc/commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/range/NumericRange.java?rev=1439683&r1=1439682&r2=1439683&view=diff
> ==============================================================================
> --- 
> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/range/NumericRange.java 
> (original)
> +++ 
> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/range/NumericRange.java 
> Mon Jan 28 22:49:36 2013
> @@ -19,7 +19,7 @@ package org.apache.commons.functor.gener
> 
> import java.util.Collection;
> 
> -import org.apache.commons.functor.generator.loop.LoopGenerator;
> +import org.apache.commons.functor.generator.BaseGenerator;
> import org.apache.commons.lang3.Validate;
> 
> /**
> @@ -35,7 +35,7 @@ import org.apache.commons.lang3.Validate
>   * @since 0.1
>   * @version $Revision$ $Date$
>   */
> -public abstract class NumericRange<T extends Number & 
> Comparable<T>> extends LoopGenerator<T> implements Range<T, 
> T> {
> +public abstract class NumericRange<T extends Number & 
> Comparable<T>> extends BaseGenerator<T> implements Range<T, 
> T> {
>      // attributes
>      // ---------------------------------------------------------------
>      /**
> 
> 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=1439683&r1=1439682&r2=1439683&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 
> Mon Jan 28 22:49:36 2013
> @@ -31,8 +31,8 @@ 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.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;
> @@ -116,7 +116,7 @@ public class TestAlgorithms {
> 
>      @Test
>      public void testApplyToGenerator() {
> -        LoopGenerator<Integer> gen = new IntegerRange(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/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=1439683&r1=1439682&r2=1439683&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 
> Mon Jan 28 22:49:36 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.loop.LoopGenerator;
> +import org.apache.commons.functor.generator.BaseGenerator;
> 
> /**
>   * @version $Revision$ $Date$
>   */
> -public class Lines extends LoopGenerator<String> {
> +public class Lines extends BaseGenerator<String> {
>      public static Lines from(Reader reader) {
>          return new Lines(reader);
>      }
> @@ -55,19 +55,13 @@ public class Lines extends LoopGenerator
>          } catch(Exception e) {
>              throw new TunneledException(e);
>          } finally {
> -            stop();
> -        }
> -    }
> -
> -    @Override
> -    public void stop() {
> -        super.stop();
> -        try {
> -            in.close();
> -        } catch(RuntimeException e) {
> -            throw e;
> -        } catch(Exception e) {
> -            throw new TunneledException(e);
> +            try {
> +                in.close();
> +            } catch(RuntimeException e) {
> +                throw e;
> +            } catch(Exception e) {
> +                throw new TunneledException(e);
> +            }
>          }
>      }
> 
> 
> Modified: 
> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/test/java/org/apache/commons/functor/generator/loop/TestGenerateUntil.java
> URL: 
> http://svn.apache.org/viewvc/commons/proper/functor/branches/FUNCTOR-14-mm/core/src/test/java/org/apache/commons/functor/generator/loop/TestGenerateUntil.java?rev=1439683&r1=1439682&r2=1439683&view=diff
> ==============================================================================
> --- 
> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/test/java/org/apache/commons/functor/generator/loop/TestGenerateUntil.java 
> (original)
> +++ 
> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/test/java/org/apache/commons/functor/generator/loop/TestGenerateUntil.java 
> Mon Jan 28 22:49:36 2013
> @@ -40,13 +40,13 @@ public class TestGenerateUntil {
>      // ------------------------------------------------------------------------
>      private static final Integer FIVE = new Integer(5);
> 
> -    private LoopGenerator<Integer> wrappedGenerator = null;
> +    private Generator<Integer> wrappedGenerator = null;
>      private UnaryPredicate<Integer> isMoreThanFive = new 
> UnaryPredicate<Integer>() {
>          public boolean test( Integer obj ) {
>              return obj > FIVE;
>          }
>      };
> -    private LoopGenerator<Integer> generateUntil = null;
> +    private PredicatedGenerator<Integer> generateUntil = null;
> 
>      @Before
>      public void setUp() throws Exception {
> 
> Modified: 
> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/test/java/org/apache/commons/functor/generator/loop/TestGenerateWhile.java
> URL: 
> http://svn.apache.org/viewvc/commons/proper/functor/branches/FUNCTOR-14-mm/core/src/test/java/org/apache/commons/functor/generator/loop/TestGenerateWhile.java?rev=1439683&r1=1439682&r2=1439683&view=diff
> ==============================================================================
> --- 
> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/test/java/org/apache/commons/functor/generator/loop/TestGenerateWhile.java 
> (original)
> +++ 
> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/test/java/org/apache/commons/functor/generator/loop/TestGenerateWhile.java 
> Mon Jan 28 22:49:36 2013
> @@ -40,13 +40,13 @@ public class TestGenerateWhile {
>      // ------------------------------------------------------------------------
>      private static final Integer FIVE = new Integer(5);
> 
> -    private LoopGenerator<Integer> wrappedGenerator = null;
> +    private Generator<Integer> wrappedGenerator = null;
>      private UnaryPredicate<Integer> isLessThanFive = new 
> UnaryPredicate<Integer>() {
>          public boolean test( Integer obj ) {
>              return obj < FIVE;
>          }
>      };
> -    private LoopGenerator<Integer> generateWhile = null;
> +    private PredicatedGenerator<Integer> generateWhile = null;
> 
>      @Before
>      public void setUp() throws Exception {
> 
> Modified: 
> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/test/java/org/apache/commons/functor/generator/loop/TestTransformedGenerator.java
> URL: 
> http://svn.apache.org/viewvc/commons/proper/functor/branches/FUNCTOR-14-mm/core/src/test/java/org/apache/commons/functor/generator/loop/TestTransformedGenerator.java?rev=1439683&r1=1439682&r2=1439683&view=diff
> ==============================================================================
> --- 
> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/test/java/org/apache/commons/functor/generator/loop/TestTransformedGenerator.java 
> (original)
> +++ 
> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/test/java/org/apache/commons/functor/generator/loop/TestTransformedGenerator.java 
> Mon Jan 28 22:49:36 2013
> @@ -22,6 +22,7 @@ import java.util.List;
> 
> import org.apache.commons.functor.UnaryFunction;
> import org.apache.commons.functor.UnaryProcedure;
> +import org.apache.commons.functor.generator.Generator;
> import org.apache.commons.functor.generator.range.IntegerRange;
> import org.junit.After;
> import org.junit.Before;
> @@ -36,7 +37,7 @@ public class TestTransformedGenerator {
>      // ------------------------------------------------------------------------
>      private static final Integer TWO = new Integer(2);
> 
> -    private LoopGenerator<Integer> wrappedGenerator = null;
> +    private Generator<Integer> wrappedGenerator = null;
>      private UnaryFunction<Integer, Integer> sumsTwo = new 
> UnaryFunction<Integer, Integer>() {
>          public Integer evaluate( Integer obj ) {
>              return obj += TWO;
> 
> Modified: 
> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/test/java/org/apache/commons/functor/generator/loop/TestUntilGenerate.java
> URL: 
> http://svn.apache.org/viewvc/commons/proper/functor/branches/FUNCTOR-14-mm/core/src/test/java/org/apache/commons/functor/generator/loop/TestUntilGenerate.java?rev=1439683&r1=1439682&r2=1439683&view=diff
> ==============================================================================
> --- 
> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/test/java/org/apache/commons/functor/generator/loop/TestUntilGenerate.java 
> (original)
> +++ 
> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/test/java/org/apache/commons/functor/generator/loop/TestUntilGenerate.java 
> Mon Jan 28 22:49:36 2013
> @@ -40,13 +40,13 @@ public class TestUntilGenerate {
>      // ------------------------------------------------------------------------
>      private static final Integer FIVE = new Integer(5);
> 
> -    private LoopGenerator<Integer> wrappedGenerator = null;
> +    private Generator<Integer> wrappedGenerator = null;
>      private UnaryPredicate<Integer> isGreaterThanFive = new 
> UnaryPredicate<Integer>() {
>          public boolean test(Integer obj) {
>              return obj > FIVE;
>          }
>      };
> -    private LoopGenerator<Integer> untilGenerate = null;
> +    private PredicatedGenerator<Integer> untilGenerate = null;
> 
>      @Before
>      public void setUp() throws Exception {
> 
> Modified: 
> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/test/java/org/apache/commons/functor/generator/loop/TestWhileGenerate.java
> URL: 
> http://svn.apache.org/viewvc/commons/proper/functor/branches/FUNCTOR-14-mm/core/src/test/java/org/apache/commons/functor/generator/loop/TestWhileGenerate.java?rev=1439683&r1=1439682&r2=1439683&view=diff
> ==============================================================================
> --- 
> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/test/java/org/apache/commons/functor/generator/loop/TestWhileGenerate.java 
> (original)
> +++ 
> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/test/java/org/apache/commons/functor/generator/loop/TestWhileGenerate.java 
> Mon Jan 28 22:49:36 2013
> @@ -42,13 +42,13 @@ public class TestWhileGenerate {
>      // ------------------------------------------------------------------------
>      private static final Integer FIVE = new Integer(5);
> 
> -    private LoopGenerator<Integer> wrappedGenerator = null;
> +    private Generator<Integer> wrappedGenerator = null;
>      private UnaryPredicate<Integer> isLessThanFive = new 
> UnaryPredicate<Integer>() {
>          public boolean test( Integer obj ) {
>              return obj < FIVE;
>          }
>      };
> -    private LoopGenerator<Integer> whileGenerate = null;
> +    private PredicatedGenerator<Integer> whileGenerate = null;
> 
>      @Before
>      public void setUp() throws Exception {
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org


Re: svn commit: r1439683 - in /commons/proper/functor/branches/FUNCTOR-14-mm/core/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/org/a...

Posted by "Bruno P. Kinoshita" <br...@yahoo.com.br>.
Maybe oac.generator.predicated? 
 
Bruno P. Kinoshita
http://kinoshita.eti.br
http://tupilabs.com


----- Original Message -----
> From: Matt Benson <gu...@gmail.com>
> To: Commons Developers List <de...@commons.apache.org>; Bruno P. Kinoshita <br...@yahoo.com.br>
> Cc: 
> Sent: Tuesday, January 29, 2013 12:25 AM
> Subject: Re: svn commit: r1439683 - in /commons/proper/functor/branches/FUNCTOR-14-mm/core/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/org/a...
> 
> Hmm, I'm struggling with the package name.  oacf.generator.flow?  I wonder
> if we should just merge this package back into oacf.generator.
> 
> Matt
> 
> 
> On Mon, Jan 28, 2013 at 8:15 PM, Matt Benson <gu...@gmail.com> wrote:
> 
>>  I think so, yes.  :)  Knew there was something I forgot!
>> 
>>  Matt
>> 
>> 
>>  On Mon, Jan 28, 2013 at 7:23 PM, Bruno P. Kinoshita <
>>  brunodepaulak@yahoo.com.br> wrote:
>> 
>>>  Thanks Matt! The name is more intuitive now. What about the package 
> name?
>>>  Should we rename it as well?
>>> 
>>>  Cheers,
>>> 
>>>  Bruno P. Kinoshita
>>>  http://kinoshita.eti.br
>>>  http://tupilabs.com
>>> 
>>> 
>>>  ----- Original Message -----
>>>  > From: "mbenson@apache.org" <mb...@apache.org>
>>>  > To: commits@commons.apache.org
>>>  > Cc:
>>>  > Sent: Monday, January 28, 2013 8:49 PM
>>>  > Subject: svn commit: r1439683 - in
>>>  /commons/proper/functor/branches/FUNCTOR-14-mm/core/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/org/a...
>>>  >
>>>  > Author: mbenson
>>>  > Date: Mon Jan 28 22:49:36 2013
>>>  > New Revision: 1439683
>>>  >
>>>  > URL: http://svn.apache.org/viewvc?rev=1439683&view=rev
>>>  > Log:
>>>  > refactor LoopGenerator to PredicatedGenerator
>>>  >
>>>  > Added:
>>>  >
>>>  >
>>> 
> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/loop/PredicatedGenerator.java
>>>  >       - copied, changed from r1439123,
>>>  >
>>> 
> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/loop/LoopGenerator.java
>>>  > Removed:
>>>  >
>>>  >
>>> 
> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/loop/LoopGenerator.java
>>>  >
>>>  >
>>> 
> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/test/java/org/apache/commons/functor/generator/loop/TestLoopGenerator.java
>>>  > Modified:
>>>  >
>>>  >
>>> 
> 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/loop/GenerateUntil.java
>>>  >
>>>  >
>>> 
> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/loop/GenerateWhile.java
>>>  >
>>>  >
>>> 
> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/loop/IteratorToGeneratorAdapter.java
>>>  >
>>>  >
>>> 
> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/loop/TransformedGenerator.java
>>>  >
>>>  >
>>> 
> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/loop/UntilGenerate.java
>>>  >
>>>  >
>>> 
> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/loop/WhileGenerate.java
>>>  >
>>>  >
>>> 
> commons/proper/functor/branches/FUNCTOR-14-mm/core/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/NumericRange.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/example/lines/Lines.java
>>>  >
>>>  >
>>> 
> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/test/java/org/apache/commons/functor/generator/loop/TestGenerateUntil.java
>>>  >
>>>  >
>>> 
> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/test/java/org/apache/commons/functor/generator/loop/TestGenerateWhile.java
>>>  >
>>>  >
>>> 
> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/test/java/org/apache/commons/functor/generator/loop/TestTransformedGenerator.java
>>>  >
>>>  >
>>> 
> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/test/java/org/apache/commons/functor/generator/loop/TestUntilGenerate.java
>>>  >
>>>  >
>>> 
> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/test/java/org/apache/commons/functor/generator/loop/TestWhileGenerate.java
>>>  >
>>>  > 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=1439683&r1=1439682&r2=1439683&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
>>>  > Mon Jan 28 22:49:36 2013
>>>  > @@ -21,17 +21,19 @@ 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.loop.LoopGenerator;
>>>  > +import org.apache.commons.functor.generator.Generator;
>>>  > +import 
> org.apache.commons.functor.generator.loop.PredicatedGenerator;
>>>  > +import org.apache.commons.functor.generator.loop.UntilGenerate;
>>>  >
>>>  > /**
>>>  > - * Return the index of the first Object in a {@link 
> LoopGenerator}
>>>  matching a
>>>  > + * Return the index of the first Object in a {@link
>>>  PredicatedGenerator}
>>>  > 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<LoopGenerator<? extends 
> T>,
>>>  > UnaryPredicate<? super T>, Number>, Serializable {
>>>  > +    implements BinaryFunction<Generator<? extends T>,
>>>  > UnaryPredicate<? super T>, Number>, Serializable {
>>>  >      /**
>>>  >       * serialVersionUID declaration.
>>>  >       */
>>>  > @@ -48,42 +50,14 @@ public final class IndexOfInGenerator<T>
>>>  >       */
>>>  >      private static class IndexProcedure<T> implements
>>>  > UnaryProcedure<T> {
>>>  >          /**
>>>  > -         * The wrapped generator.
>>>  > -         */
>>>  > -        private final LoopGenerator<? extends T> generator;
>>>  > -        /**
>>>  > -         * The wrapped predicate.
>>>  > -         */
>>>  > -        private final UnaryPredicate<? super T> pred;
>>>  > -        /**
>>>  > -         * The number of iterations needed before the wrapped
>>>  predicate found
>>>  > the target,
>>>  > -         * {@code -1} means the target was not found.
>>>  > -         */
>>>  > -        private long index = -1L;
>>>  > -        /**
>>>  >           * A local accumulator to increment the number of 
> attempts.
>>>  >           */
>>>  >          private long current = 0L;
>>>  >
>>>  >          /**
>>>  > -         * Create a new IndexProcedure.
>>>  > -         *
>>>  > -         * @param generator The wrapped generator
>>>  > -         * @param pred The wrapped predicate
>>>  > -         */
>>>  > -        IndexProcedure(LoopGenerator<? extends T> 
> generator,
>>>  > UnaryPredicate<? super T> pred) {
>>>  > -            this.generator = generator;
>>>  > -            this.pred = pred;
>>>  > -        }
>>>  > -
>>>  > -        /**
>>>  >           * {@inheritDoc}
>>>  >           */
>>>  >          public void run(T obj) {
>>>  > -            if (index < 0 && pred.test(obj)) {
>>>  > -                index = current;
>>>  > -                generator.stop();
>>>  > -            }
>>>  >              current++;
>>>  >          }
>>>  >      }
>>>  > @@ -93,10 +67,10 @@ public final class IndexOfInGenerator<T>
>>>  >       * @param left Generator
>>>  >       * @param right UnaryPredicate
>>>  >       */
>>>  > -    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);
>>>  > +    public Number evaluate(Generator<? extends T> left,
>>>  > UnaryPredicate<? super T> right) {
>>>  > +        final IndexProcedure<T> findProcedure = new
>>>  > IndexProcedure<T>();
>>>  > +        new UntilGenerate<T>(right, 
> left).run(findProcedure);
>>>  > +        return Long.valueOf(findProcedure.current);
>>>  >      }
>>>  >
>>>  >      /**
>>>  >
>>>  > 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=1439683&r1=1439682&r2=1439683&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
>>>  > Mon Jan 28 22:49:36 2013
>>>  > @@ -29,8 +29,10 @@ import org.apache.commons.functor.genera
>>>  >   */
>>>  > public abstract class BaseGenerator<E> implements 
> Generator<E> {
>>>  >
>>>  > -    /** Create a new generator. */
>>>  > -    public BaseGenerator() {
>>>  > +    /**
>>>  > +     * Create a new BaseGenerator instance.
>>>  > +     */
>>>  > +    protected BaseGenerator() {
>>>  >          super();
>>>  >      }
>>>  >
>>>  >
>>>  > Modified:
>>>  >
>>> 
> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/loop/GenerateUntil.java
>>>  > URL:
>>>  >
>>> 
> http://svn.apache.org/viewvc/commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/loop/GenerateUntil.java?rev=1439683&r1=1439682&r2=1439683&view=diff
>>>  >
>>> 
> ==============================================================================
>>>  > ---
>>>  >
>>> 
> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/loop/GenerateUntil.java
>>>  > (original)
>>>  > +++
>>>  >
>>> 
> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/loop/GenerateUntil.java
>>>  > Mon Jan 28 22:49:36 2013
>>>  > @@ -18,6 +18,7 @@ package org.apache.commons.functor.gener
>>>  >
>>>  > import org.apache.commons.functor.UnaryPredicate;
>>>  > import org.apache.commons.functor.UnaryProcedure;
>>>  > +import org.apache.commons.functor.core.composite.UnaryNot;
>>>  > import org.apache.commons.functor.generator.Generator;
>>>  > import org.apache.commons.lang3.Validate;
>>>  >
>>>  > @@ -28,12 +29,7 @@ import org.apache.commons.lang3.Validate
>>>  >   * @param <E> the type of elements held in this generator.
>>>  >   * @version $Revision$ $Date$
>>>  >   */
>>>  > -public class GenerateUntil<E> extends 
> LoopGenerator<E> {
>>>  > -
>>>  > -    /**
>>>  > -     * The condition has to verified in order to execute the
>>>  generation.
>>>  > -     */
>>>  > -    private final UnaryPredicate<? super E> test;
>>>  > +public class GenerateUntil<E> extends 
> PredicatedGenerator<E> {
>>>  >
>>>  >      /**
>>>  >       * Create a new GenerateUntil.
>>>  > @@ -41,53 +37,8 @@ public class GenerateUntil<E> extends Lo
>>>  >       * @param test {@link UnaryPredicate}
>>>  >       */
>>>  >      public GenerateUntil(Generator<? extends E> wrapped,
>>>  > UnaryPredicate<? super E> test) {
>>>  > -        super(Validate.notNull(wrapped, "Generator argument 
> was
>>>  > null"));
>>>  > -        this.test = Validate.notNull(test, "UnaryPredicate 
> argument was
>>>  > null");
>>>  > -    }
>>>  > -
>>>  > -    /**
>>>  > -     * {@inheritDoc}
>>>  > -     */
>>>  > -    public void run(final UnaryProcedure<? super E> proc) {
>>>  > -        getWrappedGenerator().run(new UnaryProcedure<E>() {
>>>  > -            public void run(E obj) {
>>>  > -                if (isStopped()) {
>>>  > -                    return;
>>>  > -                }
>>>  > -                proc.run(obj);
>>>  > -                if (test.test(obj)) {
>>>  > -                    stop();
>>>  > -                }
>>>  > -            }
>>>  > -        });
>>>  > +        super(Validate.notNull(wrapped, "Generator argument 
> was
>>>  > null"), UnaryNot.not(Validate.notNull(test,
>>>  > +            "UnaryPredicate argument was null")),
>>>  > Behavior.TEST_AFTER);
>>>  >      }
>>>  >
>>>  > -    /**
>>>  > -     * {@inheritDoc}
>>>  > -     */
>>>  > -    @Override
>>>  > -    public boolean equals(Object obj) {
>>>  > -        if (obj == this) {
>>>  > -            return true;
>>>  > -        }
>>>  > -        if (!(obj instanceof GenerateUntil<?>)) {
>>>  > -            return false;
>>>  > -        }
>>>  > -        GenerateUntil<?> other = (GenerateUntil<?>) 
> obj;
>>>  > -        return
>>>  other.getWrappedGenerator().equals(getWrappedGenerator())
>>>  > && other.test.equals(test);
>>>  > -    }
>>>  > -
>>>  > -    /**
>>>  > -     * {@inheritDoc}
>>>  > -     */
>>>  > -    @Override
>>>  > -    public int hashCode() {
>>>  > -        int result = "GenerateUntil".hashCode();
>>>  > -        result <<= 2;
>>>  > -        Generator<?> gen = getWrappedGenerator();
>>>  > -        result ^= gen.hashCode();
>>>  > -        result <<= 2;
>>>  > -        result ^= test.hashCode();
>>>  > -        return result;
>>>  > -    }
>>>  > }
>>>  >
>>>  > Modified:
>>>  >
>>> 
> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/loop/GenerateWhile.java
>>>  > URL:
>>>  >
>>> 
> http://svn.apache.org/viewvc/commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/loop/GenerateWhile.java?rev=1439683&r1=1439682&r2=1439683&view=diff
>>>  >
>>> 
> ==============================================================================
>>>  > ---
>>>  >
>>> 
> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/loop/GenerateWhile.java
>>>  > (original)
>>>  > +++
>>>  >
>>> 
> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/loop/GenerateWhile.java
>>>  > Mon Jan 28 22:49:36 2013
>>>  > @@ -28,12 +28,7 @@ import org.apache.commons.lang3.Validate
>>>  >   * @param <E> the type of elements held in this generator.
>>>  >   * @version $Revision$ $Date$
>>>  >   */
>>>  > -public class GenerateWhile<E> extends 
> LoopGenerator<E> {
>>>  > -
>>>  > -    /**
>>>  > -     * The condition has to verified in order to execute the
>>>  generation.
>>>  > -     */
>>>  > -    private final UnaryPredicate<? super E> test;
>>>  > +public class GenerateWhile<E> extends 
> PredicatedGenerator<E> {
>>>  >
>>>  >      /**
>>>  >       * Create a new GenerateWhile.
>>>  > @@ -41,53 +36,8 @@ public class GenerateWhile<E> extends Lo
>>>  >       * @param test {@link UnaryPredicate}
>>>  >       */
>>>  >      public GenerateWhile(Generator<? extends E> wrapped,
>>>  > UnaryPredicate<? super E> test) {
>>>  > -        super(Validate.notNull(wrapped, "Generator argument 
> was
>>>  > null"));
>>>  > -        this.test = Validate.notNull(test, "UnaryPredicate 
> argument was
>>>  > null");
>>>  > -    }
>>>  > -
>>>  > -    /**
>>>  > -     * {@inheritDoc}
>>>  > -     */
>>>  > -    public void run(final UnaryProcedure<? super E> proc) {
>>>  > -        getWrappedGenerator().run(new UnaryProcedure<E>() {
>>>  > -            public void run(E obj) {
>>>  > -                if (isStopped()) {
>>>  > -                    return;
>>>  > -                }
>>>  > -                proc.run(obj);
>>>  > -                if (!test.test(obj)) {
>>>  > -                    stop();
>>>  > -                }
>>>  > -            }
>>>  > -        });
>>>  > +        super(Validate.notNull(wrapped, "Generator argument 
> was
>>>  > null"),
>>>  > +        Validate.notNull(test, "UnaryPredicate argument was 
> null"),
>>>  > Behavior.TEST_AFTER);
>>>  >      }
>>>  >
>>>  > -    /**
>>>  > -     * {@inheritDoc}
>>>  > -     */
>>>  > -    @Override
>>>  > -    public boolean equals(Object obj) {
>>>  > -        if (obj == this) {
>>>  > -            return true;
>>>  > -        }
>>>  > -        if (!(obj instanceof GenerateWhile<?>)) {
>>>  > -            return false;
>>>  > -        }
>>>  > -        GenerateWhile<?> other = (GenerateWhile<?>) 
> obj;
>>>  > -        return
>>>  other.getWrappedGenerator().equals(getWrappedGenerator())
>>>  > && other.test.equals(test);
>>>  > -    }
>>>  > -
>>>  > -    /**
>>>  > -     * {@inheritDoc}
>>>  > -     */
>>>  > -    @Override
>>>  > -    public int hashCode() {
>>>  > -        int result = "GenerateWhile".hashCode();
>>>  > -        result <<= 2;
>>>  > -        Generator<?> gen = getWrappedGenerator();
>>>  > -        result ^= gen.hashCode();
>>>  > -        result <<= 2;
>>>  > -        result ^= test.hashCode();
>>>  > -        return result;
>>>  > -    }
>>>  > }
>>>  >
>>>  > Modified:
>>>  >
>>> 
> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/loop/IteratorToGeneratorAdapter.java
>>>  > URL:
>>>  >
>>> 
> http://svn.apache.org/viewvc/commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/loop/IteratorToGeneratorAdapter.java?rev=1439683&r1=1439682&r2=1439683&view=diff
>>>  >
>>> 
> ==============================================================================
>>>  > ---
>>>  >
>>> 
> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/loop/IteratorToGeneratorAdapter.java
>>>  > (original)
>>>  > +++
>>>  >
>>> 
> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/loop/IteratorToGeneratorAdapter.java
>>>  > Mon Jan 28 22:49:36 2013
>>>  > @@ -14,19 +14,23 @@
>>>  >
>>>  > package org.apache.commons.functor.generator.loop;
>>>  >
>>>  > +import java.util.Collection;
>>>  > import java.util.Iterator;
>>>  >
>>>  > +import org.apache.commons.functor.UnaryFunction;
>>>  > import org.apache.commons.functor.UnaryProcedure;
>>>  > +import org.apache.commons.functor.generator.BaseGenerator;
>>>  > +import org.apache.commons.functor.generator.Generator;
>>>  > import org.apache.commons.lang3.Validate;
>>>  >
>>>  > /**
>>>  > - * Adapts an {@link Iterator} to the {@link LoopGenerator} 
> interface.
>>>  > + * Adapts an {@link Iterator} to the {@link PredicatedGenerator}
>>>  interface.
>>>  >   *
>>>  >   * @param <E> the type of elements held in this generator.
>>>  >   * @since 1.0
>>>  >   * @version $Revision$ $Date$
>>>  >   */
>>>  > -public final class IteratorToGeneratorAdapter<E> extends
>>>  > LoopGenerator<E> {
>>>  > +public final class IteratorToGeneratorAdapter<E> extends
>>>  > BaseGenerator<E> {
>>>  >      // instance variables
>>>  >      //-----------------------------------------------------
>>>  >
>>>  > @@ -53,9 +57,6 @@ public final class IteratorToGeneratorAd
>>>  >      public void run(UnaryProcedure<? super E> proc) {
>>>  >          while (iter.hasNext()) {
>>>  >              proc.run(iter.next());
>>>  > -            if (isStopped()) {
>>>  > -                break;
>>>  > -            }
>>>  >          }
>>>  >      }
>>>  >
>>>  >
>>>  > Copied:
>>>  >
>>> 
> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/loop/PredicatedGenerator.java
>>>  > (from r1439123,
>>>  >
>>> 
> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/loop/LoopGenerator.java)
>>>  > URL:
>>>  >
>>> 
> http://svn.apache.org/viewvc/commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/loop/PredicatedGenerator.java?p2=commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/loop/PredicatedGenerator.java&p1=commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/loop/LoopGenerator.java&r1=1439123&r2=1439683&rev=1439683&view=diff
>>>  >
>>> 
> ==============================================================================
>>>  > ---
>>>  >
>>> 
> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/loop/LoopGenerator.java
>>>  > (original)
>>>  > +++
>>>  >
>>> 
> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/loop/PredicatedGenerator.java
>>>  > Mon Jan 28 22:49:36 2013
>>>  > @@ -14,6 +14,8 @@
>>>  >
>>>  > package org.apache.commons.functor.generator.loop;
>>>  >
>>>  > +import org.apache.commons.functor.UnaryPredicate;
>>>  > +import org.apache.commons.functor.UnaryProcedure;
>>>  > import org.apache.commons.functor.generator.BaseGenerator;
>>>  > import org.apache.commons.functor.generator.Generator;
>>>  >
>>>  > @@ -25,27 +27,29 @@ import org.apache.commons.functor.genera
>>>  >   * @since 1.0
>>>  >   * @version $Revision:$ $Date:$
>>>  >   */
>>>  > -public abstract class LoopGenerator<E> extends 
> BaseGenerator<E> {
>>>  > +public abstract class PredicatedGenerator<E> extends
>>>  > BaseGenerator<E> {
>>>  > +    public enum Behavior {
>>>  > +        TEST_BEFORE, TEST_AFTER;
>>>  > +    }
>>>  >
>>>  > -    /** A generator can wrap another generator. */
>>>  >      private final Generator<? extends E> wrappedGenerator;
>>>  > +    private final UnaryPredicate<? super E> 
> continuePredicate;
>>>  > +    private final Behavior behavior;
>>>  >
>>>  > -    /** Set to true when the generator is {@link #stop stopped}. 
> */
>>>  > +    /** 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
>>>  > +     * Create a new PredicatedGenerator instance.
>>>  > +     * @param wrappedGenerator
>>>  > +     * @param continuePredicate
>>>  > +     * @param behavior
>>>  >       */
>>>  > -    public LoopGenerator(Generator<? extends E> generator) 
> {
>>>  > -        this.wrappedGenerator = generator;
>>>  > +    protected PredicatedGenerator(Generator<? extends E>
>>>  > wrappedGenerator, UnaryPredicate<? super E> 
> continuePredicate, Behavior
>>>  > behavior) {
>>>  > +        super();
>>>  > +        this.wrappedGenerator = wrappedGenerator;
>>>  > +        this.continuePredicate = continuePredicate;
>>>  > +        this.behavior = behavior;
>>>  >      }
>>>  >
>>>  >      /**
>>>  > @@ -58,21 +62,58 @@ public abstract class LoopGenerator<E> e
>>>  >
>>>  >      /**
>>>  >       * {@inheritDoc}
>>>  > -     * Stop the generator. Will stop the wrapped generator if one 
> was
>>>  set.
>>>  >       */
>>>  > -    public void stop() {
>>>  > -        if (wrappedGenerator != null && wrappedGenerator 
> instanceof
>>>  > LoopGenerator<?>) {
>>>  > -            ((LoopGenerator<?>) wrappedGenerator).stop();
>>>  > +    public void run(final UnaryProcedure<? super E> proc) {
>>>  > +        wrappedGenerator.run(new UnaryProcedure<E>() {
>>>  > +            public void run(E obj) {
>>>  > +                if (stopped) {
>>>  > +                    return;
>>>  > +                }
>>>  > +                if (behavior == Behavior.TEST_BEFORE &&
>>>  > !continuePredicate.test(obj)) {
>>>  > +                    stop();
>>>  > +                    return;
>>>  > +                }
>>>  > +                proc.run(obj);
>>>  > +                if (behavior == Behavior.TEST_AFTER &&
>>>  > !continuePredicate.test(obj)) {
>>>  > +                    stop();
>>>  > +                }
>>>  > +            }
>>>  > +        });
>>>  > +    }
>>>  > +    /**
>>>  > +     * {@inheritDoc}
>>>  > +     */
>>>  > +    @Override
>>>  > +    public boolean equals(Object obj) {
>>>  > +        if (obj == this) {
>>>  > +            return true;
>>>  >          }
>>>  > -        stopped = true;
>>>  > +        if (!(obj instanceof PredicatedGenerator<?>)) {
>>>  > +            return false;
>>>  > +        }
>>>  > +        PredicatedGenerator<?> other = 
> (PredicatedGenerator<?>)
>>>  > obj;
>>>  > +        return
>>>  other.getWrappedGenerator().equals(getWrappedGenerator())
>>>  > +            && 
> other.continuePredicate.equals(continuePredicate)
>>>  > && other.behavior == behavior;
>>>  >      }
>>>  >
>>>  >      /**
>>>  >       * {@inheritDoc}
>>>  > -     * Check if the generator is stopped.
>>>  >       */
>>>  > -    public boolean isStopped() {
>>>  > -        return stopped;
>>>  > +    @Override
>>>  > +    public int hashCode() {
>>>  > +        int result = getClass().getSimpleName().hashCode();
>>>  > +        result <<= 2;
>>>  > +        Generator<?> gen = getWrappedGenerator();
>>>  > +        result ^= gen.hashCode();
>>>  > +        result <<= 2;
>>>  > +        result ^= continuePredicate.hashCode();
>>>  > +        result <<= 2;
>>>  > +        result ^= behavior.ordinal();
>>>  > +        return result;
>>>  > +    }
>>>  > +
>>>  > +    private void stop() {
>>>  > +        stopped = true;
>>>  >      }
>>>  >
>>>  > }
>>>  >
>>>  > Modified:
>>>  >
>>> 
> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/loop/TransformedGenerator.java
>>>  > URL:
>>>  >
>>> 
> http://svn.apache.org/viewvc/commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/loop/TransformedGenerator.java?rev=1439683&r1=1439682&r2=1439683&view=diff
>>>  >
>>> 
> ==============================================================================
>>>  > ---
>>>  >
>>> 
> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/loop/TransformedGenerator.java
>>>  > (original)
>>>  > +++
>>>  >
>>> 
> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/loop/TransformedGenerator.java
>>>  > Mon Jan 28 22:49:36 2013
>>>  > @@ -18,6 +18,7 @@ package org.apache.commons.functor.gener
>>>  >
>>>  > import org.apache.commons.functor.UnaryFunction;
>>>  > import org.apache.commons.functor.UnaryProcedure;
>>>  > +import org.apache.commons.functor.generator.BaseGenerator;
>>>  > import org.apache.commons.functor.generator.Generator;
>>>  > import org.apache.commons.lang3.Validate;
>>>  >
>>>  > @@ -28,34 +29,34 @@ import org.apache.commons.lang3.Validate
>>>  >   * @param <E> the type of elements held in this generator.
>>>  >   * @version $Revision$ $Date$
>>>  >   */
>>>  > -public class TransformedGenerator<I, E> extends 
> LoopGenerator<E> {
>>>  > +public class TransformedGenerator<I, E> extends 
> BaseGenerator<E> {
>>>  > +
>>>  > +    /**
>>>  > +     * The wrapped/<em>I</em>nput generator.
>>>  > +     */
>>>  > +    private final Generator<? extends I> wrappedGenerator;
>>>  >
>>>  >      /**
>>>  >       * The UnaryFunction to apply to each element.
>>>  >       */
>>>  >      private final UnaryFunction<? super I, ? extends E> 
> func;
>>>  >
>>>  > -    // 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.
>>>  >      /**
>>>  >       * Create a new TransformedGenerator.
>>>  >       * @param wrapped Generator to transform
>>>  >       * @param func UnaryFunction to apply to each element
>>>  >       */
>>>  > -    @SuppressWarnings("unchecked")
>>>  >      public TransformedGenerator(Generator<? extends I> 
> wrapped,
>>>  > UnaryFunction<? super I, ? extends E> func) {
>>>  > -        super((Generator<? extends E>) 
> Validate.notNull(wrapped,
>>>  > "Generator argument was null"));
>>>  > +        this.wrappedGenerator =
>>>  > +        Validate.notNull(wrapped, "Generator argument was 
> null");
>>>  >          this.func = Validate.notNull(func, "UnaryFunction 
> argument was
>>>  > null");
>>>  >      }
>>>  >
>>>  >      /**
>>>  >       * {@inheritDoc}
>>>  >       */
>>>  > -    @SuppressWarnings("unchecked")
>>>  >      public void run(final UnaryProcedure<? super E> proc) {
>>>  > -        ((Generator<? extends I>) 
> getWrappedGenerator()).run(new
>>>  > UnaryProcedure<I>() {
>>>  > +        wrappedGenerator.run(new UnaryProcedure<I>() {
>>>  >              public void run(I obj) {
>>>  >                  proc.run(func.evaluate(obj));
>>>  >              }
>>>  > @@ -74,7 +75,7 @@ public class TransformedGenerator<I, E>
>>>  >              return false;
>>>  >          }
>>>  >          TransformedGenerator<?, ?> other = 
> (TransformedGenerator<?,
>>>  > ?>) obj;
>>>  > -        return
>>>  other.getWrappedGenerator().equals(getWrappedGenerator())
>>>  > && other.func == func;
>>>  > +        return other.wrappedGenerator.equals(wrappedGenerator) 
> &&
>>>  > other.func.equals(func);
>>>  >      }
>>>  >
>>>  >      /**
>>>  > @@ -84,7 +85,7 @@ public class TransformedGenerator<I, E>
>>>  >      public int hashCode() {
>>>  >          int result = "TransformedGenerator".hashCode();
>>>  >          result <<= 2;
>>>  > -        Generator<?> gen = getWrappedGenerator();
>>>  > +        Generator<?> gen = wrappedGenerator;
>>>  >          result ^= gen.hashCode();
>>>  >          result <<= 2;
>>>  >          result ^= func.hashCode();
>>>  >
>>>  > Modified:
>>>  >
>>> 
> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/loop/UntilGenerate.java
>>>  > URL:
>>>  >
>>> 
> http://svn.apache.org/viewvc/commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/loop/UntilGenerate.java?rev=1439683&r1=1439682&r2=1439683&view=diff
>>>  >
>>> 
> ==============================================================================
>>>  > ---
>>>  >
>>> 
> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/loop/UntilGenerate.java
>>>  > (original)
>>>  > +++
>>>  >
>>> 
> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/loop/UntilGenerate.java
>>>  > Mon Jan 28 22:49:36 2013
>>>  > @@ -18,6 +18,7 @@ package org.apache.commons.functor.gener
>>>  >
>>>  > import org.apache.commons.functor.UnaryPredicate;
>>>  > import org.apache.commons.functor.UnaryProcedure;
>>>  > +import org.apache.commons.functor.core.composite.UnaryNot;
>>>  > import org.apache.commons.functor.generator.Generator;
>>>  > import org.apache.commons.lang3.Validate;
>>>  >
>>>  > @@ -28,12 +29,7 @@ import org.apache.commons.lang3.Validate
>>>  >   * @param <E> the type of elements held in this generator.
>>>  >   * @version $Revision$ $Date$
>>>  >   */
>>>  > -public class UntilGenerate<E> extends 
> LoopGenerator<E> {
>>>  > -
>>>  > -    /**
>>>  > -     * The condition has to verified in order to execute the
>>>  generation.
>>>  > -     */
>>>  > -    private final UnaryPredicate<? super E> test;
>>>  > +public class UntilGenerate<E> extends 
> PredicatedGenerator<E> {
>>>  >
>>>  >      /**
>>>  >       * Create a new UntilGenerate.
>>>  > @@ -41,54 +37,8 @@ public class UntilGenerate<E> extends Lo
>>>  >       * @param test {@link UnaryPredicate}
>>>  >       */
>>>  >      public UntilGenerate(UnaryPredicate<? super E> test, 
> Generator<?
>>>  > extends E> wrapped) {
>>>  > -        super(Validate.notNull(wrapped, "Generator argument 
> was
>>>  > null"));
>>>  > -        this.test = Validate.notNull(test, "UnaryPredicate 
> argument was
>>>  > null");
>>>  > -    }
>>>  > -
>>>  > -    /**
>>>  > -     * {@inheritDoc}
>>>  > -     */
>>>  > -    public void run(final UnaryProcedure<? super E> proc) {
>>>  > -        getWrappedGenerator().run(new UnaryProcedure<E>() {
>>>  > -            public void run(E obj) {
>>>  > -                if (isStopped()) {
>>>  > -                    return;
>>>  > -                }
>>>  > -                if (test.test(obj)) {
>>>  > -                    stop();
>>>  > -                } else {
>>>  > -                    proc.run(obj);
>>>  > -                }
>>>  > -            }
>>>  > -        });
>>>  > +        super(Validate.notNull(wrapped, "Generator argument 
> was
>>>  > null"), UnaryNot.not(Validate.notNull(test,
>>>  > +            "UnaryPredicate argument was null")),
>>>  > Behavior.TEST_BEFORE);
>>>  >      }
>>>  >
>>>  > -    /**
>>>  > -     * {@inheritDoc}
>>>  > -     */
>>>  > -    @Override
>>>  > -    public boolean equals(Object obj) {
>>>  > -        if (obj == this) {
>>>  > -            return true;
>>>  > -        }
>>>  > -        if (!(obj instanceof UntilGenerate<?>)) {
>>>  > -            return false;
>>>  > -        }
>>>  > -        UntilGenerate<?> other = (UntilGenerate<?>) 
> obj;
>>>  > -        return
>>>  other.getWrappedGenerator().equals(getWrappedGenerator())
>>>  > && other.test.equals(test);
>>>  > -    }
>>>  > -
>>>  > -    /**
>>>  > -     * {@inheritDoc}
>>>  > -     */
>>>  > -    @Override
>>>  > -    public int hashCode() {
>>>  > -        int result = "UntilGenerate".hashCode();
>>>  > -        result <<= 2;
>>>  > -        Generator<?> gen = getWrappedGenerator();
>>>  > -        result ^= gen.hashCode();
>>>  > -        result <<= 2;
>>>  > -        result ^= test.hashCode();
>>>  > -        return result;
>>>  > -    }
>>>  > }
>>>  >
>>>  > Modified:
>>>  >
>>> 
> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/loop/WhileGenerate.java
>>>  > URL:
>>>  >
>>> 
> http://svn.apache.org/viewvc/commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/loop/WhileGenerate.java?rev=1439683&r1=1439682&r2=1439683&view=diff
>>>  >
>>> 
> ==============================================================================
>>>  > ---
>>>  >
>>> 
> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/loop/WhileGenerate.java
>>>  > (original)
>>>  > +++
>>>  >
>>> 
> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/loop/WhileGenerate.java
>>>  > Mon Jan 28 22:49:36 2013
>>>  > @@ -28,12 +28,7 @@ import org.apache.commons.lang3.Validate
>>>  >   * @param <E> the type of elements held in this generator.
>>>  >   * @version $Revision$ $Date$
>>>  >   */
>>>  > -public class WhileGenerate<E> extends 
> LoopGenerator<E> {
>>>  > -
>>>  > -    /**
>>>  > -     * The condition has to verified in order to execute the
>>>  generation.
>>>  > -     */
>>>  > -    private final UnaryPredicate<? super E> test;
>>>  > +public class WhileGenerate<E> extends 
> PredicatedGenerator<E> {
>>>  >
>>>  >      /**
>>>  >       * Create a new WhileGenerate.
>>>  > @@ -41,54 +36,8 @@ public class WhileGenerate<E> extends Lo
>>>  >       * @param wrapped {@link Generator}
>>>  >       */
>>>  >      public WhileGenerate(UnaryPredicate<? super E> test, 
> Generator<?
>>>  > extends E> wrapped) {
>>>  > -        super(Validate.notNull(wrapped, "Generator argument 
> was
>>>  > null"));
>>>  > -        this.test = Validate.notNull(test, "UnaryPredicate 
> argument was
>>>  > null");
>>>  > -    }
>>>  > -
>>>  > -    /**
>>>  > -     * {@inheritDoc}
>>>  > -     */
>>>  > -    public void run(final UnaryProcedure<? super E> proc) {
>>>  > -        getWrappedGenerator().run(new UnaryProcedure<E>() {
>>>  > -            public void run(E obj) {
>>>  > -                if (isStopped()) {
>>>  > -                    return;
>>>  > -                }
>>>  > -                if (!test.test(obj)) {
>>>  > -                    stop();
>>>  > -                } else {
>>>  > -                    proc.run(obj);
>>>  > -                }
>>>  > -            }
>>>  > -        });
>>>  > +        super(Validate.notNull(wrapped, "Generator argument 
> was
>>>  > null"), Validate.notNull(test,
>>>  > +            "UnaryPredicate argument was null"),
>>>  > Behavior.TEST_BEFORE);
>>>  >      }
>>>  >
>>>  > -    /**
>>>  > -     * {@inheritDoc}
>>>  > -     */
>>>  > -    @Override
>>>  > -    public boolean equals(Object obj) {
>>>  > -        if (obj == this) {
>>>  > -            return true;
>>>  > -        }
>>>  > -        if (!(obj instanceof WhileGenerate<?>)) {
>>>  > -            return false;
>>>  > -        }
>>>  > -        WhileGenerate<?> other = (WhileGenerate<?>) 
> obj;
>>>  > -        return
>>>  other.getWrappedGenerator().equals(getWrappedGenerator())
>>>  > && other.test.equals(test);
>>>  > -    }
>>>  > -
>>>  > -    /**
>>>  > -     * {@inheritDoc}
>>>  > -     */
>>>  > -    @Override
>>>  > -    public int hashCode() {
>>>  > -        int result = "WhileGenerate".hashCode();
>>>  > -        result <<= 2;
>>>  > -        Generator<?> gen = getWrappedGenerator();
>>>  > -        result ^= gen.hashCode();
>>>  > -        result <<= 2;
>>>  > -        result ^= test.hashCode();
>>>  > -        return result;
>>>  > -    }
>>>  > }
>>>  >
>>>  > Modified:
>>>  >
>>> 
> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/range/CharacterRange.java
>>>  > URL:
>>>  >
>>> 
> http://svn.apache.org/viewvc/commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/range/CharacterRange.java?rev=1439683&r1=1439682&r2=1439683&view=diff
>>>  >
>>> 
> ==============================================================================
>>>  > ---
>>>  >
>>> 
> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/range/CharacterRange.java
>>>  > (original)
>>>  > +++
>>>  >
>>> 
> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/range/CharacterRange.java
>>>  > Mon Jan 28 22:49:36 2013
>>>  > @@ -21,7 +21,7 @@ import java.util.Collection;
>>>  >
>>>  > import org.apache.commons.functor.BinaryFunction;
>>>  > import org.apache.commons.functor.UnaryProcedure;
>>>  > -import org.apache.commons.functor.generator.loop.LoopGenerator;
>>>  > +import org.apache.commons.functor.generator.BaseGenerator;
>>>  > import org.apache.commons.lang3.Validate;
>>>  >
>>>  > /**
>>>  > @@ -30,7 +30,7 @@ import org.apache.commons.lang3.Validate
>>>  >   * @since 1.0
>>>  >   * @version $Revision$ $Date$
>>>  >   */
>>>  > -public final class CharacterRange extends 
> LoopGenerator<Character>
>>>  > implements Range<Character, Integer> {
>>>  > +public final class CharacterRange extends 
> BaseGenerator<Character>
>>>  > implements Range<Character, Integer> {
>>>  >
>>>  >      // attributes
>>>  >      // 
> ---------------------------------------------------------------
>>>  >
>>>  > Modified:
>>>  >
>>> 
> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/range/NumericRange.java
>>>  > URL:
>>>  >
>>> 
> http://svn.apache.org/viewvc/commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/range/NumericRange.java?rev=1439683&r1=1439682&r2=1439683&view=diff
>>>  >
>>> 
> ==============================================================================
>>>  > ---
>>>  >
>>> 
> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/range/NumericRange.java
>>>  > (original)
>>>  > +++
>>>  >
>>> 
> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/range/NumericRange.java
>>>  > Mon Jan 28 22:49:36 2013
>>>  > @@ -19,7 +19,7 @@ package org.apache.commons.functor.gener
>>>  >
>>>  > import java.util.Collection;
>>>  >
>>>  > -import org.apache.commons.functor.generator.loop.LoopGenerator;
>>>  > +import org.apache.commons.functor.generator.BaseGenerator;
>>>  > import org.apache.commons.lang3.Validate;
>>>  >
>>>  > /**
>>>  > @@ -35,7 +35,7 @@ import org.apache.commons.lang3.Validate
>>>  >   * @since 0.1
>>>  >   * @version $Revision$ $Date$
>>>  >   */
>>>  > -public abstract class NumericRange<T extends Number &
>>>  > Comparable<T>> extends LoopGenerator<T> implements 
> Range<T,
>>>  > T> {
>>>  > +public abstract class NumericRange<T extends Number &
>>>  > Comparable<T>> extends BaseGenerator<T> implements 
> Range<T,
>>>  > T> {
>>>  >      // attributes
>>>  >      // 
> ---------------------------------------------------------------
>>>  >      /**
>>>  >
>>>  > 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=1439683&r1=1439682&r2=1439683&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
>>>  > Mon Jan 28 22:49:36 2013
>>>  > @@ -31,8 +31,8 @@ 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.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;
>>>  > @@ -116,7 +116,7 @@ public class TestAlgorithms {
>>>  >
>>>  >      @Test
>>>  >      public void testApplyToGenerator() {
>>>  > -        LoopGenerator<Integer> gen = new IntegerRange(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/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=1439683&r1=1439682&r2=1439683&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
>>>  > Mon Jan 28 22:49:36 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.loop.LoopGenerator;
>>>  > +import org.apache.commons.functor.generator.BaseGenerator;
>>>  >
>>>  > /**
>>>  >   * @version $Revision$ $Date$
>>>  >   */
>>>  > -public class Lines extends LoopGenerator<String> {
>>>  > +public class Lines extends BaseGenerator<String> {
>>>  >      public static Lines from(Reader reader) {
>>>  >          return new Lines(reader);
>>>  >      }
>>>  > @@ -55,19 +55,13 @@ public class Lines extends LoopGenerator
>>>  >          } catch(Exception e) {
>>>  >              throw new TunneledException(e);
>>>  >          } finally {
>>>  > -            stop();
>>>  > -        }
>>>  > -    }
>>>  > -
>>>  > -    @Override
>>>  > -    public void stop() {
>>>  > -        super.stop();
>>>  > -        try {
>>>  > -            in.close();
>>>  > -        } catch(RuntimeException e) {
>>>  > -            throw e;
>>>  > -        } catch(Exception e) {
>>>  > -            throw new TunneledException(e);
>>>  > +            try {
>>>  > +                in.close();
>>>  > +            } catch(RuntimeException e) {
>>>  > +                throw e;
>>>  > +            } catch(Exception e) {
>>>  > +                throw new TunneledException(e);
>>>  > +            }
>>>  >          }
>>>  >      }
>>>  >
>>>  >
>>>  > Modified:
>>>  >
>>> 
> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/test/java/org/apache/commons/functor/generator/loop/TestGenerateUntil.java
>>>  > URL:
>>>  >
>>> 
> http://svn.apache.org/viewvc/commons/proper/functor/branches/FUNCTOR-14-mm/core/src/test/java/org/apache/commons/functor/generator/loop/TestGenerateUntil.java?rev=1439683&r1=1439682&r2=1439683&view=diff
>>>  >
>>> 
> ==============================================================================
>>>  > ---
>>>  >
>>> 
> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/test/java/org/apache/commons/functor/generator/loop/TestGenerateUntil.java
>>>  > (original)
>>>  > +++
>>>  >
>>> 
> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/test/java/org/apache/commons/functor/generator/loop/TestGenerateUntil.java
>>>  > Mon Jan 28 22:49:36 2013
>>>  > @@ -40,13 +40,13 @@ public class TestGenerateUntil {
>>>  >      //
>>> 
> ------------------------------------------------------------------------
>>>  >      private static final Integer FIVE = new Integer(5);
>>>  >
>>>  > -    private LoopGenerator<Integer> wrappedGenerator = null;
>>>  > +    private Generator<Integer> wrappedGenerator = null;
>>>  >      private UnaryPredicate<Integer> isMoreThanFive = new
>>>  > UnaryPredicate<Integer>() {
>>>  >          public boolean test( Integer obj ) {
>>>  >              return obj > FIVE;
>>>  >          }
>>>  >      };
>>>  > -    private LoopGenerator<Integer> generateUntil = null;
>>>  > +    private PredicatedGenerator<Integer> generateUntil = 
> null;
>>>  >
>>>  >      @Before
>>>  >      public void setUp() throws Exception {
>>>  >
>>>  > Modified:
>>>  >
>>> 
> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/test/java/org/apache/commons/functor/generator/loop/TestGenerateWhile.java
>>>  > URL:
>>>  >
>>> 
> http://svn.apache.org/viewvc/commons/proper/functor/branches/FUNCTOR-14-mm/core/src/test/java/org/apache/commons/functor/generator/loop/TestGenerateWhile.java?rev=1439683&r1=1439682&r2=1439683&view=diff
>>>  >
>>> 
> ==============================================================================
>>>  > ---
>>>  >
>>> 
> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/test/java/org/apache/commons/functor/generator/loop/TestGenerateWhile.java
>>>  > (original)
>>>  > +++
>>>  >
>>> 
> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/test/java/org/apache/commons/functor/generator/loop/TestGenerateWhile.java
>>>  > Mon Jan 28 22:49:36 2013
>>>  > @@ -40,13 +40,13 @@ public class TestGenerateWhile {
>>>  >      //
>>> 
> ------------------------------------------------------------------------
>>>  >      private static final Integer FIVE = new Integer(5);
>>>  >
>>>  > -    private LoopGenerator<Integer> wrappedGenerator = null;
>>>  > +    private Generator<Integer> wrappedGenerator = null;
>>>  >      private UnaryPredicate<Integer> isLessThanFive = new
>>>  > UnaryPredicate<Integer>() {
>>>  >          public boolean test( Integer obj ) {
>>>  >              return obj < FIVE;
>>>  >          }
>>>  >      };
>>>  > -    private LoopGenerator<Integer> generateWhile = null;
>>>  > +    private PredicatedGenerator<Integer> generateWhile = 
> null;
>>>  >
>>>  >      @Before
>>>  >      public void setUp() throws Exception {
>>>  >
>>>  > Modified:
>>>  >
>>> 
> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/test/java/org/apache/commons/functor/generator/loop/TestTransformedGenerator.java
>>>  > URL:
>>>  >
>>> 
> http://svn.apache.org/viewvc/commons/proper/functor/branches/FUNCTOR-14-mm/core/src/test/java/org/apache/commons/functor/generator/loop/TestTransformedGenerator.java?rev=1439683&r1=1439682&r2=1439683&view=diff
>>>  >
>>> 
> ==============================================================================
>>>  > ---
>>>  >
>>> 
> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/test/java/org/apache/commons/functor/generator/loop/TestTransformedGenerator.java
>>>  > (original)
>>>  > +++
>>>  >
>>> 
> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/test/java/org/apache/commons/functor/generator/loop/TestTransformedGenerator.java
>>>  > Mon Jan 28 22:49:36 2013
>>>  > @@ -22,6 +22,7 @@ import java.util.List;
>>>  >
>>>  > import org.apache.commons.functor.UnaryFunction;
>>>  > import org.apache.commons.functor.UnaryProcedure;
>>>  > +import org.apache.commons.functor.generator.Generator;
>>>  > import org.apache.commons.functor.generator.range.IntegerRange;
>>>  > import org.junit.After;
>>>  > import org.junit.Before;
>>>  > @@ -36,7 +37,7 @@ public class TestTransformedGenerator {
>>>  >      //
>>> 
> ------------------------------------------------------------------------
>>>  >      private static final Integer TWO = new Integer(2);
>>>  >
>>>  > -    private LoopGenerator<Integer> wrappedGenerator = null;
>>>  > +    private Generator<Integer> wrappedGenerator = null;
>>>  >      private UnaryFunction<Integer, Integer> sumsTwo = new
>>>  > UnaryFunction<Integer, Integer>() {
>>>  >          public Integer evaluate( Integer obj ) {
>>>  >              return obj += TWO;
>>>  >
>>>  > Modified:
>>>  >
>>> 
> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/test/java/org/apache/commons/functor/generator/loop/TestUntilGenerate.java
>>>  > URL:
>>>  >
>>> 
> http://svn.apache.org/viewvc/commons/proper/functor/branches/FUNCTOR-14-mm/core/src/test/java/org/apache/commons/functor/generator/loop/TestUntilGenerate.java?rev=1439683&r1=1439682&r2=1439683&view=diff
>>>  >
>>> 
> ==============================================================================
>>>  > ---
>>>  >
>>> 
> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/test/java/org/apache/commons/functor/generator/loop/TestUntilGenerate.java
>>>  > (original)
>>>  > +++
>>>  >
>>> 
> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/test/java/org/apache/commons/functor/generator/loop/TestUntilGenerate.java
>>>  > Mon Jan 28 22:49:36 2013
>>>  > @@ -40,13 +40,13 @@ public class TestUntilGenerate {
>>>  >      //
>>> 
> ------------------------------------------------------------------------
>>>  >      private static final Integer FIVE = new Integer(5);
>>>  >
>>>  > -    private LoopGenerator<Integer> wrappedGenerator = null;
>>>  > +    private Generator<Integer> wrappedGenerator = null;
>>>  >      private UnaryPredicate<Integer> isGreaterThanFive = new
>>>  > UnaryPredicate<Integer>() {
>>>  >          public boolean test(Integer obj) {
>>>  >              return obj > FIVE;
>>>  >          }
>>>  >      };
>>>  > -    private LoopGenerator<Integer> untilGenerate = null;
>>>  > +    private PredicatedGenerator<Integer> untilGenerate = 
> null;
>>>  >
>>>  >      @Before
>>>  >      public void setUp() throws Exception {
>>>  >
>>>  > Modified:
>>>  >
>>> 
> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/test/java/org/apache/commons/functor/generator/loop/TestWhileGenerate.java
>>>  > URL:
>>>  >
>>> 
> http://svn.apache.org/viewvc/commons/proper/functor/branches/FUNCTOR-14-mm/core/src/test/java/org/apache/commons/functor/generator/loop/TestWhileGenerate.java?rev=1439683&r1=1439682&r2=1439683&view=diff
>>>  >
>>> 
> ==============================================================================
>>>  > ---
>>>  >
>>> 
> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/test/java/org/apache/commons/functor/generator/loop/TestWhileGenerate.java
>>>  > (original)
>>>  > +++
>>>  >
>>> 
> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/test/java/org/apache/commons/functor/generator/loop/TestWhileGenerate.java
>>>  > Mon Jan 28 22:49:36 2013
>>>  > @@ -42,13 +42,13 @@ public class TestWhileGenerate {
>>>  >      //
>>> 
> ------------------------------------------------------------------------
>>>  >      private static final Integer FIVE = new Integer(5);
>>>  >
>>>  > -    private LoopGenerator<Integer> wrappedGenerator = null;
>>>  > +    private Generator<Integer> wrappedGenerator = null;
>>>  >      private UnaryPredicate<Integer> isLessThanFive = new
>>>  > UnaryPredicate<Integer>() {
>>>  >          public boolean test( Integer obj ) {
>>>  >              return obj < FIVE;
>>>  >          }
>>>  >      };
>>>  > -    private LoopGenerator<Integer> whileGenerate = null;
>>>  > +    private PredicatedGenerator<Integer> whileGenerate = 
> null;
>>>  >
>>>  >      @Before
>>>  >      public void setUp() throws Exception {
>>>  >
>>> 
>>>  ---------------------------------------------------------------------
>>>  To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
>>>  For additional commands, e-mail: dev-help@commons.apache.org
>>> 
>>> 
>> 
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org


Re: svn commit: r1439683 - in /commons/proper/functor/branches/FUNCTOR-14-mm/core/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/org/a...

Posted by Matt Benson <gu...@gmail.com>.
Hmm, I'm struggling with the package name.  oacf.generator.flow?  I wonder
if we should just merge this package back into oacf.generator.

Matt


On Mon, Jan 28, 2013 at 8:15 PM, Matt Benson <gu...@gmail.com> wrote:

> I think so, yes.  :)  Knew there was something I forgot!
>
> Matt
>
>
> On Mon, Jan 28, 2013 at 7:23 PM, Bruno P. Kinoshita <
> brunodepaulak@yahoo.com.br> wrote:
>
>> Thanks Matt! The name is more intuitive now. What about the package name?
>> Should we rename it as well?
>>
>> Cheers,
>>
>> Bruno P. Kinoshita
>> http://kinoshita.eti.br
>> http://tupilabs.com
>>
>>
>> ----- Original Message -----
>> > From: "mbenson@apache.org" <mb...@apache.org>
>> > To: commits@commons.apache.org
>> > Cc:
>> > Sent: Monday, January 28, 2013 8:49 PM
>> > Subject: svn commit: r1439683 - in
>> /commons/proper/functor/branches/FUNCTOR-14-mm/core/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/org/a...
>> >
>> > Author: mbenson
>> > Date: Mon Jan 28 22:49:36 2013
>> > New Revision: 1439683
>> >
>> > URL: http://svn.apache.org/viewvc?rev=1439683&view=rev
>> > Log:
>> > refactor LoopGenerator to PredicatedGenerator
>> >
>> > Added:
>> >
>> >
>> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/loop/PredicatedGenerator.java
>> >       - copied, changed from r1439123,
>> >
>> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/loop/LoopGenerator.java
>> > Removed:
>> >
>> >
>> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/loop/LoopGenerator.java
>> >
>> >
>> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/test/java/org/apache/commons/functor/generator/loop/TestLoopGenerator.java
>> > Modified:
>> >
>> >
>> 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/loop/GenerateUntil.java
>> >
>> >
>> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/loop/GenerateWhile.java
>> >
>> >
>> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/loop/IteratorToGeneratorAdapter.java
>> >
>> >
>> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/loop/TransformedGenerator.java
>> >
>> >
>> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/loop/UntilGenerate.java
>> >
>> >
>> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/loop/WhileGenerate.java
>> >
>> >
>> commons/proper/functor/branches/FUNCTOR-14-mm/core/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/NumericRange.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/example/lines/Lines.java
>> >
>> >
>> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/test/java/org/apache/commons/functor/generator/loop/TestGenerateUntil.java
>> >
>> >
>> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/test/java/org/apache/commons/functor/generator/loop/TestGenerateWhile.java
>> >
>> >
>> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/test/java/org/apache/commons/functor/generator/loop/TestTransformedGenerator.java
>> >
>> >
>> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/test/java/org/apache/commons/functor/generator/loop/TestUntilGenerate.java
>> >
>> >
>> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/test/java/org/apache/commons/functor/generator/loop/TestWhileGenerate.java
>> >
>> > 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=1439683&r1=1439682&r2=1439683&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
>> > Mon Jan 28 22:49:36 2013
>> > @@ -21,17 +21,19 @@ 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.loop.LoopGenerator;
>> > +import org.apache.commons.functor.generator.Generator;
>> > +import org.apache.commons.functor.generator.loop.PredicatedGenerator;
>> > +import org.apache.commons.functor.generator.loop.UntilGenerate;
>> >
>> > /**
>> > - * Return the index of the first Object in a {@link LoopGenerator}
>> matching a
>> > + * Return the index of the first Object in a {@link
>> PredicatedGenerator}
>> > 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<LoopGenerator<? extends T>,
>> > UnaryPredicate<? super T>, Number>, Serializable {
>> > +    implements BinaryFunction<Generator<? extends T>,
>> > UnaryPredicate<? super T>, Number>, Serializable {
>> >      /**
>> >       * serialVersionUID declaration.
>> >       */
>> > @@ -48,42 +50,14 @@ public final class IndexOfInGenerator<T>
>> >       */
>> >      private static class IndexProcedure<T> implements
>> > UnaryProcedure<T> {
>> >          /**
>> > -         * The wrapped generator.
>> > -         */
>> > -        private final LoopGenerator<? extends T> generator;
>> > -        /**
>> > -         * The wrapped predicate.
>> > -         */
>> > -        private final UnaryPredicate<? super T> pred;
>> > -        /**
>> > -         * The number of iterations needed before the wrapped
>> predicate found
>> > the target,
>> > -         * {@code -1} means the target was not found.
>> > -         */
>> > -        private long index = -1L;
>> > -        /**
>> >           * A local accumulator to increment the number of attempts.
>> >           */
>> >          private long current = 0L;
>> >
>> >          /**
>> > -         * Create a new IndexProcedure.
>> > -         *
>> > -         * @param generator The wrapped generator
>> > -         * @param pred The wrapped predicate
>> > -         */
>> > -        IndexProcedure(LoopGenerator<? extends T> generator,
>> > UnaryPredicate<? super T> pred) {
>> > -            this.generator = generator;
>> > -            this.pred = pred;
>> > -        }
>> > -
>> > -        /**
>> >           * {@inheritDoc}
>> >           */
>> >          public void run(T obj) {
>> > -            if (index < 0 && pred.test(obj)) {
>> > -                index = current;
>> > -                generator.stop();
>> > -            }
>> >              current++;
>> >          }
>> >      }
>> > @@ -93,10 +67,10 @@ public final class IndexOfInGenerator<T>
>> >       * @param left Generator
>> >       * @param right UnaryPredicate
>> >       */
>> > -    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);
>> > +    public Number evaluate(Generator<? extends T> left,
>> > UnaryPredicate<? super T> right) {
>> > +        final IndexProcedure<T> findProcedure = new
>> > IndexProcedure<T>();
>> > +        new UntilGenerate<T>(right, left).run(findProcedure);
>> > +        return Long.valueOf(findProcedure.current);
>> >      }
>> >
>> >      /**
>> >
>> > 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=1439683&r1=1439682&r2=1439683&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
>> > Mon Jan 28 22:49:36 2013
>> > @@ -29,8 +29,10 @@ import org.apache.commons.functor.genera
>> >   */
>> > public abstract class BaseGenerator<E> implements Generator<E> {
>> >
>> > -    /** Create a new generator. */
>> > -    public BaseGenerator() {
>> > +    /**
>> > +     * Create a new BaseGenerator instance.
>> > +     */
>> > +    protected BaseGenerator() {
>> >          super();
>> >      }
>> >
>> >
>> > Modified:
>> >
>> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/loop/GenerateUntil.java
>> > URL:
>> >
>> http://svn.apache.org/viewvc/commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/loop/GenerateUntil.java?rev=1439683&r1=1439682&r2=1439683&view=diff
>> >
>> ==============================================================================
>> > ---
>> >
>> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/loop/GenerateUntil.java
>> > (original)
>> > +++
>> >
>> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/loop/GenerateUntil.java
>> > Mon Jan 28 22:49:36 2013
>> > @@ -18,6 +18,7 @@ package org.apache.commons.functor.gener
>> >
>> > import org.apache.commons.functor.UnaryPredicate;
>> > import org.apache.commons.functor.UnaryProcedure;
>> > +import org.apache.commons.functor.core.composite.UnaryNot;
>> > import org.apache.commons.functor.generator.Generator;
>> > import org.apache.commons.lang3.Validate;
>> >
>> > @@ -28,12 +29,7 @@ import org.apache.commons.lang3.Validate
>> >   * @param <E> the type of elements held in this generator.
>> >   * @version $Revision$ $Date$
>> >   */
>> > -public class GenerateUntil<E> extends LoopGenerator<E> {
>> > -
>> > -    /**
>> > -     * The condition has to verified in order to execute the
>> generation.
>> > -     */
>> > -    private final UnaryPredicate<? super E> test;
>> > +public class GenerateUntil<E> extends PredicatedGenerator<E> {
>> >
>> >      /**
>> >       * Create a new GenerateUntil.
>> > @@ -41,53 +37,8 @@ public class GenerateUntil<E> extends Lo
>> >       * @param test {@link UnaryPredicate}
>> >       */
>> >      public GenerateUntil(Generator<? extends E> wrapped,
>> > UnaryPredicate<? super E> test) {
>> > -        super(Validate.notNull(wrapped, "Generator argument was
>> > null"));
>> > -        this.test = Validate.notNull(test, "UnaryPredicate argument was
>> > null");
>> > -    }
>> > -
>> > -    /**
>> > -     * {@inheritDoc}
>> > -     */
>> > -    public void run(final UnaryProcedure<? super E> proc) {
>> > -        getWrappedGenerator().run(new UnaryProcedure<E>() {
>> > -            public void run(E obj) {
>> > -                if (isStopped()) {
>> > -                    return;
>> > -                }
>> > -                proc.run(obj);
>> > -                if (test.test(obj)) {
>> > -                    stop();
>> > -                }
>> > -            }
>> > -        });
>> > +        super(Validate.notNull(wrapped, "Generator argument was
>> > null"), UnaryNot.not(Validate.notNull(test,
>> > +            "UnaryPredicate argument was null")),
>> > Behavior.TEST_AFTER);
>> >      }
>> >
>> > -    /**
>> > -     * {@inheritDoc}
>> > -     */
>> > -    @Override
>> > -    public boolean equals(Object obj) {
>> > -        if (obj == this) {
>> > -            return true;
>> > -        }
>> > -        if (!(obj instanceof GenerateUntil<?>)) {
>> > -            return false;
>> > -        }
>> > -        GenerateUntil<?> other = (GenerateUntil<?>) obj;
>> > -        return
>> other.getWrappedGenerator().equals(getWrappedGenerator())
>> > && other.test.equals(test);
>> > -    }
>> > -
>> > -    /**
>> > -     * {@inheritDoc}
>> > -     */
>> > -    @Override
>> > -    public int hashCode() {
>> > -        int result = "GenerateUntil".hashCode();
>> > -        result <<= 2;
>> > -        Generator<?> gen = getWrappedGenerator();
>> > -        result ^= gen.hashCode();
>> > -        result <<= 2;
>> > -        result ^= test.hashCode();
>> > -        return result;
>> > -    }
>> > }
>> >
>> > Modified:
>> >
>> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/loop/GenerateWhile.java
>> > URL:
>> >
>> http://svn.apache.org/viewvc/commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/loop/GenerateWhile.java?rev=1439683&r1=1439682&r2=1439683&view=diff
>> >
>> ==============================================================================
>> > ---
>> >
>> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/loop/GenerateWhile.java
>> > (original)
>> > +++
>> >
>> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/loop/GenerateWhile.java
>> > Mon Jan 28 22:49:36 2013
>> > @@ -28,12 +28,7 @@ import org.apache.commons.lang3.Validate
>> >   * @param <E> the type of elements held in this generator.
>> >   * @version $Revision$ $Date$
>> >   */
>> > -public class GenerateWhile<E> extends LoopGenerator<E> {
>> > -
>> > -    /**
>> > -     * The condition has to verified in order to execute the
>> generation.
>> > -     */
>> > -    private final UnaryPredicate<? super E> test;
>> > +public class GenerateWhile<E> extends PredicatedGenerator<E> {
>> >
>> >      /**
>> >       * Create a new GenerateWhile.
>> > @@ -41,53 +36,8 @@ public class GenerateWhile<E> extends Lo
>> >       * @param test {@link UnaryPredicate}
>> >       */
>> >      public GenerateWhile(Generator<? extends E> wrapped,
>> > UnaryPredicate<? super E> test) {
>> > -        super(Validate.notNull(wrapped, "Generator argument was
>> > null"));
>> > -        this.test = Validate.notNull(test, "UnaryPredicate argument was
>> > null");
>> > -    }
>> > -
>> > -    /**
>> > -     * {@inheritDoc}
>> > -     */
>> > -    public void run(final UnaryProcedure<? super E> proc) {
>> > -        getWrappedGenerator().run(new UnaryProcedure<E>() {
>> > -            public void run(E obj) {
>> > -                if (isStopped()) {
>> > -                    return;
>> > -                }
>> > -                proc.run(obj);
>> > -                if (!test.test(obj)) {
>> > -                    stop();
>> > -                }
>> > -            }
>> > -        });
>> > +        super(Validate.notNull(wrapped, "Generator argument was
>> > null"),
>> > +        Validate.notNull(test, "UnaryPredicate argument was null"),
>> > Behavior.TEST_AFTER);
>> >      }
>> >
>> > -    /**
>> > -     * {@inheritDoc}
>> > -     */
>> > -    @Override
>> > -    public boolean equals(Object obj) {
>> > -        if (obj == this) {
>> > -            return true;
>> > -        }
>> > -        if (!(obj instanceof GenerateWhile<?>)) {
>> > -            return false;
>> > -        }
>> > -        GenerateWhile<?> other = (GenerateWhile<?>) obj;
>> > -        return
>> other.getWrappedGenerator().equals(getWrappedGenerator())
>> > && other.test.equals(test);
>> > -    }
>> > -
>> > -    /**
>> > -     * {@inheritDoc}
>> > -     */
>> > -    @Override
>> > -    public int hashCode() {
>> > -        int result = "GenerateWhile".hashCode();
>> > -        result <<= 2;
>> > -        Generator<?> gen = getWrappedGenerator();
>> > -        result ^= gen.hashCode();
>> > -        result <<= 2;
>> > -        result ^= test.hashCode();
>> > -        return result;
>> > -    }
>> > }
>> >
>> > Modified:
>> >
>> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/loop/IteratorToGeneratorAdapter.java
>> > URL:
>> >
>> http://svn.apache.org/viewvc/commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/loop/IteratorToGeneratorAdapter.java?rev=1439683&r1=1439682&r2=1439683&view=diff
>> >
>> ==============================================================================
>> > ---
>> >
>> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/loop/IteratorToGeneratorAdapter.java
>> > (original)
>> > +++
>> >
>> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/loop/IteratorToGeneratorAdapter.java
>> > Mon Jan 28 22:49:36 2013
>> > @@ -14,19 +14,23 @@
>> >
>> > package org.apache.commons.functor.generator.loop;
>> >
>> > +import java.util.Collection;
>> > import java.util.Iterator;
>> >
>> > +import org.apache.commons.functor.UnaryFunction;
>> > import org.apache.commons.functor.UnaryProcedure;
>> > +import org.apache.commons.functor.generator.BaseGenerator;
>> > +import org.apache.commons.functor.generator.Generator;
>> > import org.apache.commons.lang3.Validate;
>> >
>> > /**
>> > - * Adapts an {@link Iterator} to the {@link LoopGenerator} interface.
>> > + * Adapts an {@link Iterator} to the {@link PredicatedGenerator}
>> interface.
>> >   *
>> >   * @param <E> the type of elements held in this generator.
>> >   * @since 1.0
>> >   * @version $Revision$ $Date$
>> >   */
>> > -public final class IteratorToGeneratorAdapter<E> extends
>> > LoopGenerator<E> {
>> > +public final class IteratorToGeneratorAdapter<E> extends
>> > BaseGenerator<E> {
>> >      // instance variables
>> >      //-----------------------------------------------------
>> >
>> > @@ -53,9 +57,6 @@ public final class IteratorToGeneratorAd
>> >      public void run(UnaryProcedure<? super E> proc) {
>> >          while (iter.hasNext()) {
>> >              proc.run(iter.next());
>> > -            if (isStopped()) {
>> > -                break;
>> > -            }
>> >          }
>> >      }
>> >
>> >
>> > Copied:
>> >
>> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/loop/PredicatedGenerator.java
>> > (from r1439123,
>> >
>> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/loop/LoopGenerator.java)
>> > URL:
>> >
>> http://svn.apache.org/viewvc/commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/loop/PredicatedGenerator.java?p2=commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/loop/PredicatedGenerator.java&p1=commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/loop/LoopGenerator.java&r1=1439123&r2=1439683&rev=1439683&view=diff
>> >
>> ==============================================================================
>> > ---
>> >
>> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/loop/LoopGenerator.java
>> > (original)
>> > +++
>> >
>> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/loop/PredicatedGenerator.java
>> > Mon Jan 28 22:49:36 2013
>> > @@ -14,6 +14,8 @@
>> >
>> > package org.apache.commons.functor.generator.loop;
>> >
>> > +import org.apache.commons.functor.UnaryPredicate;
>> > +import org.apache.commons.functor.UnaryProcedure;
>> > import org.apache.commons.functor.generator.BaseGenerator;
>> > import org.apache.commons.functor.generator.Generator;
>> >
>> > @@ -25,27 +27,29 @@ import org.apache.commons.functor.genera
>> >   * @since 1.0
>> >   * @version $Revision:$ $Date:$
>> >   */
>> > -public abstract class LoopGenerator<E> extends BaseGenerator<E> {
>> > +public abstract class PredicatedGenerator<E> extends
>> > BaseGenerator<E> {
>> > +    public enum Behavior {
>> > +        TEST_BEFORE, TEST_AFTER;
>> > +    }
>> >
>> > -    /** A generator can wrap another generator. */
>> >      private final Generator<? extends E> wrappedGenerator;
>> > +    private final UnaryPredicate<? super E> continuePredicate;
>> > +    private final Behavior behavior;
>> >
>> > -    /** Set to true when the generator is {@link #stop stopped}. */
>> > +    /** 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
>> > +     * Create a new PredicatedGenerator instance.
>> > +     * @param wrappedGenerator
>> > +     * @param continuePredicate
>> > +     * @param behavior
>> >       */
>> > -    public LoopGenerator(Generator<? extends E> generator) {
>> > -        this.wrappedGenerator = generator;
>> > +    protected PredicatedGenerator(Generator<? extends E>
>> > wrappedGenerator, UnaryPredicate<? super E> continuePredicate, Behavior
>> > behavior) {
>> > +        super();
>> > +        this.wrappedGenerator = wrappedGenerator;
>> > +        this.continuePredicate = continuePredicate;
>> > +        this.behavior = behavior;
>> >      }
>> >
>> >      /**
>> > @@ -58,21 +62,58 @@ public abstract class LoopGenerator<E> e
>> >
>> >      /**
>> >       * {@inheritDoc}
>> > -     * Stop the generator. Will stop the wrapped generator if one was
>> set.
>> >       */
>> > -    public void stop() {
>> > -        if (wrappedGenerator != null && wrappedGenerator instanceof
>> > LoopGenerator<?>) {
>> > -            ((LoopGenerator<?>) wrappedGenerator).stop();
>> > +    public void run(final UnaryProcedure<? super E> proc) {
>> > +        wrappedGenerator.run(new UnaryProcedure<E>() {
>> > +            public void run(E obj) {
>> > +                if (stopped) {
>> > +                    return;
>> > +                }
>> > +                if (behavior == Behavior.TEST_BEFORE &&
>> > !continuePredicate.test(obj)) {
>> > +                    stop();
>> > +                    return;
>> > +                }
>> > +                proc.run(obj);
>> > +                if (behavior == Behavior.TEST_AFTER &&
>> > !continuePredicate.test(obj)) {
>> > +                    stop();
>> > +                }
>> > +            }
>> > +        });
>> > +    }
>> > +    /**
>> > +     * {@inheritDoc}
>> > +     */
>> > +    @Override
>> > +    public boolean equals(Object obj) {
>> > +        if (obj == this) {
>> > +            return true;
>> >          }
>> > -        stopped = true;
>> > +        if (!(obj instanceof PredicatedGenerator<?>)) {
>> > +            return false;
>> > +        }
>> > +        PredicatedGenerator<?> other = (PredicatedGenerator<?>)
>> > obj;
>> > +        return
>> other.getWrappedGenerator().equals(getWrappedGenerator())
>> > +            && other.continuePredicate.equals(continuePredicate)
>> > && other.behavior == behavior;
>> >      }
>> >
>> >      /**
>> >       * {@inheritDoc}
>> > -     * Check if the generator is stopped.
>> >       */
>> > -    public boolean isStopped() {
>> > -        return stopped;
>> > +    @Override
>> > +    public int hashCode() {
>> > +        int result = getClass().getSimpleName().hashCode();
>> > +        result <<= 2;
>> > +        Generator<?> gen = getWrappedGenerator();
>> > +        result ^= gen.hashCode();
>> > +        result <<= 2;
>> > +        result ^= continuePredicate.hashCode();
>> > +        result <<= 2;
>> > +        result ^= behavior.ordinal();
>> > +        return result;
>> > +    }
>> > +
>> > +    private void stop() {
>> > +        stopped = true;
>> >      }
>> >
>> > }
>> >
>> > Modified:
>> >
>> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/loop/TransformedGenerator.java
>> > URL:
>> >
>> http://svn.apache.org/viewvc/commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/loop/TransformedGenerator.java?rev=1439683&r1=1439682&r2=1439683&view=diff
>> >
>> ==============================================================================
>> > ---
>> >
>> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/loop/TransformedGenerator.java
>> > (original)
>> > +++
>> >
>> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/loop/TransformedGenerator.java
>> > Mon Jan 28 22:49:36 2013
>> > @@ -18,6 +18,7 @@ package org.apache.commons.functor.gener
>> >
>> > import org.apache.commons.functor.UnaryFunction;
>> > import org.apache.commons.functor.UnaryProcedure;
>> > +import org.apache.commons.functor.generator.BaseGenerator;
>> > import org.apache.commons.functor.generator.Generator;
>> > import org.apache.commons.lang3.Validate;
>> >
>> > @@ -28,34 +29,34 @@ import org.apache.commons.lang3.Validate
>> >   * @param <E> the type of elements held in this generator.
>> >   * @version $Revision$ $Date$
>> >   */
>> > -public class TransformedGenerator<I, E> extends LoopGenerator<E> {
>> > +public class TransformedGenerator<I, E> extends BaseGenerator<E> {
>> > +
>> > +    /**
>> > +     * The wrapped/<em>I</em>nput generator.
>> > +     */
>> > +    private final Generator<? extends I> wrappedGenerator;
>> >
>> >      /**
>> >       * The UnaryFunction to apply to each element.
>> >       */
>> >      private final UnaryFunction<? super I, ? extends E> func;
>> >
>> > -    // 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.
>> >      /**
>> >       * Create a new TransformedGenerator.
>> >       * @param wrapped Generator to transform
>> >       * @param func UnaryFunction to apply to each element
>> >       */
>> > -    @SuppressWarnings("unchecked")
>> >      public TransformedGenerator(Generator<? extends I> wrapped,
>> > UnaryFunction<? super I, ? extends E> func) {
>> > -        super((Generator<? extends E>) Validate.notNull(wrapped,
>> > "Generator argument was null"));
>> > +        this.wrappedGenerator =
>> > +        Validate.notNull(wrapped, "Generator argument was null");
>> >          this.func = Validate.notNull(func, "UnaryFunction argument was
>> > null");
>> >      }
>> >
>> >      /**
>> >       * {@inheritDoc}
>> >       */
>> > -    @SuppressWarnings("unchecked")
>> >      public void run(final UnaryProcedure<? super E> proc) {
>> > -        ((Generator<? extends I>) getWrappedGenerator()).run(new
>> > UnaryProcedure<I>() {
>> > +        wrappedGenerator.run(new UnaryProcedure<I>() {
>> >              public void run(I obj) {
>> >                  proc.run(func.evaluate(obj));
>> >              }
>> > @@ -74,7 +75,7 @@ public class TransformedGenerator<I, E>
>> >              return false;
>> >          }
>> >          TransformedGenerator<?, ?> other = (TransformedGenerator<?,
>> > ?>) obj;
>> > -        return
>> other.getWrappedGenerator().equals(getWrappedGenerator())
>> > && other.func == func;
>> > +        return other.wrappedGenerator.equals(wrappedGenerator) &&
>> > other.func.equals(func);
>> >      }
>> >
>> >      /**
>> > @@ -84,7 +85,7 @@ public class TransformedGenerator<I, E>
>> >      public int hashCode() {
>> >          int result = "TransformedGenerator".hashCode();
>> >          result <<= 2;
>> > -        Generator<?> gen = getWrappedGenerator();
>> > +        Generator<?> gen = wrappedGenerator;
>> >          result ^= gen.hashCode();
>> >          result <<= 2;
>> >          result ^= func.hashCode();
>> >
>> > Modified:
>> >
>> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/loop/UntilGenerate.java
>> > URL:
>> >
>> http://svn.apache.org/viewvc/commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/loop/UntilGenerate.java?rev=1439683&r1=1439682&r2=1439683&view=diff
>> >
>> ==============================================================================
>> > ---
>> >
>> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/loop/UntilGenerate.java
>> > (original)
>> > +++
>> >
>> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/loop/UntilGenerate.java
>> > Mon Jan 28 22:49:36 2013
>> > @@ -18,6 +18,7 @@ package org.apache.commons.functor.gener
>> >
>> > import org.apache.commons.functor.UnaryPredicate;
>> > import org.apache.commons.functor.UnaryProcedure;
>> > +import org.apache.commons.functor.core.composite.UnaryNot;
>> > import org.apache.commons.functor.generator.Generator;
>> > import org.apache.commons.lang3.Validate;
>> >
>> > @@ -28,12 +29,7 @@ import org.apache.commons.lang3.Validate
>> >   * @param <E> the type of elements held in this generator.
>> >   * @version $Revision$ $Date$
>> >   */
>> > -public class UntilGenerate<E> extends LoopGenerator<E> {
>> > -
>> > -    /**
>> > -     * The condition has to verified in order to execute the
>> generation.
>> > -     */
>> > -    private final UnaryPredicate<? super E> test;
>> > +public class UntilGenerate<E> extends PredicatedGenerator<E> {
>> >
>> >      /**
>> >       * Create a new UntilGenerate.
>> > @@ -41,54 +37,8 @@ public class UntilGenerate<E> extends Lo
>> >       * @param test {@link UnaryPredicate}
>> >       */
>> >      public UntilGenerate(UnaryPredicate<? super E> test, Generator<?
>> > extends E> wrapped) {
>> > -        super(Validate.notNull(wrapped, "Generator argument was
>> > null"));
>> > -        this.test = Validate.notNull(test, "UnaryPredicate argument was
>> > null");
>> > -    }
>> > -
>> > -    /**
>> > -     * {@inheritDoc}
>> > -     */
>> > -    public void run(final UnaryProcedure<? super E> proc) {
>> > -        getWrappedGenerator().run(new UnaryProcedure<E>() {
>> > -            public void run(E obj) {
>> > -                if (isStopped()) {
>> > -                    return;
>> > -                }
>> > -                if (test.test(obj)) {
>> > -                    stop();
>> > -                } else {
>> > -                    proc.run(obj);
>> > -                }
>> > -            }
>> > -        });
>> > +        super(Validate.notNull(wrapped, "Generator argument was
>> > null"), UnaryNot.not(Validate.notNull(test,
>> > +            "UnaryPredicate argument was null")),
>> > Behavior.TEST_BEFORE);
>> >      }
>> >
>> > -    /**
>> > -     * {@inheritDoc}
>> > -     */
>> > -    @Override
>> > -    public boolean equals(Object obj) {
>> > -        if (obj == this) {
>> > -            return true;
>> > -        }
>> > -        if (!(obj instanceof UntilGenerate<?>)) {
>> > -            return false;
>> > -        }
>> > -        UntilGenerate<?> other = (UntilGenerate<?>) obj;
>> > -        return
>> other.getWrappedGenerator().equals(getWrappedGenerator())
>> > && other.test.equals(test);
>> > -    }
>> > -
>> > -    /**
>> > -     * {@inheritDoc}
>> > -     */
>> > -    @Override
>> > -    public int hashCode() {
>> > -        int result = "UntilGenerate".hashCode();
>> > -        result <<= 2;
>> > -        Generator<?> gen = getWrappedGenerator();
>> > -        result ^= gen.hashCode();
>> > -        result <<= 2;
>> > -        result ^= test.hashCode();
>> > -        return result;
>> > -    }
>> > }
>> >
>> > Modified:
>> >
>> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/loop/WhileGenerate.java
>> > URL:
>> >
>> http://svn.apache.org/viewvc/commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/loop/WhileGenerate.java?rev=1439683&r1=1439682&r2=1439683&view=diff
>> >
>> ==============================================================================
>> > ---
>> >
>> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/loop/WhileGenerate.java
>> > (original)
>> > +++
>> >
>> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/loop/WhileGenerate.java
>> > Mon Jan 28 22:49:36 2013
>> > @@ -28,12 +28,7 @@ import org.apache.commons.lang3.Validate
>> >   * @param <E> the type of elements held in this generator.
>> >   * @version $Revision$ $Date$
>> >   */
>> > -public class WhileGenerate<E> extends LoopGenerator<E> {
>> > -
>> > -    /**
>> > -     * The condition has to verified in order to execute the
>> generation.
>> > -     */
>> > -    private final UnaryPredicate<? super E> test;
>> > +public class WhileGenerate<E> extends PredicatedGenerator<E> {
>> >
>> >      /**
>> >       * Create a new WhileGenerate.
>> > @@ -41,54 +36,8 @@ public class WhileGenerate<E> extends Lo
>> >       * @param wrapped {@link Generator}
>> >       */
>> >      public WhileGenerate(UnaryPredicate<? super E> test, Generator<?
>> > extends E> wrapped) {
>> > -        super(Validate.notNull(wrapped, "Generator argument was
>> > null"));
>> > -        this.test = Validate.notNull(test, "UnaryPredicate argument was
>> > null");
>> > -    }
>> > -
>> > -    /**
>> > -     * {@inheritDoc}
>> > -     */
>> > -    public void run(final UnaryProcedure<? super E> proc) {
>> > -        getWrappedGenerator().run(new UnaryProcedure<E>() {
>> > -            public void run(E obj) {
>> > -                if (isStopped()) {
>> > -                    return;
>> > -                }
>> > -                if (!test.test(obj)) {
>> > -                    stop();
>> > -                } else {
>> > -                    proc.run(obj);
>> > -                }
>> > -            }
>> > -        });
>> > +        super(Validate.notNull(wrapped, "Generator argument was
>> > null"), Validate.notNull(test,
>> > +            "UnaryPredicate argument was null"),
>> > Behavior.TEST_BEFORE);
>> >      }
>> >
>> > -    /**
>> > -     * {@inheritDoc}
>> > -     */
>> > -    @Override
>> > -    public boolean equals(Object obj) {
>> > -        if (obj == this) {
>> > -            return true;
>> > -        }
>> > -        if (!(obj instanceof WhileGenerate<?>)) {
>> > -            return false;
>> > -        }
>> > -        WhileGenerate<?> other = (WhileGenerate<?>) obj;
>> > -        return
>> other.getWrappedGenerator().equals(getWrappedGenerator())
>> > && other.test.equals(test);
>> > -    }
>> > -
>> > -    /**
>> > -     * {@inheritDoc}
>> > -     */
>> > -    @Override
>> > -    public int hashCode() {
>> > -        int result = "WhileGenerate".hashCode();
>> > -        result <<= 2;
>> > -        Generator<?> gen = getWrappedGenerator();
>> > -        result ^= gen.hashCode();
>> > -        result <<= 2;
>> > -        result ^= test.hashCode();
>> > -        return result;
>> > -    }
>> > }
>> >
>> > Modified:
>> >
>> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/range/CharacterRange.java
>> > URL:
>> >
>> http://svn.apache.org/viewvc/commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/range/CharacterRange.java?rev=1439683&r1=1439682&r2=1439683&view=diff
>> >
>> ==============================================================================
>> > ---
>> >
>> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/range/CharacterRange.java
>> > (original)
>> > +++
>> >
>> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/range/CharacterRange.java
>> > Mon Jan 28 22:49:36 2013
>> > @@ -21,7 +21,7 @@ import java.util.Collection;
>> >
>> > import org.apache.commons.functor.BinaryFunction;
>> > import org.apache.commons.functor.UnaryProcedure;
>> > -import org.apache.commons.functor.generator.loop.LoopGenerator;
>> > +import org.apache.commons.functor.generator.BaseGenerator;
>> > import org.apache.commons.lang3.Validate;
>> >
>> > /**
>> > @@ -30,7 +30,7 @@ import org.apache.commons.lang3.Validate
>> >   * @since 1.0
>> >   * @version $Revision$ $Date$
>> >   */
>> > -public final class CharacterRange extends LoopGenerator<Character>
>> > implements Range<Character, Integer> {
>> > +public final class CharacterRange extends BaseGenerator<Character>
>> > implements Range<Character, Integer> {
>> >
>> >      // attributes
>> >      // ---------------------------------------------------------------
>> >
>> > Modified:
>> >
>> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/range/NumericRange.java
>> > URL:
>> >
>> http://svn.apache.org/viewvc/commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/range/NumericRange.java?rev=1439683&r1=1439682&r2=1439683&view=diff
>> >
>> ==============================================================================
>> > ---
>> >
>> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/range/NumericRange.java
>> > (original)
>> > +++
>> >
>> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/range/NumericRange.java
>> > Mon Jan 28 22:49:36 2013
>> > @@ -19,7 +19,7 @@ package org.apache.commons.functor.gener
>> >
>> > import java.util.Collection;
>> >
>> > -import org.apache.commons.functor.generator.loop.LoopGenerator;
>> > +import org.apache.commons.functor.generator.BaseGenerator;
>> > import org.apache.commons.lang3.Validate;
>> >
>> > /**
>> > @@ -35,7 +35,7 @@ import org.apache.commons.lang3.Validate
>> >   * @since 0.1
>> >   * @version $Revision$ $Date$
>> >   */
>> > -public abstract class NumericRange<T extends Number &
>> > Comparable<T>> extends LoopGenerator<T> implements Range<T,
>> > T> {
>> > +public abstract class NumericRange<T extends Number &
>> > Comparable<T>> extends BaseGenerator<T> implements Range<T,
>> > T> {
>> >      // attributes
>> >      // ---------------------------------------------------------------
>> >      /**
>> >
>> > 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=1439683&r1=1439682&r2=1439683&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
>> > Mon Jan 28 22:49:36 2013
>> > @@ -31,8 +31,8 @@ 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.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;
>> > @@ -116,7 +116,7 @@ public class TestAlgorithms {
>> >
>> >      @Test
>> >      public void testApplyToGenerator() {
>> > -        LoopGenerator<Integer> gen = new IntegerRange(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/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=1439683&r1=1439682&r2=1439683&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
>> > Mon Jan 28 22:49:36 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.loop.LoopGenerator;
>> > +import org.apache.commons.functor.generator.BaseGenerator;
>> >
>> > /**
>> >   * @version $Revision$ $Date$
>> >   */
>> > -public class Lines extends LoopGenerator<String> {
>> > +public class Lines extends BaseGenerator<String> {
>> >      public static Lines from(Reader reader) {
>> >          return new Lines(reader);
>> >      }
>> > @@ -55,19 +55,13 @@ public class Lines extends LoopGenerator
>> >          } catch(Exception e) {
>> >              throw new TunneledException(e);
>> >          } finally {
>> > -            stop();
>> > -        }
>> > -    }
>> > -
>> > -    @Override
>> > -    public void stop() {
>> > -        super.stop();
>> > -        try {
>> > -            in.close();
>> > -        } catch(RuntimeException e) {
>> > -            throw e;
>> > -        } catch(Exception e) {
>> > -            throw new TunneledException(e);
>> > +            try {
>> > +                in.close();
>> > +            } catch(RuntimeException e) {
>> > +                throw e;
>> > +            } catch(Exception e) {
>> > +                throw new TunneledException(e);
>> > +            }
>> >          }
>> >      }
>> >
>> >
>> > Modified:
>> >
>> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/test/java/org/apache/commons/functor/generator/loop/TestGenerateUntil.java
>> > URL:
>> >
>> http://svn.apache.org/viewvc/commons/proper/functor/branches/FUNCTOR-14-mm/core/src/test/java/org/apache/commons/functor/generator/loop/TestGenerateUntil.java?rev=1439683&r1=1439682&r2=1439683&view=diff
>> >
>> ==============================================================================
>> > ---
>> >
>> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/test/java/org/apache/commons/functor/generator/loop/TestGenerateUntil.java
>> > (original)
>> > +++
>> >
>> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/test/java/org/apache/commons/functor/generator/loop/TestGenerateUntil.java
>> > Mon Jan 28 22:49:36 2013
>> > @@ -40,13 +40,13 @@ public class TestGenerateUntil {
>> >      //
>> ------------------------------------------------------------------------
>> >      private static final Integer FIVE = new Integer(5);
>> >
>> > -    private LoopGenerator<Integer> wrappedGenerator = null;
>> > +    private Generator<Integer> wrappedGenerator = null;
>> >      private UnaryPredicate<Integer> isMoreThanFive = new
>> > UnaryPredicate<Integer>() {
>> >          public boolean test( Integer obj ) {
>> >              return obj > FIVE;
>> >          }
>> >      };
>> > -    private LoopGenerator<Integer> generateUntil = null;
>> > +    private PredicatedGenerator<Integer> generateUntil = null;
>> >
>> >      @Before
>> >      public void setUp() throws Exception {
>> >
>> > Modified:
>> >
>> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/test/java/org/apache/commons/functor/generator/loop/TestGenerateWhile.java
>> > URL:
>> >
>> http://svn.apache.org/viewvc/commons/proper/functor/branches/FUNCTOR-14-mm/core/src/test/java/org/apache/commons/functor/generator/loop/TestGenerateWhile.java?rev=1439683&r1=1439682&r2=1439683&view=diff
>> >
>> ==============================================================================
>> > ---
>> >
>> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/test/java/org/apache/commons/functor/generator/loop/TestGenerateWhile.java
>> > (original)
>> > +++
>> >
>> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/test/java/org/apache/commons/functor/generator/loop/TestGenerateWhile.java
>> > Mon Jan 28 22:49:36 2013
>> > @@ -40,13 +40,13 @@ public class TestGenerateWhile {
>> >      //
>> ------------------------------------------------------------------------
>> >      private static final Integer FIVE = new Integer(5);
>> >
>> > -    private LoopGenerator<Integer> wrappedGenerator = null;
>> > +    private Generator<Integer> wrappedGenerator = null;
>> >      private UnaryPredicate<Integer> isLessThanFive = new
>> > UnaryPredicate<Integer>() {
>> >          public boolean test( Integer obj ) {
>> >              return obj < FIVE;
>> >          }
>> >      };
>> > -    private LoopGenerator<Integer> generateWhile = null;
>> > +    private PredicatedGenerator<Integer> generateWhile = null;
>> >
>> >      @Before
>> >      public void setUp() throws Exception {
>> >
>> > Modified:
>> >
>> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/test/java/org/apache/commons/functor/generator/loop/TestTransformedGenerator.java
>> > URL:
>> >
>> http://svn.apache.org/viewvc/commons/proper/functor/branches/FUNCTOR-14-mm/core/src/test/java/org/apache/commons/functor/generator/loop/TestTransformedGenerator.java?rev=1439683&r1=1439682&r2=1439683&view=diff
>> >
>> ==============================================================================
>> > ---
>> >
>> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/test/java/org/apache/commons/functor/generator/loop/TestTransformedGenerator.java
>> > (original)
>> > +++
>> >
>> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/test/java/org/apache/commons/functor/generator/loop/TestTransformedGenerator.java
>> > Mon Jan 28 22:49:36 2013
>> > @@ -22,6 +22,7 @@ import java.util.List;
>> >
>> > import org.apache.commons.functor.UnaryFunction;
>> > import org.apache.commons.functor.UnaryProcedure;
>> > +import org.apache.commons.functor.generator.Generator;
>> > import org.apache.commons.functor.generator.range.IntegerRange;
>> > import org.junit.After;
>> > import org.junit.Before;
>> > @@ -36,7 +37,7 @@ public class TestTransformedGenerator {
>> >      //
>> ------------------------------------------------------------------------
>> >      private static final Integer TWO = new Integer(2);
>> >
>> > -    private LoopGenerator<Integer> wrappedGenerator = null;
>> > +    private Generator<Integer> wrappedGenerator = null;
>> >      private UnaryFunction<Integer, Integer> sumsTwo = new
>> > UnaryFunction<Integer, Integer>() {
>> >          public Integer evaluate( Integer obj ) {
>> >              return obj += TWO;
>> >
>> > Modified:
>> >
>> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/test/java/org/apache/commons/functor/generator/loop/TestUntilGenerate.java
>> > URL:
>> >
>> http://svn.apache.org/viewvc/commons/proper/functor/branches/FUNCTOR-14-mm/core/src/test/java/org/apache/commons/functor/generator/loop/TestUntilGenerate.java?rev=1439683&r1=1439682&r2=1439683&view=diff
>> >
>> ==============================================================================
>> > ---
>> >
>> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/test/java/org/apache/commons/functor/generator/loop/TestUntilGenerate.java
>> > (original)
>> > +++
>> >
>> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/test/java/org/apache/commons/functor/generator/loop/TestUntilGenerate.java
>> > Mon Jan 28 22:49:36 2013
>> > @@ -40,13 +40,13 @@ public class TestUntilGenerate {
>> >      //
>> ------------------------------------------------------------------------
>> >      private static final Integer FIVE = new Integer(5);
>> >
>> > -    private LoopGenerator<Integer> wrappedGenerator = null;
>> > +    private Generator<Integer> wrappedGenerator = null;
>> >      private UnaryPredicate<Integer> isGreaterThanFive = new
>> > UnaryPredicate<Integer>() {
>> >          public boolean test(Integer obj) {
>> >              return obj > FIVE;
>> >          }
>> >      };
>> > -    private LoopGenerator<Integer> untilGenerate = null;
>> > +    private PredicatedGenerator<Integer> untilGenerate = null;
>> >
>> >      @Before
>> >      public void setUp() throws Exception {
>> >
>> > Modified:
>> >
>> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/test/java/org/apache/commons/functor/generator/loop/TestWhileGenerate.java
>> > URL:
>> >
>> http://svn.apache.org/viewvc/commons/proper/functor/branches/FUNCTOR-14-mm/core/src/test/java/org/apache/commons/functor/generator/loop/TestWhileGenerate.java?rev=1439683&r1=1439682&r2=1439683&view=diff
>> >
>> ==============================================================================
>> > ---
>> >
>> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/test/java/org/apache/commons/functor/generator/loop/TestWhileGenerate.java
>> > (original)
>> > +++
>> >
>> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/test/java/org/apache/commons/functor/generator/loop/TestWhileGenerate.java
>> > Mon Jan 28 22:49:36 2013
>> > @@ -42,13 +42,13 @@ public class TestWhileGenerate {
>> >      //
>> ------------------------------------------------------------------------
>> >      private static final Integer FIVE = new Integer(5);
>> >
>> > -    private LoopGenerator<Integer> wrappedGenerator = null;
>> > +    private Generator<Integer> wrappedGenerator = null;
>> >      private UnaryPredicate<Integer> isLessThanFive = new
>> > UnaryPredicate<Integer>() {
>> >          public boolean test( Integer obj ) {
>> >              return obj < FIVE;
>> >          }
>> >      };
>> > -    private LoopGenerator<Integer> whileGenerate = null;
>> > +    private PredicatedGenerator<Integer> whileGenerate = null;
>> >
>> >      @Before
>> >      public void setUp() throws Exception {
>> >
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
>> For additional commands, e-mail: dev-help@commons.apache.org
>>
>>
>

Re: svn commit: r1439683 - in /commons/proper/functor/branches/FUNCTOR-14-mm/core/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/org/a...

Posted by Matt Benson <gu...@gmail.com>.
I think so, yes.  :)  Knew there was something I forgot!

Matt


On Mon, Jan 28, 2013 at 7:23 PM, Bruno P. Kinoshita <
brunodepaulak@yahoo.com.br> wrote:

> Thanks Matt! The name is more intuitive now. What about the package name?
> Should we rename it as well?
>
> Cheers,
>
> Bruno P. Kinoshita
> http://kinoshita.eti.br
> http://tupilabs.com
>
>
> ----- Original Message -----
> > From: "mbenson@apache.org" <mb...@apache.org>
> > To: commits@commons.apache.org
> > Cc:
> > Sent: Monday, January 28, 2013 8:49 PM
> > Subject: svn commit: r1439683 - in
> /commons/proper/functor/branches/FUNCTOR-14-mm/core/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/org/a...
> >
> > Author: mbenson
> > Date: Mon Jan 28 22:49:36 2013
> > New Revision: 1439683
> >
> > URL: http://svn.apache.org/viewvc?rev=1439683&view=rev
> > Log:
> > refactor LoopGenerator to PredicatedGenerator
> >
> > Added:
> >
> >
> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/loop/PredicatedGenerator.java
> >       - copied, changed from r1439123,
> >
> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/loop/LoopGenerator.java
> > Removed:
> >
> >
> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/loop/LoopGenerator.java
> >
> >
> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/test/java/org/apache/commons/functor/generator/loop/TestLoopGenerator.java
> > Modified:
> >
> >
> 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/loop/GenerateUntil.java
> >
> >
> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/loop/GenerateWhile.java
> >
> >
> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/loop/IteratorToGeneratorAdapter.java
> >
> >
> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/loop/TransformedGenerator.java
> >
> >
> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/loop/UntilGenerate.java
> >
> >
> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/loop/WhileGenerate.java
> >
> >
> commons/proper/functor/branches/FUNCTOR-14-mm/core/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/NumericRange.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/example/lines/Lines.java
> >
> >
> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/test/java/org/apache/commons/functor/generator/loop/TestGenerateUntil.java
> >
> >
> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/test/java/org/apache/commons/functor/generator/loop/TestGenerateWhile.java
> >
> >
> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/test/java/org/apache/commons/functor/generator/loop/TestTransformedGenerator.java
> >
> >
> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/test/java/org/apache/commons/functor/generator/loop/TestUntilGenerate.java
> >
> >
> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/test/java/org/apache/commons/functor/generator/loop/TestWhileGenerate.java
> >
> > 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=1439683&r1=1439682&r2=1439683&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
> > Mon Jan 28 22:49:36 2013
> > @@ -21,17 +21,19 @@ 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.loop.LoopGenerator;
> > +import org.apache.commons.functor.generator.Generator;
> > +import org.apache.commons.functor.generator.loop.PredicatedGenerator;
> > +import org.apache.commons.functor.generator.loop.UntilGenerate;
> >
> > /**
> > - * Return the index of the first Object in a {@link LoopGenerator}
> matching a
> > + * Return the index of the first Object in a {@link PredicatedGenerator}
> > 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<LoopGenerator<? extends T>,
> > UnaryPredicate<? super T>, Number>, Serializable {
> > +    implements BinaryFunction<Generator<? extends T>,
> > UnaryPredicate<? super T>, Number>, Serializable {
> >      /**
> >       * serialVersionUID declaration.
> >       */
> > @@ -48,42 +50,14 @@ public final class IndexOfInGenerator<T>
> >       */
> >      private static class IndexProcedure<T> implements
> > UnaryProcedure<T> {
> >          /**
> > -         * The wrapped generator.
> > -         */
> > -        private final LoopGenerator<? extends T> generator;
> > -        /**
> > -         * The wrapped predicate.
> > -         */
> > -        private final UnaryPredicate<? super T> pred;
> > -        /**
> > -         * The number of iterations needed before the wrapped predicate
> found
> > the target,
> > -         * {@code -1} means the target was not found.
> > -         */
> > -        private long index = -1L;
> > -        /**
> >           * A local accumulator to increment the number of attempts.
> >           */
> >          private long current = 0L;
> >
> >          /**
> > -         * Create a new IndexProcedure.
> > -         *
> > -         * @param generator The wrapped generator
> > -         * @param pred The wrapped predicate
> > -         */
> > -        IndexProcedure(LoopGenerator<? extends T> generator,
> > UnaryPredicate<? super T> pred) {
> > -            this.generator = generator;
> > -            this.pred = pred;
> > -        }
> > -
> > -        /**
> >           * {@inheritDoc}
> >           */
> >          public void run(T obj) {
> > -            if (index < 0 && pred.test(obj)) {
> > -                index = current;
> > -                generator.stop();
> > -            }
> >              current++;
> >          }
> >      }
> > @@ -93,10 +67,10 @@ public final class IndexOfInGenerator<T>
> >       * @param left Generator
> >       * @param right UnaryPredicate
> >       */
> > -    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);
> > +    public Number evaluate(Generator<? extends T> left,
> > UnaryPredicate<? super T> right) {
> > +        final IndexProcedure<T> findProcedure = new
> > IndexProcedure<T>();
> > +        new UntilGenerate<T>(right, left).run(findProcedure);
> > +        return Long.valueOf(findProcedure.current);
> >      }
> >
> >      /**
> >
> > 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=1439683&r1=1439682&r2=1439683&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
> > Mon Jan 28 22:49:36 2013
> > @@ -29,8 +29,10 @@ import org.apache.commons.functor.genera
> >   */
> > public abstract class BaseGenerator<E> implements Generator<E> {
> >
> > -    /** Create a new generator. */
> > -    public BaseGenerator() {
> > +    /**
> > +     * Create a new BaseGenerator instance.
> > +     */
> > +    protected BaseGenerator() {
> >          super();
> >      }
> >
> >
> > Modified:
> >
> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/loop/GenerateUntil.java
> > URL:
> >
> http://svn.apache.org/viewvc/commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/loop/GenerateUntil.java?rev=1439683&r1=1439682&r2=1439683&view=diff
> >
> ==============================================================================
> > ---
> >
> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/loop/GenerateUntil.java
> > (original)
> > +++
> >
> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/loop/GenerateUntil.java
> > Mon Jan 28 22:49:36 2013
> > @@ -18,6 +18,7 @@ package org.apache.commons.functor.gener
> >
> > import org.apache.commons.functor.UnaryPredicate;
> > import org.apache.commons.functor.UnaryProcedure;
> > +import org.apache.commons.functor.core.composite.UnaryNot;
> > import org.apache.commons.functor.generator.Generator;
> > import org.apache.commons.lang3.Validate;
> >
> > @@ -28,12 +29,7 @@ import org.apache.commons.lang3.Validate
> >   * @param <E> the type of elements held in this generator.
> >   * @version $Revision$ $Date$
> >   */
> > -public class GenerateUntil<E> extends LoopGenerator<E> {
> > -
> > -    /**
> > -     * The condition has to verified in order to execute the generation.
> > -     */
> > -    private final UnaryPredicate<? super E> test;
> > +public class GenerateUntil<E> extends PredicatedGenerator<E> {
> >
> >      /**
> >       * Create a new GenerateUntil.
> > @@ -41,53 +37,8 @@ public class GenerateUntil<E> extends Lo
> >       * @param test {@link UnaryPredicate}
> >       */
> >      public GenerateUntil(Generator<? extends E> wrapped,
> > UnaryPredicate<? super E> test) {
> > -        super(Validate.notNull(wrapped, "Generator argument was
> > null"));
> > -        this.test = Validate.notNull(test, "UnaryPredicate argument was
> > null");
> > -    }
> > -
> > -    /**
> > -     * {@inheritDoc}
> > -     */
> > -    public void run(final UnaryProcedure<? super E> proc) {
> > -        getWrappedGenerator().run(new UnaryProcedure<E>() {
> > -            public void run(E obj) {
> > -                if (isStopped()) {
> > -                    return;
> > -                }
> > -                proc.run(obj);
> > -                if (test.test(obj)) {
> > -                    stop();
> > -                }
> > -            }
> > -        });
> > +        super(Validate.notNull(wrapped, "Generator argument was
> > null"), UnaryNot.not(Validate.notNull(test,
> > +            "UnaryPredicate argument was null")),
> > Behavior.TEST_AFTER);
> >      }
> >
> > -    /**
> > -     * {@inheritDoc}
> > -     */
> > -    @Override
> > -    public boolean equals(Object obj) {
> > -        if (obj == this) {
> > -            return true;
> > -        }
> > -        if (!(obj instanceof GenerateUntil<?>)) {
> > -            return false;
> > -        }
> > -        GenerateUntil<?> other = (GenerateUntil<?>) obj;
> > -        return other.getWrappedGenerator().equals(getWrappedGenerator())
> > && other.test.equals(test);
> > -    }
> > -
> > -    /**
> > -     * {@inheritDoc}
> > -     */
> > -    @Override
> > -    public int hashCode() {
> > -        int result = "GenerateUntil".hashCode();
> > -        result <<= 2;
> > -        Generator<?> gen = getWrappedGenerator();
> > -        result ^= gen.hashCode();
> > -        result <<= 2;
> > -        result ^= test.hashCode();
> > -        return result;
> > -    }
> > }
> >
> > Modified:
> >
> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/loop/GenerateWhile.java
> > URL:
> >
> http://svn.apache.org/viewvc/commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/loop/GenerateWhile.java?rev=1439683&r1=1439682&r2=1439683&view=diff
> >
> ==============================================================================
> > ---
> >
> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/loop/GenerateWhile.java
> > (original)
> > +++
> >
> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/loop/GenerateWhile.java
> > Mon Jan 28 22:49:36 2013
> > @@ -28,12 +28,7 @@ import org.apache.commons.lang3.Validate
> >   * @param <E> the type of elements held in this generator.
> >   * @version $Revision$ $Date$
> >   */
> > -public class GenerateWhile<E> extends LoopGenerator<E> {
> > -
> > -    /**
> > -     * The condition has to verified in order to execute the generation.
> > -     */
> > -    private final UnaryPredicate<? super E> test;
> > +public class GenerateWhile<E> extends PredicatedGenerator<E> {
> >
> >      /**
> >       * Create a new GenerateWhile.
> > @@ -41,53 +36,8 @@ public class GenerateWhile<E> extends Lo
> >       * @param test {@link UnaryPredicate}
> >       */
> >      public GenerateWhile(Generator<? extends E> wrapped,
> > UnaryPredicate<? super E> test) {
> > -        super(Validate.notNull(wrapped, "Generator argument was
> > null"));
> > -        this.test = Validate.notNull(test, "UnaryPredicate argument was
> > null");
> > -    }
> > -
> > -    /**
> > -     * {@inheritDoc}
> > -     */
> > -    public void run(final UnaryProcedure<? super E> proc) {
> > -        getWrappedGenerator().run(new UnaryProcedure<E>() {
> > -            public void run(E obj) {
> > -                if (isStopped()) {
> > -                    return;
> > -                }
> > -                proc.run(obj);
> > -                if (!test.test(obj)) {
> > -                    stop();
> > -                }
> > -            }
> > -        });
> > +        super(Validate.notNull(wrapped, "Generator argument was
> > null"),
> > +        Validate.notNull(test, "UnaryPredicate argument was null"),
> > Behavior.TEST_AFTER);
> >      }
> >
> > -    /**
> > -     * {@inheritDoc}
> > -     */
> > -    @Override
> > -    public boolean equals(Object obj) {
> > -        if (obj == this) {
> > -            return true;
> > -        }
> > -        if (!(obj instanceof GenerateWhile<?>)) {
> > -            return false;
> > -        }
> > -        GenerateWhile<?> other = (GenerateWhile<?>) obj;
> > -        return other.getWrappedGenerator().equals(getWrappedGenerator())
> > && other.test.equals(test);
> > -    }
> > -
> > -    /**
> > -     * {@inheritDoc}
> > -     */
> > -    @Override
> > -    public int hashCode() {
> > -        int result = "GenerateWhile".hashCode();
> > -        result <<= 2;
> > -        Generator<?> gen = getWrappedGenerator();
> > -        result ^= gen.hashCode();
> > -        result <<= 2;
> > -        result ^= test.hashCode();
> > -        return result;
> > -    }
> > }
> >
> > Modified:
> >
> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/loop/IteratorToGeneratorAdapter.java
> > URL:
> >
> http://svn.apache.org/viewvc/commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/loop/IteratorToGeneratorAdapter.java?rev=1439683&r1=1439682&r2=1439683&view=diff
> >
> ==============================================================================
> > ---
> >
> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/loop/IteratorToGeneratorAdapter.java
> > (original)
> > +++
> >
> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/loop/IteratorToGeneratorAdapter.java
> > Mon Jan 28 22:49:36 2013
> > @@ -14,19 +14,23 @@
> >
> > package org.apache.commons.functor.generator.loop;
> >
> > +import java.util.Collection;
> > import java.util.Iterator;
> >
> > +import org.apache.commons.functor.UnaryFunction;
> > import org.apache.commons.functor.UnaryProcedure;
> > +import org.apache.commons.functor.generator.BaseGenerator;
> > +import org.apache.commons.functor.generator.Generator;
> > import org.apache.commons.lang3.Validate;
> >
> > /**
> > - * Adapts an {@link Iterator} to the {@link LoopGenerator} interface.
> > + * Adapts an {@link Iterator} to the {@link PredicatedGenerator}
> interface.
> >   *
> >   * @param <E> the type of elements held in this generator.
> >   * @since 1.0
> >   * @version $Revision$ $Date$
> >   */
> > -public final class IteratorToGeneratorAdapter<E> extends
> > LoopGenerator<E> {
> > +public final class IteratorToGeneratorAdapter<E> extends
> > BaseGenerator<E> {
> >      // instance variables
> >      //-----------------------------------------------------
> >
> > @@ -53,9 +57,6 @@ public final class IteratorToGeneratorAd
> >      public void run(UnaryProcedure<? super E> proc) {
> >          while (iter.hasNext()) {
> >              proc.run(iter.next());
> > -            if (isStopped()) {
> > -                break;
> > -            }
> >          }
> >      }
> >
> >
> > Copied:
> >
> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/loop/PredicatedGenerator.java
> > (from r1439123,
> >
> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/loop/LoopGenerator.java)
> > URL:
> >
> http://svn.apache.org/viewvc/commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/loop/PredicatedGenerator.java?p2=commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/loop/PredicatedGenerator.java&p1=commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/loop/LoopGenerator.java&r1=1439123&r2=1439683&rev=1439683&view=diff
> >
> ==============================================================================
> > ---
> >
> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/loop/LoopGenerator.java
> > (original)
> > +++
> >
> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/loop/PredicatedGenerator.java
> > Mon Jan 28 22:49:36 2013
> > @@ -14,6 +14,8 @@
> >
> > package org.apache.commons.functor.generator.loop;
> >
> > +import org.apache.commons.functor.UnaryPredicate;
> > +import org.apache.commons.functor.UnaryProcedure;
> > import org.apache.commons.functor.generator.BaseGenerator;
> > import org.apache.commons.functor.generator.Generator;
> >
> > @@ -25,27 +27,29 @@ import org.apache.commons.functor.genera
> >   * @since 1.0
> >   * @version $Revision:$ $Date:$
> >   */
> > -public abstract class LoopGenerator<E> extends BaseGenerator<E> {
> > +public abstract class PredicatedGenerator<E> extends
> > BaseGenerator<E> {
> > +    public enum Behavior {
> > +        TEST_BEFORE, TEST_AFTER;
> > +    }
> >
> > -    /** A generator can wrap another generator. */
> >      private final Generator<? extends E> wrappedGenerator;
> > +    private final UnaryPredicate<? super E> continuePredicate;
> > +    private final Behavior behavior;
> >
> > -    /** Set to true when the generator is {@link #stop stopped}. */
> > +    /** 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
> > +     * Create a new PredicatedGenerator instance.
> > +     * @param wrappedGenerator
> > +     * @param continuePredicate
> > +     * @param behavior
> >       */
> > -    public LoopGenerator(Generator<? extends E> generator) {
> > -        this.wrappedGenerator = generator;
> > +    protected PredicatedGenerator(Generator<? extends E>
> > wrappedGenerator, UnaryPredicate<? super E> continuePredicate, Behavior
> > behavior) {
> > +        super();
> > +        this.wrappedGenerator = wrappedGenerator;
> > +        this.continuePredicate = continuePredicate;
> > +        this.behavior = behavior;
> >      }
> >
> >      /**
> > @@ -58,21 +62,58 @@ public abstract class LoopGenerator<E> e
> >
> >      /**
> >       * {@inheritDoc}
> > -     * Stop the generator. Will stop the wrapped generator if one was
> set.
> >       */
> > -    public void stop() {
> > -        if (wrappedGenerator != null && wrappedGenerator instanceof
> > LoopGenerator<?>) {
> > -            ((LoopGenerator<?>) wrappedGenerator).stop();
> > +    public void run(final UnaryProcedure<? super E> proc) {
> > +        wrappedGenerator.run(new UnaryProcedure<E>() {
> > +            public void run(E obj) {
> > +                if (stopped) {
> > +                    return;
> > +                }
> > +                if (behavior == Behavior.TEST_BEFORE &&
> > !continuePredicate.test(obj)) {
> > +                    stop();
> > +                    return;
> > +                }
> > +                proc.run(obj);
> > +                if (behavior == Behavior.TEST_AFTER &&
> > !continuePredicate.test(obj)) {
> > +                    stop();
> > +                }
> > +            }
> > +        });
> > +    }
> > +    /**
> > +     * {@inheritDoc}
> > +     */
> > +    @Override
> > +    public boolean equals(Object obj) {
> > +        if (obj == this) {
> > +            return true;
> >          }
> > -        stopped = true;
> > +        if (!(obj instanceof PredicatedGenerator<?>)) {
> > +            return false;
> > +        }
> > +        PredicatedGenerator<?> other = (PredicatedGenerator<?>)
> > obj;
> > +        return other.getWrappedGenerator().equals(getWrappedGenerator())
> > +            && other.continuePredicate.equals(continuePredicate)
> > && other.behavior == behavior;
> >      }
> >
> >      /**
> >       * {@inheritDoc}
> > -     * Check if the generator is stopped.
> >       */
> > -    public boolean isStopped() {
> > -        return stopped;
> > +    @Override
> > +    public int hashCode() {
> > +        int result = getClass().getSimpleName().hashCode();
> > +        result <<= 2;
> > +        Generator<?> gen = getWrappedGenerator();
> > +        result ^= gen.hashCode();
> > +        result <<= 2;
> > +        result ^= continuePredicate.hashCode();
> > +        result <<= 2;
> > +        result ^= behavior.ordinal();
> > +        return result;
> > +    }
> > +
> > +    private void stop() {
> > +        stopped = true;
> >      }
> >
> > }
> >
> > Modified:
> >
> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/loop/TransformedGenerator.java
> > URL:
> >
> http://svn.apache.org/viewvc/commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/loop/TransformedGenerator.java?rev=1439683&r1=1439682&r2=1439683&view=diff
> >
> ==============================================================================
> > ---
> >
> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/loop/TransformedGenerator.java
> > (original)
> > +++
> >
> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/loop/TransformedGenerator.java
> > Mon Jan 28 22:49:36 2013
> > @@ -18,6 +18,7 @@ package org.apache.commons.functor.gener
> >
> > import org.apache.commons.functor.UnaryFunction;
> > import org.apache.commons.functor.UnaryProcedure;
> > +import org.apache.commons.functor.generator.BaseGenerator;
> > import org.apache.commons.functor.generator.Generator;
> > import org.apache.commons.lang3.Validate;
> >
> > @@ -28,34 +29,34 @@ import org.apache.commons.lang3.Validate
> >   * @param <E> the type of elements held in this generator.
> >   * @version $Revision$ $Date$
> >   */
> > -public class TransformedGenerator<I, E> extends LoopGenerator<E> {
> > +public class TransformedGenerator<I, E> extends BaseGenerator<E> {
> > +
> > +    /**
> > +     * The wrapped/<em>I</em>nput generator.
> > +     */
> > +    private final Generator<? extends I> wrappedGenerator;
> >
> >      /**
> >       * The UnaryFunction to apply to each element.
> >       */
> >      private final UnaryFunction<? super I, ? extends E> func;
> >
> > -    // 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.
> >      /**
> >       * Create a new TransformedGenerator.
> >       * @param wrapped Generator to transform
> >       * @param func UnaryFunction to apply to each element
> >       */
> > -    @SuppressWarnings("unchecked")
> >      public TransformedGenerator(Generator<? extends I> wrapped,
> > UnaryFunction<? super I, ? extends E> func) {
> > -        super((Generator<? extends E>) Validate.notNull(wrapped,
> > "Generator argument was null"));
> > +        this.wrappedGenerator =
> > +        Validate.notNull(wrapped, "Generator argument was null");
> >          this.func = Validate.notNull(func, "UnaryFunction argument was
> > null");
> >      }
> >
> >      /**
> >       * {@inheritDoc}
> >       */
> > -    @SuppressWarnings("unchecked")
> >      public void run(final UnaryProcedure<? super E> proc) {
> > -        ((Generator<? extends I>) getWrappedGenerator()).run(new
> > UnaryProcedure<I>() {
> > +        wrappedGenerator.run(new UnaryProcedure<I>() {
> >              public void run(I obj) {
> >                  proc.run(func.evaluate(obj));
> >              }
> > @@ -74,7 +75,7 @@ public class TransformedGenerator<I, E>
> >              return false;
> >          }
> >          TransformedGenerator<?, ?> other = (TransformedGenerator<?,
> > ?>) obj;
> > -        return other.getWrappedGenerator().equals(getWrappedGenerator())
> > && other.func == func;
> > +        return other.wrappedGenerator.equals(wrappedGenerator) &&
> > other.func.equals(func);
> >      }
> >
> >      /**
> > @@ -84,7 +85,7 @@ public class TransformedGenerator<I, E>
> >      public int hashCode() {
> >          int result = "TransformedGenerator".hashCode();
> >          result <<= 2;
> > -        Generator<?> gen = getWrappedGenerator();
> > +        Generator<?> gen = wrappedGenerator;
> >          result ^= gen.hashCode();
> >          result <<= 2;
> >          result ^= func.hashCode();
> >
> > Modified:
> >
> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/loop/UntilGenerate.java
> > URL:
> >
> http://svn.apache.org/viewvc/commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/loop/UntilGenerate.java?rev=1439683&r1=1439682&r2=1439683&view=diff
> >
> ==============================================================================
> > ---
> >
> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/loop/UntilGenerate.java
> > (original)
> > +++
> >
> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/loop/UntilGenerate.java
> > Mon Jan 28 22:49:36 2013
> > @@ -18,6 +18,7 @@ package org.apache.commons.functor.gener
> >
> > import org.apache.commons.functor.UnaryPredicate;
> > import org.apache.commons.functor.UnaryProcedure;
> > +import org.apache.commons.functor.core.composite.UnaryNot;
> > import org.apache.commons.functor.generator.Generator;
> > import org.apache.commons.lang3.Validate;
> >
> > @@ -28,12 +29,7 @@ import org.apache.commons.lang3.Validate
> >   * @param <E> the type of elements held in this generator.
> >   * @version $Revision$ $Date$
> >   */
> > -public class UntilGenerate<E> extends LoopGenerator<E> {
> > -
> > -    /**
> > -     * The condition has to verified in order to execute the generation.
> > -     */
> > -    private final UnaryPredicate<? super E> test;
> > +public class UntilGenerate<E> extends PredicatedGenerator<E> {
> >
> >      /**
> >       * Create a new UntilGenerate.
> > @@ -41,54 +37,8 @@ public class UntilGenerate<E> extends Lo
> >       * @param test {@link UnaryPredicate}
> >       */
> >      public UntilGenerate(UnaryPredicate<? super E> test, Generator<?
> > extends E> wrapped) {
> > -        super(Validate.notNull(wrapped, "Generator argument was
> > null"));
> > -        this.test = Validate.notNull(test, "UnaryPredicate argument was
> > null");
> > -    }
> > -
> > -    /**
> > -     * {@inheritDoc}
> > -     */
> > -    public void run(final UnaryProcedure<? super E> proc) {
> > -        getWrappedGenerator().run(new UnaryProcedure<E>() {
> > -            public void run(E obj) {
> > -                if (isStopped()) {
> > -                    return;
> > -                }
> > -                if (test.test(obj)) {
> > -                    stop();
> > -                } else {
> > -                    proc.run(obj);
> > -                }
> > -            }
> > -        });
> > +        super(Validate.notNull(wrapped, "Generator argument was
> > null"), UnaryNot.not(Validate.notNull(test,
> > +            "UnaryPredicate argument was null")),
> > Behavior.TEST_BEFORE);
> >      }
> >
> > -    /**
> > -     * {@inheritDoc}
> > -     */
> > -    @Override
> > -    public boolean equals(Object obj) {
> > -        if (obj == this) {
> > -            return true;
> > -        }
> > -        if (!(obj instanceof UntilGenerate<?>)) {
> > -            return false;
> > -        }
> > -        UntilGenerate<?> other = (UntilGenerate<?>) obj;
> > -        return other.getWrappedGenerator().equals(getWrappedGenerator())
> > && other.test.equals(test);
> > -    }
> > -
> > -    /**
> > -     * {@inheritDoc}
> > -     */
> > -    @Override
> > -    public int hashCode() {
> > -        int result = "UntilGenerate".hashCode();
> > -        result <<= 2;
> > -        Generator<?> gen = getWrappedGenerator();
> > -        result ^= gen.hashCode();
> > -        result <<= 2;
> > -        result ^= test.hashCode();
> > -        return result;
> > -    }
> > }
> >
> > Modified:
> >
> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/loop/WhileGenerate.java
> > URL:
> >
> http://svn.apache.org/viewvc/commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/loop/WhileGenerate.java?rev=1439683&r1=1439682&r2=1439683&view=diff
> >
> ==============================================================================
> > ---
> >
> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/loop/WhileGenerate.java
> > (original)
> > +++
> >
> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/loop/WhileGenerate.java
> > Mon Jan 28 22:49:36 2013
> > @@ -28,12 +28,7 @@ import org.apache.commons.lang3.Validate
> >   * @param <E> the type of elements held in this generator.
> >   * @version $Revision$ $Date$
> >   */
> > -public class WhileGenerate<E> extends LoopGenerator<E> {
> > -
> > -    /**
> > -     * The condition has to verified in order to execute the generation.
> > -     */
> > -    private final UnaryPredicate<? super E> test;
> > +public class WhileGenerate<E> extends PredicatedGenerator<E> {
> >
> >      /**
> >       * Create a new WhileGenerate.
> > @@ -41,54 +36,8 @@ public class WhileGenerate<E> extends Lo
> >       * @param wrapped {@link Generator}
> >       */
> >      public WhileGenerate(UnaryPredicate<? super E> test, Generator<?
> > extends E> wrapped) {
> > -        super(Validate.notNull(wrapped, "Generator argument was
> > null"));
> > -        this.test = Validate.notNull(test, "UnaryPredicate argument was
> > null");
> > -    }
> > -
> > -    /**
> > -     * {@inheritDoc}
> > -     */
> > -    public void run(final UnaryProcedure<? super E> proc) {
> > -        getWrappedGenerator().run(new UnaryProcedure<E>() {
> > -            public void run(E obj) {
> > -                if (isStopped()) {
> > -                    return;
> > -                }
> > -                if (!test.test(obj)) {
> > -                    stop();
> > -                } else {
> > -                    proc.run(obj);
> > -                }
> > -            }
> > -        });
> > +        super(Validate.notNull(wrapped, "Generator argument was
> > null"), Validate.notNull(test,
> > +            "UnaryPredicate argument was null"),
> > Behavior.TEST_BEFORE);
> >      }
> >
> > -    /**
> > -     * {@inheritDoc}
> > -     */
> > -    @Override
> > -    public boolean equals(Object obj) {
> > -        if (obj == this) {
> > -            return true;
> > -        }
> > -        if (!(obj instanceof WhileGenerate<?>)) {
> > -            return false;
> > -        }
> > -        WhileGenerate<?> other = (WhileGenerate<?>) obj;
> > -        return other.getWrappedGenerator().equals(getWrappedGenerator())
> > && other.test.equals(test);
> > -    }
> > -
> > -    /**
> > -     * {@inheritDoc}
> > -     */
> > -    @Override
> > -    public int hashCode() {
> > -        int result = "WhileGenerate".hashCode();
> > -        result <<= 2;
> > -        Generator<?> gen = getWrappedGenerator();
> > -        result ^= gen.hashCode();
> > -        result <<= 2;
> > -        result ^= test.hashCode();
> > -        return result;
> > -    }
> > }
> >
> > Modified:
> >
> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/range/CharacterRange.java
> > URL:
> >
> http://svn.apache.org/viewvc/commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/range/CharacterRange.java?rev=1439683&r1=1439682&r2=1439683&view=diff
> >
> ==============================================================================
> > ---
> >
> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/range/CharacterRange.java
> > (original)
> > +++
> >
> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/range/CharacterRange.java
> > Mon Jan 28 22:49:36 2013
> > @@ -21,7 +21,7 @@ import java.util.Collection;
> >
> > import org.apache.commons.functor.BinaryFunction;
> > import org.apache.commons.functor.UnaryProcedure;
> > -import org.apache.commons.functor.generator.loop.LoopGenerator;
> > +import org.apache.commons.functor.generator.BaseGenerator;
> > import org.apache.commons.lang3.Validate;
> >
> > /**
> > @@ -30,7 +30,7 @@ import org.apache.commons.lang3.Validate
> >   * @since 1.0
> >   * @version $Revision$ $Date$
> >   */
> > -public final class CharacterRange extends LoopGenerator<Character>
> > implements Range<Character, Integer> {
> > +public final class CharacterRange extends BaseGenerator<Character>
> > implements Range<Character, Integer> {
> >
> >      // attributes
> >      // ---------------------------------------------------------------
> >
> > Modified:
> >
> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/range/NumericRange.java
> > URL:
> >
> http://svn.apache.org/viewvc/commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/range/NumericRange.java?rev=1439683&r1=1439682&r2=1439683&view=diff
> >
> ==============================================================================
> > ---
> >
> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/range/NumericRange.java
> > (original)
> > +++
> >
> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/main/java/org/apache/commons/functor/generator/range/NumericRange.java
> > Mon Jan 28 22:49:36 2013
> > @@ -19,7 +19,7 @@ package org.apache.commons.functor.gener
> >
> > import java.util.Collection;
> >
> > -import org.apache.commons.functor.generator.loop.LoopGenerator;
> > +import org.apache.commons.functor.generator.BaseGenerator;
> > import org.apache.commons.lang3.Validate;
> >
> > /**
> > @@ -35,7 +35,7 @@ import org.apache.commons.lang3.Validate
> >   * @since 0.1
> >   * @version $Revision$ $Date$
> >   */
> > -public abstract class NumericRange<T extends Number &
> > Comparable<T>> extends LoopGenerator<T> implements Range<T,
> > T> {
> > +public abstract class NumericRange<T extends Number &
> > Comparable<T>> extends BaseGenerator<T> implements Range<T,
> > T> {
> >      // attributes
> >      // ---------------------------------------------------------------
> >      /**
> >
> > 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=1439683&r1=1439682&r2=1439683&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
> > Mon Jan 28 22:49:36 2013
> > @@ -31,8 +31,8 @@ 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.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;
> > @@ -116,7 +116,7 @@ public class TestAlgorithms {
> >
> >      @Test
> >      public void testApplyToGenerator() {
> > -        LoopGenerator<Integer> gen = new IntegerRange(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/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=1439683&r1=1439682&r2=1439683&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
> > Mon Jan 28 22:49:36 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.loop.LoopGenerator;
> > +import org.apache.commons.functor.generator.BaseGenerator;
> >
> > /**
> >   * @version $Revision$ $Date$
> >   */
> > -public class Lines extends LoopGenerator<String> {
> > +public class Lines extends BaseGenerator<String> {
> >      public static Lines from(Reader reader) {
> >          return new Lines(reader);
> >      }
> > @@ -55,19 +55,13 @@ public class Lines extends LoopGenerator
> >          } catch(Exception e) {
> >              throw new TunneledException(e);
> >          } finally {
> > -            stop();
> > -        }
> > -    }
> > -
> > -    @Override
> > -    public void stop() {
> > -        super.stop();
> > -        try {
> > -            in.close();
> > -        } catch(RuntimeException e) {
> > -            throw e;
> > -        } catch(Exception e) {
> > -            throw new TunneledException(e);
> > +            try {
> > +                in.close();
> > +            } catch(RuntimeException e) {
> > +                throw e;
> > +            } catch(Exception e) {
> > +                throw new TunneledException(e);
> > +            }
> >          }
> >      }
> >
> >
> > Modified:
> >
> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/test/java/org/apache/commons/functor/generator/loop/TestGenerateUntil.java
> > URL:
> >
> http://svn.apache.org/viewvc/commons/proper/functor/branches/FUNCTOR-14-mm/core/src/test/java/org/apache/commons/functor/generator/loop/TestGenerateUntil.java?rev=1439683&r1=1439682&r2=1439683&view=diff
> >
> ==============================================================================
> > ---
> >
> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/test/java/org/apache/commons/functor/generator/loop/TestGenerateUntil.java
> > (original)
> > +++
> >
> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/test/java/org/apache/commons/functor/generator/loop/TestGenerateUntil.java
> > Mon Jan 28 22:49:36 2013
> > @@ -40,13 +40,13 @@ public class TestGenerateUntil {
> >      //
> ------------------------------------------------------------------------
> >      private static final Integer FIVE = new Integer(5);
> >
> > -    private LoopGenerator<Integer> wrappedGenerator = null;
> > +    private Generator<Integer> wrappedGenerator = null;
> >      private UnaryPredicate<Integer> isMoreThanFive = new
> > UnaryPredicate<Integer>() {
> >          public boolean test( Integer obj ) {
> >              return obj > FIVE;
> >          }
> >      };
> > -    private LoopGenerator<Integer> generateUntil = null;
> > +    private PredicatedGenerator<Integer> generateUntil = null;
> >
> >      @Before
> >      public void setUp() throws Exception {
> >
> > Modified:
> >
> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/test/java/org/apache/commons/functor/generator/loop/TestGenerateWhile.java
> > URL:
> >
> http://svn.apache.org/viewvc/commons/proper/functor/branches/FUNCTOR-14-mm/core/src/test/java/org/apache/commons/functor/generator/loop/TestGenerateWhile.java?rev=1439683&r1=1439682&r2=1439683&view=diff
> >
> ==============================================================================
> > ---
> >
> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/test/java/org/apache/commons/functor/generator/loop/TestGenerateWhile.java
> > (original)
> > +++
> >
> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/test/java/org/apache/commons/functor/generator/loop/TestGenerateWhile.java
> > Mon Jan 28 22:49:36 2013
> > @@ -40,13 +40,13 @@ public class TestGenerateWhile {
> >      //
> ------------------------------------------------------------------------
> >      private static final Integer FIVE = new Integer(5);
> >
> > -    private LoopGenerator<Integer> wrappedGenerator = null;
> > +    private Generator<Integer> wrappedGenerator = null;
> >      private UnaryPredicate<Integer> isLessThanFive = new
> > UnaryPredicate<Integer>() {
> >          public boolean test( Integer obj ) {
> >              return obj < FIVE;
> >          }
> >      };
> > -    private LoopGenerator<Integer> generateWhile = null;
> > +    private PredicatedGenerator<Integer> generateWhile = null;
> >
> >      @Before
> >      public void setUp() throws Exception {
> >
> > Modified:
> >
> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/test/java/org/apache/commons/functor/generator/loop/TestTransformedGenerator.java
> > URL:
> >
> http://svn.apache.org/viewvc/commons/proper/functor/branches/FUNCTOR-14-mm/core/src/test/java/org/apache/commons/functor/generator/loop/TestTransformedGenerator.java?rev=1439683&r1=1439682&r2=1439683&view=diff
> >
> ==============================================================================
> > ---
> >
> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/test/java/org/apache/commons/functor/generator/loop/TestTransformedGenerator.java
> > (original)
> > +++
> >
> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/test/java/org/apache/commons/functor/generator/loop/TestTransformedGenerator.java
> > Mon Jan 28 22:49:36 2013
> > @@ -22,6 +22,7 @@ import java.util.List;
> >
> > import org.apache.commons.functor.UnaryFunction;
> > import org.apache.commons.functor.UnaryProcedure;
> > +import org.apache.commons.functor.generator.Generator;
> > import org.apache.commons.functor.generator.range.IntegerRange;
> > import org.junit.After;
> > import org.junit.Before;
> > @@ -36,7 +37,7 @@ public class TestTransformedGenerator {
> >      //
> ------------------------------------------------------------------------
> >      private static final Integer TWO = new Integer(2);
> >
> > -    private LoopGenerator<Integer> wrappedGenerator = null;
> > +    private Generator<Integer> wrappedGenerator = null;
> >      private UnaryFunction<Integer, Integer> sumsTwo = new
> > UnaryFunction<Integer, Integer>() {
> >          public Integer evaluate( Integer obj ) {
> >              return obj += TWO;
> >
> > Modified:
> >
> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/test/java/org/apache/commons/functor/generator/loop/TestUntilGenerate.java
> > URL:
> >
> http://svn.apache.org/viewvc/commons/proper/functor/branches/FUNCTOR-14-mm/core/src/test/java/org/apache/commons/functor/generator/loop/TestUntilGenerate.java?rev=1439683&r1=1439682&r2=1439683&view=diff
> >
> ==============================================================================
> > ---
> >
> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/test/java/org/apache/commons/functor/generator/loop/TestUntilGenerate.java
> > (original)
> > +++
> >
> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/test/java/org/apache/commons/functor/generator/loop/TestUntilGenerate.java
> > Mon Jan 28 22:49:36 2013
> > @@ -40,13 +40,13 @@ public class TestUntilGenerate {
> >      //
> ------------------------------------------------------------------------
> >      private static final Integer FIVE = new Integer(5);
> >
> > -    private LoopGenerator<Integer> wrappedGenerator = null;
> > +    private Generator<Integer> wrappedGenerator = null;
> >      private UnaryPredicate<Integer> isGreaterThanFive = new
> > UnaryPredicate<Integer>() {
> >          public boolean test(Integer obj) {
> >              return obj > FIVE;
> >          }
> >      };
> > -    private LoopGenerator<Integer> untilGenerate = null;
> > +    private PredicatedGenerator<Integer> untilGenerate = null;
> >
> >      @Before
> >      public void setUp() throws Exception {
> >
> > Modified:
> >
> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/test/java/org/apache/commons/functor/generator/loop/TestWhileGenerate.java
> > URL:
> >
> http://svn.apache.org/viewvc/commons/proper/functor/branches/FUNCTOR-14-mm/core/src/test/java/org/apache/commons/functor/generator/loop/TestWhileGenerate.java?rev=1439683&r1=1439682&r2=1439683&view=diff
> >
> ==============================================================================
> > ---
> >
> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/test/java/org/apache/commons/functor/generator/loop/TestWhileGenerate.java
> > (original)
> > +++
> >
> commons/proper/functor/branches/FUNCTOR-14-mm/core/src/test/java/org/apache/commons/functor/generator/loop/TestWhileGenerate.java
> > Mon Jan 28 22:49:36 2013
> > @@ -42,13 +42,13 @@ public class TestWhileGenerate {
> >      //
> ------------------------------------------------------------------------
> >      private static final Integer FIVE = new Integer(5);
> >
> > -    private LoopGenerator<Integer> wrappedGenerator = null;
> > +    private Generator<Integer> wrappedGenerator = null;
> >      private UnaryPredicate<Integer> isLessThanFive = new
> > UnaryPredicate<Integer>() {
> >          public boolean test( Integer obj ) {
> >              return obj < FIVE;
> >          }
> >      };
> > -    private LoopGenerator<Integer> whileGenerate = null;
> > +    private PredicatedGenerator<Integer> whileGenerate = null;
> >
> >      @Before
> >      public void setUp() throws Exception {
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> For additional commands, e-mail: dev-help@commons.apache.org
>
>