org.databene.benerator.wrapper
Class LastProductDetector<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.LastProductDetector<E>
All Implemented Interfaces:
java.io.Closeable, Generator<E>, org.databene.commons.Resettable, org.databene.commons.ThreadAware

public class LastProductDetector<E>
extends GeneratorProxy<E>

Wraps another Generator, finds out which is the last generated object and tags that with "last"="true".

Created: 12.09.2011 12:06:26

Since:
0.7.0
Author:
Volker Bergmann
See Also:
ProductWrapper.getTag(String)

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
LastProductDetector(Generator<E> source)
           
 
Method Summary
 void close()
          Closes the generator.
 ProductWrapper<E> generate(ProductWrapper<E> wrapper)
          Returns an instance of the generic type E, using the ProductWrapper instance provided as argument.
 void init(GeneratorContext context)
           
 void reset()
           
 
Methods inherited from class org.databene.benerator.wrapper.GeneratorProxy
getGeneratedType, toString
 
Methods inherited from class org.databene.benerator.wrapper.GeneratorWrapper
equals, generateFromSource, getSource, getSourceWrapper, hashCode, isParallelizable, isThreadSafe, 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

LastProductDetector

public LastProductDetector(Generator<E> source)
Method Detail

init

public void init(GeneratorContext context)
Specified by:
init in interface Generator<E>
Overrides:
init in class GeneratorWrapper<E,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>
Overrides:
generate in class GeneratorProxy<E>

reset

public void reset()
Specified by:
reset in interface org.databene.commons.Resettable
Overrides:
reset in class GeneratorWrapper<E,E>

close

public void close()
Description copied from interface: Generator
Closes the generator. After invocation the state is unavailable.

Specified by:
close in interface java.io.Closeable
Specified by:
close in interface Generator<E>
Overrides:
close in class GeneratorWrapper<E,E>


Copyright © 2013. All Rights Reserved.