org.databene.benerator.sample
Class IndividualWeightSampleGenerator<E>

java.lang.Object
  extended by org.databene.benerator.util.AbstractGenerator<E>
      extended by org.databene.benerator.util.ThreadSafeGenerator<E>
          extended by org.databene.benerator.sample.AbstractSampleGenerator<E>
              extended by org.databene.benerator.sample.IndividualWeightSampleGenerator<E>
All Implemented Interfaces:
java.io.Closeable, Generator<E>, WeightedGenerator<E>, org.databene.commons.Resettable, org.databene.commons.ThreadAware, org.databene.commons.Weighted

public class IndividualWeightSampleGenerator<E>
extends AbstractSampleGenerator<E>
implements WeightedGenerator<E>

Maps an IndividualWeight distribution to an AbstractWeightFunction and uses its capabilities for providing distribution features based on the IndividualWeight's characteristics.

Created at 01.07.2009 11:48:23

Since:
0.6.0
Author:
Volker Bergmann

Field Summary
 
Fields inherited from class org.databene.benerator.util.AbstractGenerator
context, logger, state
 
Constructor Summary
IndividualWeightSampleGenerator(java.lang.Class<E> generatedType, IndividualWeight<E> individualWeight, E... values)
          Initializes the generator to an unweighted sample list
IndividualWeightSampleGenerator(java.lang.Class<E> generatedType, IndividualWeight<E> individualWeight, java.lang.Iterable<E> values)
          Initializes the generator to an unweighted sample list
 
Method Summary
<T extends E>
void
addValue(T value)
          Adds an unweighted value to the sample list
 void clear()
          Removes all values from the sample list
 ProductWrapper<E> generate(ProductWrapper<E> wrapper)
          Returns an instance of the generic type E, using the ProductWrapper instance provided as argument.
 long getVariety()
           
 double getWeight()
           
 void init(GeneratorContext context)
          Initializes all attributes
 void setSamples(E... samples)
          Sets the sample list to the specified weighted values
 java.lang.String toString()
           
 
Methods inherited from class org.databene.benerator.sample.AbstractSampleGenerator
addValues, addValues, getGeneratedType, setValues, setValues
 
Methods inherited from class org.databene.benerator.util.ThreadSafeGenerator
isParallelizable, isThreadSafe
 
Methods inherited from class org.databene.benerator.util.AbstractGenerator
assertInitialized, assertNotInitialized, close, getResultWrapper, reset, wasInitialized
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.databene.benerator.Generator
close, getGeneratedType, wasInitialized
 
Methods inherited from interface org.databene.commons.ThreadAware
isParallelizable, isThreadSafe
 
Methods inherited from interface org.databene.commons.Resettable
reset
 

Constructor Detail

IndividualWeightSampleGenerator

public IndividualWeightSampleGenerator(java.lang.Class<E> generatedType,
                                       IndividualWeight<E> individualWeight,
                                       E... values)
Initializes the generator to an unweighted sample list


IndividualWeightSampleGenerator

public IndividualWeightSampleGenerator(java.lang.Class<E> generatedType,
                                       IndividualWeight<E> individualWeight,
                                       java.lang.Iterable<E> values)
Initializes the generator to an unweighted sample list

Method Detail

setSamples

public void setSamples(E... samples)
Sets the sample list to the specified weighted values


addValue

public <T extends E> void addValue(T value)
Adds an unweighted value to the sample list

Specified by:
addValue in class AbstractSampleGenerator<E>

getVariety

public long getVariety()
Specified by:
getVariety in class AbstractSampleGenerator<E>

getWeight

public double getWeight()
Specified by:
getWeight in interface org.databene.commons.Weighted

clear

public void clear()
Description copied from class: AbstractSampleGenerator
Removes all values from the sample list

Specified by:
clear in class AbstractSampleGenerator<E>

init

public void init(GeneratorContext context)
Initializes all attributes

Specified by:
init in interface Generator<E>
Overrides:
init in class AbstractGenerator<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.

Specified by:
generate in interface Generator<E>

toString

public java.lang.String toString()
Overrides:
toString in class AbstractGenerator<E>


Copyright © 2013. All Rights Reserved.