Class ComponentizedGenerator<T>

java.lang.Object
com.pholser.junit.quickcheck.generator.Generator<T>
com.pholser.junit.quickcheck.generator.ComponentizedGenerator<T>
Type Parameters:
T - type of property parameter to apply this generator's values to
All Implemented Interfaces:
Gen<T>, Shrink<T>
Direct Known Subclasses:
BiFunctionGenerator, BinaryOperatorGenerator, BiPredicateGenerator, CallableGenerator, CollectionGenerator, DoubleFunctionGenerator, FunctionGenerator, FunctionGenerator, IntFunctionGenerator, LongFunctionGenerator, MapGenerator, OptionalGenerator, OptionalGenerator, PredicateGenerator, PredicateGenerator, SupplierGenerator, SupplierGenerator, ToDoubleBiFunctionGenerator, ToDoubleFunctionGenerator, ToIntBiFunctionGenerator, ToIntFunctionGenerator, ToLongBiFunctionGenerator, ToLongFunctionGenerator, UnaryOperatorGenerator

public abstract class ComponentizedGenerator<T> extends Generator<T>
Produces values for property parameters of types that have parameterizations that would also need generation, such as collections, maps, and predicates.
  • Field Details

  • Constructor Details

    • ComponentizedGenerator

      protected ComponentizedGenerator(Class<T> type)
      Parameters:
      type - class token for type of property parameter this generator is applicable to
  • Method Details

    • canRegisterAsType

      public boolean canRegisterAsType(Class<?> type)
      Tells whether this generator is allowed to be used for property parameters of the given type.

      Generators of this type do not get called upon to generate values for parameters of type Object.

      Overrides:
      canRegisterAsType in class Generator<T>
      Parameters:
      type - type against which to test this generator
      Returns:
      true if the generator is allowed to participate in generating values for property parameters of type
    • hasComponents

      public final boolean hasComponents()
      Description copied from class: Generator

      This is intended for use only by junit-quickcheck itself, and not by creators of custom generators.

      Overrides:
      hasComponents in class Generator<T>
      Returns:
      whether this generator has component generators, such as for those generators that produce lists or maps
      See Also:
    • addComponentGenerators

      public void addComponentGenerators(List<Generator<?>> newComponents)
      Description copied from class: Generator

      Adds component generators to this generator.

      Some generators need component generators to create proper values. For example, list generators require a single component generator in order to generate elements that have the type of the list parameter's type argument.

      This is intended for use only by junit-quickcheck itself, and not by creators of custom generators.

      Overrides:
      addComponentGenerators in class Generator<T>
      Parameters:
      newComponents - component generators to add
    • canGenerateForParametersOfTypes

      public boolean canGenerateForParametersOfTypes(List<io.arxila.javaruntype.type.TypeParameter<?>> typeParameters)
      Overrides:
      canGenerateForParametersOfTypes in class Generator<T>
      Parameters:
      typeParameters - a list of generic type parameters
      Returns:
      whether this generator can be considered for generating values for property parameters that have the given type parameters in their signatures
    • provide

      public void provide(Generators provided)
      Description copied from class: Generator

      Supplies the available generators to this one.

      This is intended for use only by junit-quickcheck itself, and not by creators of custom generators.

      Overrides:
      provide in class Generator<T>
      Parameters:
      provided - repository of available generators
    • configure

      public void configure(AnnotatedType annotatedType)
      Description copied from class: Generator

      Configures this generator using annotations from a given annotated type.

      This method considers only annotations that are themselves marked with GeneratorConfiguration.

      By default, the generator will configure itself using this procedure:

      • For each of the given annotations:
        • Find a public method on the generator named configure, that accepts a single parameter of the annotation type
        • Invoke the configure method reflectively, passing the annotation as the argument
      Overrides:
      configure in class Generator<T>
      Parameters:
      annotatedType - a type usage
    • componentGenerators

      protected List<Generator<?>> componentGenerators()
      Returns:
      this generator's component generators