Class OneOfArrayGenerator<T>
java.lang.Object
org.instancio.internal.generator.AbstractGenerator<T>
org.instancio.internal.generator.array.OneOfArrayGenerator<T>
- All Implemented Interfaces:
Generator<T>
,GeneratorSpec<T>
,OneOfArrayGeneratorSpec<T>
public class OneOfArrayGenerator<T>
extends AbstractGenerator<T>
implements OneOfArrayGeneratorSpec<T>
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionReturns the public API method name of the generator spec.Returns a generated value.hints()
Hints provided by the generator to the engine.final OneOfArrayGeneratorSpec<T>
Selects a random value from the given choices.Methods inherited from class org.instancio.internal.generator.AbstractGenerator
getContext
-
Constructor Details
-
OneOfArrayGenerator
-
-
Method Details
-
apiMethod
Description copied from class:AbstractGenerator
Returns the public API method name of the generator spec. The returned name is used for reporting validation errors.- Specified by:
apiMethod
in classAbstractGenerator<T>
- Returns:
- spec name if defined, or
null
otherwise
-
oneOf
Description copied from interface:OneOfArrayGeneratorSpec
Selects a random value from the given choices.- Specified by:
oneOf
in interfaceOneOfArrayGeneratorSpec<T>
- Parameters:
values
- from which a random value will be selected- Returns:
- completed spec with no further methods
-
generate
Description copied from interface:Generator
Returns a generated value.If this method produces random data, the data needs to be generated using the provided
Random
instance. This ensures generated values are reproducible for a given seed value. -
hints
Description copied from interface:Generator
Hints provided by the generator to the engine.The most important hint for custom generators is
AfterGenerate
. This hint indicates whether the object created by this generator:- should be populated (for example, if it has
null
fields) - can be modified using selectors
For example, setting the hint to
AfterGenerate.POPULATE_NULLS
will cause Instancio to populatenull
fields on the object returned by this generator:@Override public Hints hints() { return Hints.afterGenerate(AfterGenerate.POPULATE_NULLS); }
If the action is not specified, default behaviour will be based on the
AfterGenerate
value configured in theSettings
using the keyKeys.AFTER_GENERATE_HINT
.In addition, the following hints can be provided for populating data structures:
- should be populated (for example, if it has
-