Class CompositeGenerator
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddComponentGenerators(List<Generator<?>> newComponents) Adds component generators to this generator.private StringbooleanTells whether this generator is allowed to participate in theShrinkprocess for the given "larger" value.(package private) Generator<?>composed(int index) voidconfigure(AnnotatedElement element) voidconfigure(AnnotatedType annotatedType) Configures this generator using annotations from a given annotated type.doShrink(SourceOfRandomness random, Object larger) Gives some objects that are "smaller" than a given "larger" object.generate(SourceOfRandomness random, GenerationStatus status) Generates a value, possibly influenced by a source of randomness and metadata about the generation.private voidinstallCandidates(List<Weighted<Generator<?>>> candidates, AnnotatedElement element) Gives a hint to the shrinking process as to the magnitude of the given value.(package private) intvoidprovide(Generators provided) Supplies the available generators to this one.Methods inherited from class com.pholser.junit.quickcheck.generator.Generator
canGenerateForParametersOfTypes, canRegisterAsType, compatibleWithTypeParameter, configurationAnnotationsOn, copy, gen, gen, hasComponents, narrow, numberOfNeededComponents, shrink, types
-
Field Details
-
composed
-
-
Constructor Details
-
CompositeGenerator
-
-
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
-
canShrink
Description copied from class:GeneratorTells whether this generator is allowed to participate in the
Shrinkprocess for the given "larger" value.Unless overridden, the only criterion for whether a generator is allowed to participate in shrinking a value is if the value can be safely cast to the type of values the generator produces.
-
doShrink
Description copied from class:GeneratorGives some objects that are "smaller" than a given "larger" object.
Unless overridden, a generator will produce an empty list of "smaller" values.
-
composed
-
numberOfComposedGenerators
int numberOfComposedGenerators() -
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.
-
magnitude
Description copied from class:GeneratorGives a hint to the shrinking process as to the magnitude of the given value. The shrinking process will prefer trying values of greater magnitude before values of lesser magnitude. If not overridden, this implementation returns "one".
Note to generator writers: Do not worry about normalizing a magnitude to a positive value; the shrinking mechanism will take care of it.
-
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:
-
configure
-
addComponentGenerators
Description copied from class:GeneratorAdds component generators to this generator.
Some generators need component generators to create proper values. For example, list generators require a single component generator in order to generate elements that have the type of the list parameter's type argument.
This is intended for use only by junit-quickcheck itself, and not by creators of custom generators.
- Overrides:
addComponentGeneratorsin classGenerator<Object>- Parameters:
newComponents- component generators to add
-
installCandidates
-
candidateGeneratorDescriptions
-
configurationAnnotationNames
-