Class CollectionGeneratorSpecImpl<T>

All Implemented Interfaces:
Generator<Collection<T>>, GeneratorSpec<Collection<T>>, CollectionGeneratorSpec<T>

public class CollectionGeneratorSpecImpl<T> extends CollectionGenerator<T>
  • Constructor Details

    • CollectionGeneratorSpecImpl

      public CollectionGeneratorSpecImpl(GeneratorContext context)
  • Method Details

    • generate

      public Collection<T> generate(RandomProvider random)
      Description copied from interface: Generator
      Returns a generated value.

      If the generated value is random, it needs to be generated using the given RandomProvider instance. This ensures the data is generated with the same seed value and allows random data to be reproduced by specifying the seed value.

      Specified by:
      generate in interface Generator<T>
      Overrides:
      generate in class CollectionGenerator<T>
      Parameters:
      random - provider for random values
      Returns:
      generated value
    • isDelegating

      public boolean isDelegating()
      Description copied from interface: Generator
      If true, then this generator delegate object instantiation to another generator supplied via Generator.setDelegate(Generator).
      Returns:
      true if this is a delegating generator
    • setDelegate

      public void setDelegate(Generator<?> delegate)
      Description copied from interface: Generator
      Set a delegate that will be responsible for instantiating an object on behalf of this generator.
      Parameters:
      delegate - that will create the target object
    • targetClass

      public Optional<Class<?>> targetClass()
      Description copied from interface: Generator
      Target class to generate.

      If Optional.empty() is returned, it will default to the field type for fields, and element type for collection and array elements.

      If the type is an interface, such as Set, will generate a default implementation class such as HashSet.

      Returns:
      target class