Package net.jqwik.api.arbitraries
Class ArbitraryDecorator<T>
java.lang.Object
net.jqwik.api.arbitraries.ArbitraryDecorator<T>
- Type Parameters:
T
- The type of object to be generated by this arbitrary
@API(status=MAINTAINED,
since="1.4.0")
public abstract class ArbitraryDecorator<T>
extends Object
implements Cloneable, Arbitrary<T>
Use this superclass if you want to provide a specialized type of arbitrary,
e.g. with additional methods for configuration or defaults,
but don't want to implement the whole Arbitrary interface yourself.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface net.jqwik.api.Arbitrary
Arbitrary.ArbitraryFacade
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionImplement by calling jqwik's standard DSL for building arbitraries.edgeCases
(int maxEdgeCases) exhaustive
(long maxNumberOfSamples) Create the exhaustive generator for an arbitrary.generator
(int genSize) Create the random generator for an arbitrary.generatorWithEmbeddedEdgeCases
(int genSize) Create the random generator for an arbitrary where the embedded generators, if there are any, also generate edge cases.boolean
toString()
protected <A extends Arbitrary<?>>
AUse to clone current instance with its interface typeMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface net.jqwik.api.Arbitrary
allValues, array, asGeneric, collect, dontShrink, edgeCases, edgeCases, exhaustive, filter, filter, fixGenSize, flatMap, forEachValue, generator, ignoreException, ignoreException, ignoreExceptions, ignoreExceptions, injectDuplicates, injectNull, iterator, list, map, optional, optional, sample, sampleStream, set, stream, tuple1, tuple2, tuple3, tuple4, tuple5, withoutEdgeCases
-
Constructor Details
-
ArbitraryDecorator
public ArbitraryDecorator()
-
-
Method Details
-
arbitrary
Implement by calling jqwik's standard DSL for building arbitraries.- Returns:
- a new arbitrary instance
-
generator
Description copied from interface:Arbitrary
Create the random generator for an arbitrary.Starting with version 1.4.0 the returned generator should no longer include edge cases explicitly since those will be injected in Arbitrary.generator(int, boolean)
- Specified by:
generator
in interfaceArbitrary<T>
- Parameters:
genSize
- a very unspecific configuration parameter that can be used to influence the configuration and behaviour of a random generator if and only if the generator wants to be influenced. Many generators are independent of genSize.The default value of
genSize
is the number of tries configured for a property. Use Arbitrary.fixGenSize(int) to fix the parameter for a given arbitrary.- Returns:
- a new random generator instance
-
generatorWithEmbeddedEdgeCases
Description copied from interface:Arbitrary
Create the random generator for an arbitrary where the embedded generators, if there are any, also generate edge cases.Override only if there are any embedded arbitraries / generators, e.g. a container using an element generator
- Specified by:
generatorWithEmbeddedEdgeCases
in interfaceArbitrary<T>
- Parameters:
genSize
- See Arbitrary.generator(int) about meaning of this parameter- Returns:
- a new random generator instance
-
exhaustive
Description copied from interface:Arbitrary
Create the exhaustive generator for an arbitrary. Depending onmaxNumberOfSamples
this can take a long time. This method must be overridden in all arbitraries that support exhaustive generation.- Specified by:
exhaustive
in interfaceArbitrary<T>
- Parameters:
maxNumberOfSamples
- The maximum number of samples considered. If during generation it becomes clear that this number will be exceeded generation stops.- Returns:
- a new exhaustive generator or Optional.empty() if it cannot be created.
-
isGeneratorMemoizable
public boolean isGeneratorMemoizable()- Specified by:
isGeneratorMemoizable
in interfaceArbitrary<T>
-
edgeCases
-
toString
-
typedClone
Use to clone current instance with its interface type- Type Parameters:
A
- The special interface type of this arbitrary- Returns:
- A cloned instance of this arbitrary
-