Class Fields<T>
- Type Parameters:
T- the type of objects generated
Produces instances of a class by reflecting the class's fields and generating random values for them.
All fields of the class and its class hierarchy are auto-generated.
In order for this generator to work, the type it is given must have an accessible zero-arg constructor.
If a field is marked with an annotation that influences the generation of a given kind of value, that annotation will be applied to the generation of values for that field.
This generator is intended to be used with
From, and not to be available via the
ServiceLoader mechanism.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidconfigure(AnnotatedType annotatedType) Configures this generator using annotations from a given annotated type.copy()Used by the framework to make a copy of the receiver.generate(SourceOfRandomness random, GenerationStatus status) Generates a value, possibly influenced by a source of randomness and metadata about the generation.voidprovide(Generators provided) Supplies the available generators to this one.Methods inherited from class com.pholser.junit.quickcheck.generator.Generator
addComponentGenerators, canGenerateForParametersOfTypes, canRegisterAsType, canShrink, compatibleWithTypeParameter, configurationAnnotationsOn, configure, doShrink, gen, gen, hasComponents, magnitude, narrow, numberOfNeededComponents, shrink, types
-
Field Details
-
fields
-
fieldGenerators
-
-
Constructor Details
-
Fields
- Parameters:
type- the type of objects to be generated
-
-
Method Details
-
generate
Description copied from interface:GenGenerates a value, possibly influenced by a source of randomness and metadata about the generation.- Parameters:
random- source of randomness to be used when generating the valuestatus- an object that can be used to influence the generated value. For example, generating lists can use thesizemethod to generate lists with a given number of elements.- Returns:
- the generated value
-
provide
Description copied from class:GeneratorSupplies the available generators to this one.
This is intended for use only by junit-quickcheck itself, and not by creators of custom generators.
-
configure
Description copied from class:GeneratorConfigures this generator using annotations from a given annotated type.
This method considers only annotations that are themselves marked with
GeneratorConfiguration.By default, the generator will configure itself using this procedure:
- For each of the given annotations:
- Find a
publicmethod on the generator namedconfigure, that accepts a single parameter of the annotation type - Invoke the
configuremethod reflectively, passing the annotation as the argument
- Find a
- For each of the given annotations:
-
copy
Description copied from class:GeneratorUsed by the framework to make a copy of the receiver.
-