Package net.jqwik.api.providers
Interface ArbitraryProvider
-
@API(status=MAINTAINED, since="1.0") public interface ArbitraryProvider
Implementation of this class are used to provide default arbitraries toForAll
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:
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interface
ArbitraryProvider.SubtypeProvider
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description boolean
canProvideFor(TypeUsage targetType)
Return true if the provider is suitable fortargetType
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 ofArbitraryProvider
.
-
-
-
Method Detail
-
canProvideFor
boolean canProvideFor(TypeUsage targetType)
Return true if the provider is suitable fortargetType
-
provideFor
java.util.Set<Arbitrary<?>> provideFor(TypeUsage targetType, ArbitraryProvider.SubtypeProvider subtypeProvider)
This is the method you must override in your own implementations ofArbitraryProvider
. It should return a set of arbitrary instances for a giventargetType
.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 oftargetType
.
-
priority
default int priority()
Providers with higher priority will replace providers with lower priority. If there is more than one provider for a given type with the same priority, there results will add up in a single set of arbitraries to use.- Override with value > 0 to replace most of _jqwik_'s default providers.
- Override with value > 100 to replace arbitrary provisioning for unrestricted type variables and wildcard types.
- Override with value > 100 to replace arbitrary provisioning for plain type
Object
.
-
-