org.databene.benerator.nullable
Class ValidatingNullableGeneratorProxy<E>

java.lang.Object
  extended by org.databene.benerator.nullable.AbstractNullableGenerator<P>
      extended by org.databene.benerator.nullable.NullableGeneratorWrapper<E,E>
          extended by org.databene.benerator.nullable.ValidatingNullableGeneratorProxy<E>
All Implemented Interfaces:
java.io.Closeable, NullableGenerator<E>, org.databene.commons.Resettable, org.databene.commons.ThreadAware

public class ValidatingNullableGeneratorProxy<E>
extends NullableGeneratorWrapper<E,E>

Proxy for NullableGenerator that only generates products which pass a validator.

Created: 18.02.2010 11:19:59

Since:
0.6.0
Author:
Volker Bergmann

Field Summary
static int ERROR_THRESHOLD
          The number of invalid consecutive generations that causes an exception
protected  org.databene.commons.Validator<? super E> validator
          The validator used for validation
static int WARNING_THRESHOLD
          The number of invalid consecutive generations that causes a warning
 
Fields inherited from class org.databene.benerator.nullable.NullableGeneratorWrapper
realGenerator
 
Fields inherited from class org.databene.benerator.nullable.AbstractNullableGenerator
state
 
Constructor Summary
ValidatingNullableGeneratorProxy(NullableGenerator<E> realValidator, org.databene.commons.Validator<? super E> validator)
          Constructor that takes the validator
 
Method Summary
 ProductWrapper<E> generate(ProductWrapper<E> wrapper)
          Generator implementation that calls generateImpl() to generate values and validator.validate() in order to validate them.
 java.lang.Class<E> getGeneratedType()
           
 
Methods inherited from class org.databene.benerator.nullable.NullableGeneratorWrapper
close, init, isParallelizable, isThreadSafe, reset
 
Methods inherited from class org.databene.benerator.nullable.AbstractNullableGenerator
assertInitialized, assertNotInitialized
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

WARNING_THRESHOLD

public static final int WARNING_THRESHOLD
The number of invalid consecutive generations that causes a warning

See Also:
Constant Field Values

ERROR_THRESHOLD

public static final int ERROR_THRESHOLD
The number of invalid consecutive generations that causes an exception

See Also:
Constant Field Values

validator

protected org.databene.commons.Validator<? super E> validator
The validator used for validation

Constructor Detail

ValidatingNullableGeneratorProxy

public ValidatingNullableGeneratorProxy(NullableGenerator<E> realValidator,
                                        org.databene.commons.Validator<? super E> validator)
Constructor that takes the validator

Method Detail

getGeneratedType

public java.lang.Class<E> getGeneratedType()

generate

public ProductWrapper<E> generate(ProductWrapper<E> wrapper)
Generator implementation that calls generateImpl() to generate values and validator.validate() in order to validate them. Consecutive invalid values are counted. If this count reaches the WARNING_THRESHOLD value, a warning is logged, if the count reaches the ERROR_THRESHOLD, an exception is raised.



Copyright © 2011. All Rights Reserved.