Interface ArbitraryProvider


@API(status=MAINTAINED, since="1.0") public interface ArbitraryProvider
Implementations of this class are used to provide default arbitraries to 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:

  • Method Details

    • canProvideFor

      boolean canProvideFor(TypeUsage targetType)
      Return true if the provider is suitable for targetType
    • provideFor

      Set<Arbitrary<?>> provideFor(TypeUsage targetType, ArbitraryProvider.SubtypeProvider subtypeProvider)
      This is the method you must override in your own implementations of ArbitraryProvider. It should return a set of arbitrary instances for a given targetType.

      Only targetTypes 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.
    • 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.