-
Notifications
You must be signed in to change notification settings - Fork 54
JAXB2 Setters Plugin
maffe edited this page Sep 3, 2019
·
4 revisions
By default, XJC does not generate setters for collection. JAXB2 Setters Plugin generates missing setters.
- Add JAXB2 Basics to your build.
- 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.
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:
// accessor mode
public void setStrings(List<String> value) {
this.strings = null;
List<String> draftStrings = this.getStrings();
draftStrings.addAll(value);
}
// direct mode
public void setStrings(List<String> value) {
this.strings = value;
}
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.
-
JAXB2 Basics Plugins
- Using JAXB2 Basics Plugins
- JSR-305 Support
- SimpleEquals Plugin
- SimpleHashCode Plugin
- Equals Plugin
- HashCode Plugin
- ToString Plugin
- Copyable Plugin
- Mergeable Plugin
- Inheritance Plugin
- AutoInheritance Plugin
- Wildcard Plugin
- Setters Plugin
- Simplify Plugin
- EnumValue Plugin
- JAXBIndex Plugin
- FixJAXB1058 Plugin
- Sample Projects