Class EnumGenerator<E extends Enum<E>>
java.lang.Object
org.instancio.internal.generator.AbstractGenerator<E>
org.instancio.internal.generator.lang.EnumGenerator<E>
- All Implemented Interfaces:
AsStringGeneratorSpec<E>,Generator<E>,GeneratorSpec<E>,AsGeneratorSpec<E>,EnumAsGeneratorSpec<E>,EnumGeneratorSpec<E>,EnumSpec<E>,NullableGeneratorSpec<E>,ValueSpec<E>
public class EnumGenerator<E extends Enum<E>>
extends AbstractGenerator<E>
implements EnumSpec<E>, EnumAsGeneratorSpec<E>
-
Constructor Summary
ConstructorsConstructorDescriptionEnumGenerator(Class<E> enumClass) EnumGenerator(GeneratorContext context, Class<E> enumClass) -
Method Summary
Modifier and TypeMethodDescriptionReturns the public API method name of the generator spec.final EnumGenerator<E>Generate an enum while excluding the specified values.hints()Hints provided by the generator to the engine.nullable()Indicates thatnullvalue can be generated.protected EtryGenerateNonNull(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.AsGeneratorSpec
as, asStringMethods inherited from interface org.instancio.generator.AsStringGeneratorSpec
asString
-
Constructor Details
-
EnumGenerator
-
EnumGenerator
-
-
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<E extends Enum<E>>- Returns:
- spec name if defined, or
nullotherwise
-
excluding
Description copied from interface:EnumSpecGenerate an enum while excluding the specified values. The argument can be an empty array, but notnull. -
nullable
Description copied from interface:NullableGeneratorSpecIndicates thatnullvalue can be generated.- Specified by:
nullablein interfaceEnumAsGeneratorSpec<E extends Enum<E>>- Specified by:
nullablein interfaceEnumGeneratorSpec<E extends Enum<E>>- Specified by:
nullablein interfaceEnumSpec<E extends Enum<E>>- Specified by:
nullablein interfaceNullableGeneratorSpec<E extends Enum<E>>- Specified by:
nullablein interfaceValueSpec<E extends Enum<E>>- Overrides:
nullablein classAbstractGenerator<E extends Enum<E>>- 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<E extends Enum<E>>- 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
-