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>
,EnumGeneratorSpec<E>
,NullableGeneratorSpec<E>
public class EnumGenerator<E extends Enum<E>>
extends AbstractGenerator<E>
implements EnumGeneratorSpec<E>, Generator<E>
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturns the public API method name of the generator spec.final EnumGeneratorSpec<E>
Generate an enum while excluding the specified values.Returns a generated value.hints()
Hints provided by the generator to the engine.nullable()
Indicates thatnull
value can be generated.Methods inherited from class org.instancio.internal.generator.AbstractGenerator
getContext, isNullable, nullable
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.AsStringGeneratorSpec
asString, asString
-
Constructor Details
-
EnumGenerator
-
-
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<E extends Enum<E>>
- Returns:
- spec name if defined, or
null
otherwise
-
excluding
Description copied from interface:EnumGeneratorSpec
Generate an enum while excluding the specified values. The argument can be an empty array, but notnull
.- Specified by:
excluding
in interfaceEnumGeneratorSpec<E extends Enum<E>>
- Parameters:
values
- to exclude- Returns:
- spec builder
-
nullable
Description copied from interface:NullableGeneratorSpec
Indicates thatnull
value can be generated.- Specified by:
nullable
in interfaceEnumGeneratorSpec<E extends Enum<E>>
- Specified by:
nullable
in interfaceNullableGeneratorSpec<E extends Enum<E>>
- Overrides:
nullable
in classAbstractGenerator<E extends Enum<E>>
- Returns:
- spec builder
-
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
-