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
- All Implemented Interfaces:
java.lang.Cloneable
,Arbitrary<T>
@API(status=MAINTAINED, since="1.4.0") public abstract class ArbitraryDecorator<T> extends java.lang.Object implements java.lang.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:
Arbitrary
,Arbitraries
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface net.jqwik.api.Arbitrary
Arbitrary.ArbitraryFacade
-
-
Constructor Summary
Constructors Constructor Description ArbitraryDecorator()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract Arbitrary<T>
arbitrary()
Implement by calling jqwik's standard DSL for building arbitraries.EdgeCases<T>
edgeCases(int maxEdgeCases)
java.util.Optional<ExhaustiveGenerator<T>>
exhaustive(long maxNumberOfSamples)
Create the exhaustive generator for an arbitrary.RandomGenerator<T>
generator(int genSize)
Create the random generator for an arbitrary.RandomGenerator<T>
generatorWithEmbeddedEdgeCases(int genSize)
Create the random generator for an arbitrary where the embedded generators, if there are any, also generate edge cases.boolean
isGeneratorMemoizable()
java.lang.String
toString()
protected <A extends Arbitrary<?>>
AtypedClone()
Use to clone current instance with its interface type-
Methods 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, injectDuplicates, injectNull, iterator, list, map, optional, optional, sample, sampleStream, set, stream, tuple1, tuple2, tuple3, tuple4, tuple5, withoutEdgeCases
-
-
-
-
Method Detail
-
arbitrary
protected abstract Arbitrary<T> arbitrary()
Implement by calling jqwik's standard DSL for building arbitraries.- Returns:
- a new arbitrary instance
-
generator
public RandomGenerator<T> generator(int genSize)
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
public RandomGenerator<T> generatorWithEmbeddedEdgeCases(int genSize)
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
public java.util.Optional<ExhaustiveGenerator<T>> exhaustive(long maxNumberOfSamples)
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>
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
typedClone
protected <A extends Arbitrary<?>> A 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
-
-