org.databene.benerator.wrapper
Class AlternativeGenerator<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.AlternativeGenerator<E>
All Implemented Interfaces:
java.io.Closeable, Generator<E>, org.databene.commons.Resettable, org.databene.commons.ThreadAware
Direct Known Subclasses:
DomainGenerator

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

On each call to generate(), it chooses a generator from a collection, calls its generate() method and returns the product.

Created: 30.08.2006 21:56:59

Since:
0.1
Author:
Volker Bergmann

Field Summary
 
Fields inherited from class org.databene.benerator.wrapper.MultiGeneratorWrapper
availableSources, sources
 
Fields inherited from class org.databene.benerator.util.AbstractGenerator
context, state
 
Constructor Summary
AlternativeGenerator()
           
AlternativeGenerator(java.lang.Class<E> targetType, Generator<E>... sources)
          Initializes the generator to a collection of source generators
AlternativeGenerator(Generator<E>... sources)
          Initializes the generator to a collection of source generators
 
Method Summary
 E generate()
          Returns an instance of the generic type E.
 java.lang.Class<E> getGeneratedType()
          Declares the type of the objects returned by the generate() method.
 
Methods inherited from class org.databene.benerator.wrapper.MultiGeneratorWrapper
addSource, close, generateFromAllSources, generateFromRandomSource, getSource, getSources, init, isParallelizable, isThreadSafe, reset, setSources, toString
 
Methods inherited from class org.databene.benerator.util.AbstractGenerator
assertInitialized, assertNotInitialized, wasInitialized
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AlternativeGenerator

public AlternativeGenerator()

AlternativeGenerator

public AlternativeGenerator(Generator<E>... sources)
Initializes the generator to a collection of source generators


AlternativeGenerator

public AlternativeGenerator(java.lang.Class<E> targetType,
                            Generator<E>... sources)
Initializes the generator to a collection of source generators

Method Detail

getGeneratedType

public java.lang.Class<E> getGeneratedType()
Description copied from interface: Generator
Declares the type of the objects returned by the generate() method.


generate

public E generate()
Description copied from interface: Generator
Returns an instance of the generic type E.

See Also:
Generator.generate()


Copyright © 2011. All Rights Reserved.