@API(status=MAINTAINED,
since="1.0")
public interface ArbitraryProvider
ForAll
parameters without an explicit provider reference.
Implementations must be registered in /META-INF/services/net.jqwik.api.providers.ArbitraryProvider
so that they will be automatically considered for parameter resolution.
Some examples that come with jqwik:
Modifier and Type | Interface and Description |
---|---|
static interface |
ArbitraryProvider.SubtypeProvider |
Modifier and Type | Method and Description |
---|---|
boolean |
canProvideFor(TypeUsage targetType)
Return true if the provider is suitable for
targetType |
default int |
priority()
Providers with higher priority will replace providers with lower priority.
|
java.util.Set<Arbitrary<?>> |
provideFor(TypeUsage targetType,
ArbitraryProvider.SubtypeProvider subtypeProvider)
This is the method you must override in your own implementations of
ArbitraryProvider . |
boolean canProvideFor(TypeUsage targetType)
targetType
java.util.Set<Arbitrary<?>> provideFor(TypeUsage targetType, ArbitraryProvider.SubtypeProvider subtypeProvider)
ArbitraryProvider
.
It should return a set of arbitrary instances for a given targetType
.
Only targetType
s that have been allowed by canProvideFor(TypeUsage)
will be given to this method.
For each try a single, randomly chosen element of the set will be used to generate all objects represented by this arbitrary. This is necessary in order to make generation of parameterized types stable.
subtypeProvider
can be used to get the arbitraries for any type argument of targetType
.default int priority()
Object
.