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>,NullableGeneratorSpec<T>,OneOfArrayGeneratorSpec<T>,OneOfArraySpec<T>,ValueSpec<T>
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturns the public API method name of the generator spec.hints()Hints provided by the generator to the engine.nullable()Indicates thatnullvalue can be generated.Selects a random value from the given choices.protected TtryGenerateNonNull(Random random) Makes the best effort to return a non-null value.Methods inherited from class org.instancio.internal.generator.AbstractGenerator
generate, getContext, isNullable, nullableMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.instancio.generator.specs.OneOfArraySpec
toModel
-
Constructor Details
-
OneOfArrayGenerator
public OneOfArrayGenerator() -
OneOfArrayGenerator
-
-
Method Details
-
apiMethod
Description copied from class:AbstractGeneratorReturns the public API method name of the generator spec. The returned name is used for reporting validation errors.- Specified by:
apiMethodin classAbstractGenerator<T>- Returns:
- spec name if defined, or
nullotherwise
-
oneOf
Description copied from interface:OneOfArrayGeneratorSpecSelects a random value from the given choices.- Specified by:
oneOfin interfaceOneOfArrayGeneratorSpec<T>- Specified by:
oneOfin interfaceOneOfArraySpec<T>- Parameters:
values- from which a random value will be selected- Returns:
- completed spec with no further methods
-
nullable
Description copied from interface:NullableGeneratorSpecIndicates thatnullvalue can be generated.- Specified by:
nullablein interfaceNullableGeneratorSpec<T>- Specified by:
nullablein interfaceValueSpec<T>- Overrides:
nullablein classAbstractGenerator<T>- Returns:
- spec builder
-
tryGenerateNonNull
Description copied from class:AbstractGeneratorMakes the best effort to return a non-null value. However, in certain cases this method will produce anull.- Specified by:
tryGenerateNonNullin classAbstractGenerator<T>- Parameters:
random- for generating the value- Returns:
- generated value, either a null or non-null
-
hints
Description copied from interface:GeneratorHints 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
nullfields) - can be modified using selectors
For example, setting the hint to
AfterGenerate.POPULATE_NULLSwill cause Instancio to populatenullfields 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
AfterGeneratevalue configured in theSettingsusing 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
-