Enum AfterGenerate
- All Implemented Interfaces:
Serializable,Comparable<AfterGenerate>,java.lang.constant.Constable
Specifies actions to be taken on objects generated by a generator.
This hint is communicated to the engine via the
Generator.hints() method.
Each action determines how the engine processes the generated object, including whether and how its fields are populated or modified.
Example usage:
public class CustomGenerator implements Generator<MyObject> {
@Override
public MyObject generate(Random random) {
// Generation logic
return new MyObject();
}
@Override
public Hints hints() {
return Hints.afterGenerate(AfterGenerate.POPULATE_NULLS);
}
}
- Since:
- 2.0.0
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>> -
Enum Constant Summary
Enum ConstantsEnum ConstantDescriptionIndicates that a generated object can be modified only via explicitly specified selectors.Indicates that a generated object should remain unchanged.Indicates that all fields in a generated object should be populated, regardless of their current values.Indicates that allnullfields in a generated object should be populated by the engine.Indicates that bothnullfields and primitive fields containing default values in a generated object should be populated by the engine. -
Method Summary
Modifier and TypeMethodDescriptionstatic AfterGenerateReturns the enum constant of this type with the specified name.static AfterGenerate[]values()Returns an array containing the constants of this enum type, in the order they are declared.
-
Enum Constant Details
-
DO_NOT_MODIFY
Indicates that a generated object should remain unchanged. The engine will treat the object as read-only and assign it to the target field without further modification.Fields will not be populated, and matching selectors will have no effect. However,
OnCompleteCallbackcallbacks provided via theonComplete()method will still be executed.- Since:
- 2.0.0
-
APPLY_SELECTORS
Indicates that a generated object can be modified only via explicitly specified selectors. Fields not targeted by selectors will remain unchanged.- Since:
- 2.0.0
-
POPULATE_NULLS
Indicates that allnullfields in a generated object should be populated by the engine. Additionally, the object can be modified as described byAPPLY_SELECTORS.Non-null fields will remain unchanged unless explicitly targeted by selectors.
- Since:
- 2.0.0
-
POPULATE_NULLS_AND_DEFAULT_PRIMITIVES
Indicates that bothnullfields and primitive fields containing default values in a generated object should be populated by the engine. This includes the behavior ofPOPULATE_NULLS.A primitive field is considered to have a default value if it contains:
0for numeric types (byte,short,int,long,float,double)falseforboolean' '(null character) forchar
For example:
- A
booleanfield with the valuefalsemay be randomized. - A
booleanfield with the valuetruewill remain unchanged. - An
intfield with the value0may be randomized. - An
intfield with a non-zero value will remain unchanged.
- Since:
- 2.0.0
-
POPULATE_ALL
Indicates that all fields in a generated object should be populated, regardless of their current values. This will overwrite all fields with new random values.This is the default behaviour for internal generators.
- Since:
- 2.0.0
-
-
Method Details
-
values
Returns an array containing the constants of this enum type, in the order they are declared.- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)- Parameters:
name- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException- if this enum type has no constant with the specified nameNullPointerException- if the argument is null
-