com.pholser.junit.quickcheck.generator
Class ComponentizedGenerator<T>

java.lang.Object
  extended by com.pholser.junit.quickcheck.generator.Generator<T>
      extended by com.pholser.junit.quickcheck.generator.ComponentizedGenerator<T>
Type Parameters:
T - type of theory parameter to apply this generator's values to

public abstract class ComponentizedGenerator<T>
extends Generator<T>

Produces values for theory parameters of types that have components that would also need generation, such as arrays, lists, and predicates.


Constructor Summary
protected ComponentizedGenerator(Class<T> type)
           
 
Method Summary
 void addComponentGenerators(List<Generator<?>> components)
          Adds component generators to this generator.
 boolean canGenerateForParametersOfTypes(List<org.javaruntype.type.TypeParameter<?>> typeParameters)
           
 List<Generator<?>> componentGenerators()
           
 void configure(Map<Class<? extends Annotation>,Annotation> configurationsByType)
          Tells this generator to configure itself using annotations from a theory parameter.
 boolean hasComponents()
           
 
Methods inherited from class com.pholser.junit.quickcheck.generator.Generator
canRegisterAsType, compatibleWithTypeParameter, generate, numberOfNeededComponents, types
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ComponentizedGenerator

protected ComponentizedGenerator(Class<T> type)
Parameters:
type - class token for type of theory parameter this generator is applicable to
Method Detail

hasComponents

public final boolean hasComponents()
Overrides:
hasComponents in class Generator<T>
Returns:
whether this generator has component generators, such as for those generators that produce lists or arrays.
See Also:
Generator.addComponentGenerators(java.util.List)

addComponentGenerators

public void addComponentGenerators(List<Generator<?>> components)
Description copied from class: Generator

Adds component generators to this generator.

Some generators need component generators to create proper values. For example, lists require a single component generator in order to generate elements that have the type of the list parameter's type argument.

Overrides:
addComponentGenerators in class Generator<T>
Parameters:
components - component generators to add

componentGenerators

public List<Generator<?>> componentGenerators()

canGenerateForParametersOfTypes

public boolean canGenerateForParametersOfTypes(List<org.javaruntype.type.TypeParameter<?>> typeParameters)
Overrides:
canGenerateForParametersOfTypes in class Generator<T>
Parameters:
typeParameters - a list of generic type parameters
Returns:
whether this generator can be considered for generating values for theory parameters that have the given type parameters in their signatures

configure

public void configure(Map<Class<? extends Annotation>,Annotation> configurationsByType)
Description copied from class: Generator

Tells this generator to configure itself using annotations from a theory parameter.

The annotations fed to this method will be those annotations on the theory parameter that are themselves marked with GeneratorConfiguration.

By default, the generator will configure itself by:

Overrides:
configure in class Generator<T>
Parameters:
configurationsByType - a map of configuration annotations, keyed by annotation type


Copyright © 2013. All Rights Reserved.