|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.pholser.junit.quickcheck.generator.Generator<T>
T - type of theory parameter to apply this generator's values topublic abstract class Generator<T>
Produces values for theory parameters.
| Constructor Summary | |
|---|---|
protected |
Generator(Class<T> type)
|
protected |
Generator(List<Class<T>> types)
Used for generators of primitives/their wrappers. |
| Method Summary | |
|---|---|
void |
addComponentGenerators(List<Generator<?>> components)
Adds component generators to this generator. |
boolean |
canGenerateForParametersOfTypes(List<org.javaruntype.type.TypeParameter<?>> typeParameters)
|
boolean |
canRegisterAsType(Class<?> type)
Tells whether this generator is allowed to be used for theory parameters of the given type. |
static boolean |
compatibleWithTypeParameter(org.javaruntype.type.TypeParameter<?> parameter,
Class<?> clazz)
|
void |
configure(Map<Class<? extends Annotation>,Annotation> configurationsByType)
Tells this generator to configure itself using annotations from a theory parameter. |
abstract T |
generate(SourceOfRandomness random,
GenerationStatus status)
Produces a value for a theory parameter. |
boolean |
hasComponents()
|
int |
numberOfNeededComponents()
|
List<Class<T>> |
types()
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
protected Generator(Class<T> type)
type - class token for type of theory parameter this generator is applicable toprotected Generator(List<Class<T>> types)
Generator<Integer> can be used for
theory parameters of type Integer or int.
types - class tokens for type of theory parameter this generator is applicable to| Method Detail |
|---|
public List<Class<T>> types()
public boolean canRegisterAsType(Class<?> type)
type - type against which to test this generator
true if the generator is allowed to participate in generating values for theory parameters
of type.
public abstract T generate(SourceOfRandomness random,
GenerationStatus status)
Produces a value for a theory parameter.
A generator may raise an unchecked exception if some condition exists which would lead to a confusing generation -- for example, if a generator honored a range configuration, and the endpoints were transposed.
random - a source of randomness to be used when generating the valuestatus - an object that the generator can use to influence the value it produces. For example, a generator
for lists can use the size method to generate lists with a given number of
elements.
public boolean hasComponents()
addComponentGenerators(java.util.List)public int numberOfNeededComponents()
addComponentGenerators(java.util.List)public void addComponentGenerators(List<Generator<?>> components)
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.
components - component generators to addpublic boolean canGenerateForParametersOfTypes(List<org.javaruntype.type.TypeParameter<?>> typeParameters)
typeParameters - a list of generic type parameters
public static boolean compatibleWithTypeParameter(org.javaruntype.type.TypeParameter<?> parameter,
Class<?> clazz)
parameter - a generic type parameterclazz - a type
canGenerateForParametersOfTypes(List)public void configure(Map<Class<? extends Annotation>,Annotation> configurationsByType)
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:
public method on the generator named configure, that accepts a single
parameter of the annotation typeconfigure method reflectively, passing the annotation as the argument
configurationsByType - a map of configuration annotations, keyed by annotation type
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||