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

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

public class NullInjectingGeneratorProxy<E>
extends GeneratorProxy<E>

GeneratorProxy implementation which injects a given quota of null values in the original generator's results.

Created: 26.01.2010 10:32:58

Since:
0.6.0
Author:
Volker Bergmann

Field Summary
 
Fields inherited from class org.databene.benerator.wrapper.GeneratorProxy
generatedType
 
Fields inherited from class org.databene.benerator.util.AbstractGenerator
context, logger, state
 
Constructor Summary
NullInjectingGeneratorProxy(Generator<E> source, double nullQuota)
           
 
Method Summary
 ProductWrapper<E> generate(ProductWrapper<E> wrapper)
          First checks if a null value should be returned, if so it returns a wrapper that wraps a null value, otherwise a wrapper that wraps a value generated by the underlying source generator.
protected  boolean shouldNullify()
           
 java.lang.String toString()
           
 
Methods inherited from class org.databene.benerator.wrapper.GeneratorProxy
getGeneratedType
 
Methods inherited from class org.databene.benerator.wrapper.GeneratorWrapper
close, equals, generateFromSource, getSource, getSourceWrapper, hashCode, init, isParallelizable, isThreadSafe, reset, setSource
 
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

NullInjectingGeneratorProxy

public NullInjectingGeneratorProxy(Generator<E> source,
                                   double nullQuota)
Method Detail

generate

public ProductWrapper<E> generate(ProductWrapper<E> wrapper)
First checks if a null value should be returned, if so it returns a wrapper that wraps a null value, otherwise a wrapper that wraps a value generated by the underlying source generator. If that generator is not available any more, null is returned.

Specified by:
generate in interface Generator<E>
Overrides:
generate in class GeneratorProxy<E>

shouldNullify

protected boolean shouldNullify()

toString

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


Copyright © 2013. All Rights Reserved.