org.databene.benerator.wrapper
Class CollectionGenerator<C extends java.util.Collection,I>

java.lang.Object
  extended by org.databene.benerator.util.AbstractGenerator<P>
      extended by org.databene.benerator.wrapper.GeneratorWrapper<S,P>
          extended by org.databene.benerator.wrapper.CardinalGenerator<I,C>
              extended by org.databene.benerator.wrapper.CollectionGenerator<C,I>
All Implemented Interfaces:
java.io.Closeable, Generator<C>, org.databene.commons.Resettable, org.databene.commons.ThreadAware

public class CollectionGenerator<C extends java.util.Collection,I>
extends CardinalGenerator<I,C>

Combines a a random number a source generator's products into a collection.

Created: 07.07.2006 19:13:22

Since:
0.1
Author:
Volker Bergmann

Field Summary
 
Fields inherited from class org.databene.benerator.wrapper.CardinalGenerator
cardinalGenerator
 
Fields inherited from class org.databene.benerator.util.AbstractGenerator
context, logger, state
 
Constructor Summary
CollectionGenerator()
           
CollectionGenerator(java.lang.Class<C> collectionType, Generator<I> source, int minSize, int maxSize, Distribution sizeDistribution)
           
 
Method Summary
 ProductWrapper<C> generate(ProductWrapper<C> wrapper)
          Returns an instance of the generic type E, using the ProductWrapper instance provided as argument.
 java.lang.Class<C> getCollectionType()
           
 java.lang.Class<C> getGeneratedType()
          Declares the type of the objects returned by the generate() method.
 void init(GeneratorContext context)
          ensures consistency of the state
 void setCollectionType(java.lang.Class<C> collectionType)
           
 
Methods inherited from class org.databene.benerator.wrapper.CardinalGenerator
generateCardinal, generateCardinalWrapper, reset
 
Methods inherited from class org.databene.benerator.wrapper.GeneratorWrapper
close, equals, generateFromSource, getSource, getSourceWrapper, hashCode, isParallelizable, isThreadSafe, setSource, toString
 
Methods inherited from class org.databene.benerator.util.AbstractGenerator
assertInitialized, assertNotInitialized, getResultWrapper, wasInitialized
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

CollectionGenerator

public CollectionGenerator()

CollectionGenerator

public CollectionGenerator(java.lang.Class<C> collectionType,
                           Generator<I> source,
                           int minSize,
                           int maxSize,
                           Distribution sizeDistribution)
Method Detail

getCollectionType

public java.lang.Class<C> getCollectionType()

setCollectionType

public void setCollectionType(java.lang.Class<C> collectionType)

init

public void init(GeneratorContext context)
ensures consistency of the state

Specified by:
init in interface Generator<C extends java.util.Collection>
Overrides:
init in class CardinalGenerator<I,C extends java.util.Collection>

getGeneratedType

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


generate

public ProductWrapper<C> generate(ProductWrapper<C> 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.