Modification
OBJECTO
Objecto provides a powerful mechanism to customize and adapt generated objects based on specific requirements or scenarios. This flexibility enables developers to tailor objects to their exact needs, ensuring that the generated data aligns with the desired context. Objecto supports the modification of generated objects through both parameters of factory methods and modifier methods.
@Modifier
Modifier Parameters
Specify modification parameters using @Modifier
annotation in factory methods to alter specific fields or invoke methods during generation.
When the code is compiled with the -parameters
flag, the parameter names are retained in the compiled bytecode. This means that Objecto can infer the parameters without the explicit use of @Modifier
. Developers can choose whether to use @Modifier
for clarity or rely on parameter names when compiling with the -parameters
flag.
Declaration Example:
Usage Examples
Modifier Methods
Define @Modifier
methods with a return type of the factory interface itself.
Declaration Examples
Usage Examples
Complex Modifiers
Modifiers can also be complex, allowing modification of nested fields or collections.
Examples:
Last updated