Package net.jqwik.api

Interface ArbitrarySupplier<T>

All Superinterfaces:
Supplier<Arbitrary<T>>
All Known Implementing Classes:
ArbitrarySupplier.NONE

@API(status=MAINTAINED, since="1.7.0") public interface ArbitrarySupplier<T> extends Supplier<Arbitrary<T>>
Implementations of this class are used to provide single arbitraries for ForAll parameters and parameter types annotated with From. Use ForAll.supplier() or From.supplier() attributes to specify the actual implementation class.

Either supplyFor(TypeUsage) or get() must be overridden. But not both.

See Also:
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Interface
    Description
    static class 
     
  • Method Summary

    Modifier and Type
    Method
    Description
    default @Nullable Arbitrary<T>
    get()
    Override this method if generating the arbitrary is straightforward.
    default @Nullable Arbitrary<T>
    supplyFor(TypeUsage targetType)
    Override this method if you need more information about the target type, e.g. annotations or type parameters.
  • Method Details

    • supplyFor

      default @Nullable Arbitrary<T> supplyFor(TypeUsage targetType)
      Override this method if you need more information about the target type, e.g. annotations or type parameters.

      This method takes precedence if both supplyFor(TypeUsage) and get() are overridden.

      Parameters:
      targetType - Specifies the type to generate.
      Returns:
      A new arbitrary instance
    • get

      default @Nullable Arbitrary<T> get()
      Override this method if generating the arbitrary is straightforward. This is probably the standard usage.

      Mind that supplyFor(TypeUsage) takes precedence if both supplyFor(TypeUsage) and get() are overridden.

      Specified by:
      get in interface Supplier<T>
      Returns:
      A new arbitrary instance