[Task] Extend code generation with option for POJO setters #695
Labels
acknowledged
Has been viewed by one of the maintainers and is ready for further work, discussion or other steps.
task
Is your task related to a problem? Please describe.
Currently POJOs are generated with immutability built in. A full constructor is generated and then for each property one getter.
As long as the POJOs are used to only consume upstream data or are always fully initialized prior to passing them on (e.g. to the API of an aspect implementation for serialization to JSON) this is fine.
However in situations where data can only be partially initialized and is added later in the process (e.g. through some sort of post-processing) this can be unhandy, as it requires a developer to always fully initialize a new instance, taking the properties from an existing one when they should be used unmodified and then passing the updated/new property values for everything else.
Describe the solution you'd like
The POJO generator (or rather the templates) should be extended, so that with an additional option it can be decided, whether also setters should be generated. By default the current variant should be used where only getters exist.
Additionally one could also think about providing an additional parameter that drives how the setters are generated: either in a classic setter style (
void
method) or in a fluent builder style (wherethis
is returned for method chaining)Additional context
See #534
The text was updated successfully, but these errors were encountered: