Class OneOfArrayGenerator<T>

java.lang.Object
org.instancio.generator.AbstractGenerator<T>
org.instancio.generator.array.OneOfArrayGenerator<T>
All Implemented Interfaces:
Generator<T>, GeneratorSpec<T>, OneOfArrayGeneratorSpec<T>

public class OneOfArrayGenerator<T> extends AbstractGenerator<T> implements OneOfArrayGeneratorSpec<T>
  • Constructor Details

  • Method Details

    • oneOf

      @SafeVarargs public final OneOfArrayGeneratorSpec<T> oneOf(T... values)
      Specified by:
      oneOf in interface OneOfArrayGeneratorSpec<T>
    • generate

      public 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>
      Parameters:
      random - provider for generating random values
      Returns:
      generated value
    • 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.

      Specified by:
      targetClass in interface Generator<T>
      Returns:
      target class