Class OptionalGenerator
java.lang.Object
com.pholser.junit.quickcheck.generator.Generator<T>
com.pholser.junit.quickcheck.generator.ComponentizedGenerator<Optional>
com.pholser.junit.quickcheck.generator.java.util.OptionalGenerator
Produces values of type
Optional.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondoShrink(SourceOfRandomness random, Optional larger) Gives some objects that are "smaller" than a given "larger" object.Optional<?>generate(SourceOfRandomness random, GenerationStatus status) Generates a value, possibly influenced by a source of randomness and metadata about the generation.Gives a hint to the shrinking process as to the magnitude of the given value.intThis is intended for use only by junit-quickcheck itself, and not by creators of custom generators.Methods inherited from class com.pholser.junit.quickcheck.generator.ComponentizedGenerator
addComponentGenerators, canGenerateForParametersOfTypes, canRegisterAsType, componentGenerators, configure, hasComponents, provideMethods inherited from class com.pholser.junit.quickcheck.generator.Generator
canShrink, compatibleWithTypeParameter, configurationAnnotationsOn, configure, copy, gen, gen, narrow, shrink, types
-
Constructor Details
-
OptionalGenerator
public OptionalGenerator()
-
-
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
-
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.
- Overrides:
doShrinkin classGenerator<Optional>- Parameters:
random- source of randomness to use in shrinking, if desiredlarger- the larger object- Returns:
- objects that are "smaller" than the larger object. Smaller objects should be provided before bigger objects to make shrinking process faster.
-
numberOfNeededComponents
public int numberOfNeededComponents()Description copied from class:GeneratorThis is intended for use only by junit-quickcheck itself, and not by creators of custom generators.
- Overrides:
numberOfNeededComponentsin classGenerator<Optional>- Returns:
- how many component generators this generator needs
- See Also:
-
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.
-