org.databene.benerator.wrapper
Class GeneratorChain<E>

java.lang.Object
  extended by org.databene.benerator.util.AbstractGenerator<P>
      extended by org.databene.benerator.wrapper.MultiGeneratorWrapper<E,E>
          extended by org.databene.benerator.wrapper.GeneratorChain<E>
All Implemented Interfaces:
java.io.Closeable, Generator<E>, org.databene.commons.Resettable, org.databene.commons.ThreadAware
Direct Known Subclasses:
IncrementalStringGenerator

public class GeneratorChain<E>
extends MultiGeneratorWrapper<E,E>

Proxies several source generators, initially returning products of the first source as long as it is available, then of the second source and son on. When generating unique data, the last source generator is required to generate unique data itself.

Created: 22.07.2011 14:58:00

Since:
0.7.0
Author:
Volker Bergmann

Field Summary
 
Fields inherited from class org.databene.benerator.wrapper.MultiGeneratorWrapper
generatedType, sources
 
Fields inherited from class org.databene.benerator.util.AbstractGenerator
context, logger, state
 
Constructor Summary
GeneratorChain(java.lang.Class<E> generatedType, boolean unique, Generator<? extends E>... sources)
           
 
Method Summary
protected  void clearMembers()
           
 void close()
          Closes the generator.
 ProductWrapper<E> generate(ProductWrapper<E> wrapper)
          Returns an instance of the generic type E, using the ProductWrapper instance provided as argument.
protected  ProductWrapper<E> generateUnvalidated(ProductWrapper<E> wrapper)
           
 void init(GeneratorContext context)
           
 void reset()
           
 
Methods inherited from class org.databene.benerator.wrapper.MultiGeneratorWrapper
addSource, availableSourceCount, generateFromAllSources, generateFromAvailableSource, generateFromRandomSource, generateFromSource, getAvailableSource, getGeneratedType, getSource, getSources, getSourceWrapper, isParallelizable, isThreadSafe, setSources, toString
 
Methods inherited from class org.databene.benerator.util.AbstractGenerator
assertInitialized, assertNotInitialized, getResultWrapper, wasInitialized
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

GeneratorChain

public GeneratorChain(java.lang.Class<E> generatedType,
                      boolean unique,
                      Generator<? extends E>... sources)
Method Detail

init

public void init(GeneratorContext context)
Specified by:
init in interface Generator<E>
Overrides:
init in class MultiGeneratorWrapper<E,E>

generate

public ProductWrapper<E> generate(ProductWrapper<E> wrapper)
Description copied from interface: Generator
Returns an instance of the generic type E, using the ProductWrapper instance provided as argument. The wrapper may wrap a null value as a regular generator product. If the generator is not available (any more), it returns null instead of the ProductWrapper instance.


reset

public void reset()
Specified by:
reset in interface org.databene.commons.Resettable
Overrides:
reset in class MultiGeneratorWrapper<E,E>

close

public void close()
Description copied from interface: Generator
Closes the generator. After invocation the state is unavailable.

Specified by:
close in interface java.io.Closeable
Specified by:
close in interface Generator<E>
Overrides:
close in class MultiGeneratorWrapper<E,E>

generateUnvalidated

protected ProductWrapper<E> generateUnvalidated(ProductWrapper<E> wrapper)

clearMembers

protected void clearMembers()


Copyright © 2013. All Rights Reserved.