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
generatedType, sources
 
Fields inherited from class org.databene.benerator.util.AbstractGenerator
context, logger, state
 
Constructor Summary
AlternativeGenerator(java.lang.Class<E> targetType, Generator<E>... sources)
          Initializes the generator to a collection of source generators
 
Method Summary
 ProductWrapper<E> generate(ProductWrapper<E> wrapper)
          Returns an instance of the generic type E, using the ProductWrapper instance provided as argument.
 
Methods inherited from class org.databene.benerator.wrapper.MultiGeneratorWrapper
addSource, availableSourceCount, close, generateFromAllSources, generateFromAvailableSource, generateFromRandomSource, generateFromSource, getAvailableSource, getGeneratedType, getSource, getSources, getSourceWrapper, init, isParallelizable, isThreadSafe, reset, 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

AlternativeGenerator

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

Method Detail

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.



Copyright © 2013. All Rights Reserved.