Class BaseGenerator<E>
java.lang.Object
org.apache.commons.functor.generator.BaseGenerator<E>
- Type Parameters:
E- the type of elements held in this generator.
- All Implemented Interfaces:
Generator<E>
- Direct Known Subclasses:
FilteredGenerator, GenerateUntil, GenerateWhile, IntegerRange, IteratorToGeneratorAdapter, LongRange, TransformedGenerator, UntilGenerate, WhileGenerate
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionCreate a new generator.BaseGenerator(Generator<?> generator) A generator can wrap another generator. -
Method Summary
Modifier and TypeMethodDescriptionprotected Generator<?> Get the generator that is being wrapped.booleanCheck if the generator is stopped.voidstop()Stop the generator.final Collection<? super E> to(Collection<? super E> collection) Same as to(new CollectionTransformer(collection)).final <T> Tto(UnaryFunction<Generator<? extends E>, ? extends T> transformer) Transforms this generator using the passed in transformer.final Collection<E> Same as to(new CollectionTransformer()).
-
Field Details
-
wrappedGenerator
A generator can wrap another generator. -
stopped
private boolean stoppedSet to true when the generator isstopped.
-
-
Constructor Details
-
BaseGenerator
public BaseGenerator()Create a new generator. -
BaseGenerator
-
-
Method Details
-
getWrappedGenerator
Get the generator that is being wrapped.- Returns:
- Generator
-
stop
-
isStopped
-
to
Transforms this generator using the passed in transformer. An example transformer might turn the contents of the generator into aCollectionof elements. Transforms this generator using the passed in UnaryFunction. An example function might turn the contents of the generator into aCollectionof elements.- Specified by:
toin interfaceGenerator<E>- Type Parameters:
T- the returned value type of the inputUnaryFunction.- Parameters:
transformer- UnaryFunction to apply to this- Returns:
- transformation result
-
to
Same as to(new CollectionTransformer(collection)). Same as to(new CollectionTransformer(collection)). -
toCollection
Same as to(new CollectionTransformer()). Same as to(new CollectionTransformer()).- Specified by:
toCollectionin interfaceGenerator<E>- Returns:
- Collection
-