| Modifier and Type | Method and Description |
|---|---|
boolean |
canShrink(Object larger)
Tells whether this generator is allowed to participate in the
Shrink process for the given "larger" value. |
void |
configure(AnnotatedType annotatedType)
Configures this generator using annotations from a given annotated
type.
|
void |
configure(Distinct distinct)
Tells this generator to produce values which are distinct from each
other.
|
void |
configure(Size size)
Tells this generator to produce values with a length within a specified
minimum and/or maximum, inclusive, chosen with uniform distribution.
|
List<Object> |
doShrink(SourceOfRandomness random,
Object larger)
Gives some objects that are "smaller" than a given "larger"
object.
|
Object |
generate(SourceOfRandomness random,
GenerationStatus status)
Generates a value, possibly influenced by a source of randomness and
metadata about the generation.
|
BigDecimal |
magnitude(Object value)
Gives a hint to the shrinking process as to the magnitude of the given
value.
|
void |
provide(Generators provided)
Supplies the available generators to this one.
|
addComponentGenerators, canGenerateForParametersOfTypes, canRegisterAsType, compatibleWithTypeParameter, configurationAnnotationsOn, configure, copy, gen, gen, hasComponents, narrow, numberOfNeededComponents, shrink, typespublic void configure(Size size)
size - annotation that gives the length constraintspublic void configure(Distinct distinct)
distinct - Generated values will be distinct if this param is not
null.public Object generate(SourceOfRandomness random, GenerationStatus status)
Genrandom - 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 the size method to generate lists with a given
number of elements.public boolean canShrink(Object larger)
GeneratorTells whether this generator is allowed to participate in the
Shrink process 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.
public List<Object> doShrink(SourceOfRandomness random, Object larger)
GeneratorGives some objects that are "smaller" than a given "larger" object.
Unless overridden, a generator will produce an empty list of "smaller" values.
public void provide(Generators provided)
GeneratorSupplies the available generators to this one.
This is intended for use only by junit-quickcheck itself, and not by creators of custom generators.
public BigDecimal magnitude(Object value)
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.
magnitude in class Generator<Object>value - the value to assessGenerator.narrow(Object)public void configure(AnnotatedType annotatedType)
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:
public method on the generator named
configure, that accepts a single parameter of the
annotation typeconfigure method reflectively, passing the
annotation as the argumentCopyright © 2019. All rights reserved.