Package org.instancio.generator.array
Class ArrayGenerator<T>
java.lang.Object
org.instancio.generator.AbstractGenerator<T>
org.instancio.generator.array.ArrayGenerator<T>
- All Implemented Interfaces:
Generator<T>
,ArrayGeneratorSpec<T>
,GeneratorSpec<T>
-
Constructor Summary
ConstructorDescriptionArrayGenerator
(GeneratorContext context) ArrayGenerator
(GeneratorContext context, Class<?> arrayType) -
Method Summary
Modifier and TypeMethodDescriptiongenerate
(RandomProvider random) Returns a generated value.getHints()
Returns hints, including collection sizes and whether values are nullable.length
(int length) length of array to generate.maxLength
(int length) Maximum length of array to generate.minLength
(int length) Minimum length of array to generate.nullable()
Indicates thatnull
value can be generated for the array.Indicates thatnull
values can be generated for array elements.Target class to generate.Specifies the type of array that should be generated.Adds given elements to the generated array at random positions.Methods inherited from class org.instancio.generator.AbstractGenerator
getContext
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.instancio.Generator
isDelegating, setDelegate, supports
Methods inherited from interface org.instancio.generator.GeneratorSpec
name
-
Constructor Details
-
ArrayGenerator
-
ArrayGenerator
-
-
Method Details
-
minLength
Description copied from interface:ArrayGeneratorSpec
Minimum length of array to generate.- Specified by:
minLength
in interfaceArrayGeneratorSpec<T>
- Parameters:
length
- minimum length (inclusive)- Returns:
- spec builder
-
maxLength
Description copied from interface:ArrayGeneratorSpec
Maximum length of array to generate.- Specified by:
maxLength
in interfaceArrayGeneratorSpec<T>
- Parameters:
length
- maximum length (inclusive)- Returns:
- spec builder
-
length
Description copied from interface:ArrayGeneratorSpec
length of array to generate.- Specified by:
length
in interfaceArrayGeneratorSpec<T>
- Parameters:
length
- of array- Returns:
- spec builder
-
nullable
Description copied from interface:ArrayGeneratorSpec
Indicates thatnull
value can be generated for the array.- Specified by:
nullable
in interfaceArrayGeneratorSpec<T>
- Returns:
- spec builder
-
nullableElements
Description copied from interface:ArrayGeneratorSpec
Indicates thatnull
values can be generated for array elements.- Specified by:
nullableElements
in interfaceArrayGeneratorSpec<T>
- Returns:
- spec builder
-
type
Description copied from interface:ArrayGeneratorSpec
Specifies the type of array that should be generated.- Specified by:
type
in interfaceArrayGeneratorSpec<T>
- Parameters:
type
- of array to generate- Returns:
- spec builder
-
with
Description copied from interface:ArrayGeneratorSpec
Adds given elements to the generated array at random positions.- Specified by:
with
in interfaceArrayGeneratorSpec<T>
- Parameters:
elements
- to add- Returns:
- spec builder
-
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 asHashSet
.- Specified by:
targetClass
in interfaceGenerator<T>
- Returns:
- target class
-
generate
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. -
getHints
Description copied from interface:Generator
Returns hints, including collection sizes and whether values are nullable.
-