org.apache.commons.functor.generator
Interface Generator<E>

Type Parameters:
E - the type of elements held in this generator.
All Known Implementing Classes:
BaseGenerator, FilteredGenerator, GenerateUntil, GenerateWhile, IntegerRange, IteratorToGeneratorAdapter, LongRange, TransformedGenerator, UntilGenerate, WhileGenerate

public interface Generator<E>

The Generator interface defines a number of useful actions applying UnaryFunctors to each in a series of argument Objects.

Version:
$Revision: 1160786 $ $Date: 2011-08-23 18:40:12 +0200 (Tue, 23 Aug 2011) $
Author:
Jason Horman (jason@jhorman.org), Rodney Waldhoff

Method Summary
 boolean isStopped()
          Check if the generator is stopped.
 void run(UnaryProcedure<? super E> proc)
          Generators must implement this method.
 void stop()
          Stop the generator.
 Collection<? super E> to(Collection<? super E> collection)
          Same as to(new CollectionTransformer(collection)).
<Z> Z
to(UnaryFunction<Generator<? extends E>,? extends Z> transformer)
          Transforms this generator using the passed in transformer.
 Collection<? super E> toCollection()
          Same as to(new CollectionTransformer()).
 

Method Detail

run

void run(UnaryProcedure<? super E> proc)
Generators must implement this method.

Parameters:
proc - UnaryProcedure to run

stop

void stop()
Stop the generator. Will stop the wrapped generator if one was set.


isStopped

boolean isStopped()
Check if the generator is stopped.

Returns:
true if stopped

to

<Z> Z to(UnaryFunction<Generator<? extends E>,? extends Z> transformer)
Transforms this generator using the passed in transformer. An example transformer might turn the contents of the generator into a Collection of elements.

Type Parameters:
Z - the returned value type of the input UnaryFunction.
Parameters:
transformer - UnaryFunction to apply to this
Returns:
transformation result

to

Collection<? super E> to(Collection<? super E> collection)
Same as to(new CollectionTransformer(collection)).

Parameters:
collection - Collection to which my elements should be added
Returns:
collection

toCollection

Collection<? super E> toCollection()
Same as to(new CollectionTransformer()).

Returns:
Collection


Copyright © 2003-2011 The Apache Software Foundation. All Rights Reserved.