Class CollectionGeneratorSpecImpl<T>

    • Constructor Detail

      • CollectionGeneratorSpecImpl

        public CollectionGeneratorSpecImpl​(GeneratorContext context)
    • Method Detail

      • generate

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

        If the generated value is random, it needs to be generated using the given Random 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).

        A generator is delegating when it does not know the type it needs to generate. For example, the collection generator could generate an ArrayList, a HashSet, or some other collection type.

        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