Setters Plugin
| Since 0.5.3. |
Setters Plugin
Setters plugin generates missing setters.
Activation
The plugin is activated by the -Xsetters command line option.
You can also use the -Xsetters-mode=accessor or -Xsetters-mode=direct options to configure the generation modes.
Setter generation modes
| Setter generation modes are supported since 0.6.3. |
The plugin supports two setter generation modes: accessor and direct.
The accessor mode relies on JAXB XJC style of setter generation, the direct mode assigns the provided value directly to the field. The following code snippets demonstrate the difference between these modes:
public void setStrings(List<String> value) {
this.strings = null;
List<String> draftl = this.getStrings();
draftl.addAll(value);
}
public void setStrings(List<String> value) {
this.strings = value;
}
In the version 0.6.3, the accessor mode will be kept default for backwards compatibility reasons. So you'll have to add the following options if you want to generate setters in the direct style:
-Xsetters -Xsetters-mode=direct
The defaulting may be changed in one of the next major version.