JAXB2 Basics Plugins List - highsource/jaxb-tools GitHub Wiki
Schema compiler (XJC) produces schema-derived classes which can be used to turn XML into object structures and back. However, generated classes lack by default lack convenience and utility methods like equals(...), hashCode(...), toString() and so on.
JAXB2 Basics provides a package of plugins which can generate such utility code
- 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
- 
Commons Lang Plugin - generates the toString(),hashCode()andequals()methods using Apache commons-lang3.
- Default Value Plugin - modifies the JAXB code model to set default values to the schema default attribute.
- Fluent API Plugin - support a fluent api in addition to the default (JavaBean) setter methods.
- 
Namespace Prefix Plugin - Namespace Prefix Plugin - adds javax.xml.bind.annotation.XmlNsannotations topackage-info.javafiles
- Value Constructor Plugin - generates another constructor, taking an argument for each field in the class and initialises the field with the argument value.
- 
Boolean Getter Plugin - changes getter methods for boolean from isXXXtogetXXX.
- CamelCase Plugin - changes the way class names are generated to always be in CamelCase..
- 
XML ElementWrapper Plugin - support @XmlElementWrappercollection generation (without the need of inner class).
- Parent Pointer Plugin - adds a field that points to the parent object
- 
Property Listener Injector Plugin - generates property change events on each setXXXif specified in the additional generated methods
Most utility methods generated by JAXB2 Basics plugins come in two flavours : default (like equals(that)) and with additional locator and strategy parameters (like equals(thisLocator, thatLocator, that, strategy)).
This gives you a possibility to provide a custom strategy which will be used for object comparison, hash code calculation, content copying and so on.
When generating methods, plugins also make schema-derived classes implement corresponding interfaces from the runtime package. For instance, if you use the Equals Plugin, your classes will implement the org/jvnet/jaxb2_commons/lang/Equals interface.
In order to access data from objects, generated code uses getters, setters and fields. For performance reasons, no reflection is used.
In some cases you may need to exclude certain properties from calculations in utility methods. You may use binding customizations to do this :
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
  xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
  jaxb:extensionBindingPrefixes="basic copyable equals hashCode mergeable toString"
  xmlns:basic="http://jaxb2-commons.dev.java.net/basic"
  xmlns:copyable="http://jaxb2-commons.dev.java.net/basic/copyable"
  xmlns:equals="http://jaxb2-commons.dev.java.net/basic/equals"
  xmlns:hashCode="http://jaxb2-commons.dev.java.net/basic/hashCode"
  xmlns:mergeable="http://jaxb2-commons.dev.java.net/basic/mergeable"
  xmlns:toString="http://jaxb2-commons.dev.java.net/basic/toString">
  <xs:complexType name="copyable">
    <xs:sequence>
      <xs:element name="notIgnored" type="xs:string"/>
      <xs:element name="ignored" type="xs:string">
        <xs:annotation>
          <xs:appinfo>
            <basic:ignored/>
          </xs:appinfo>
        </xs:annotation>
      </xs:element>
      <xs:element name="alsoIgnored" type="xs:string">
        <xs:annotation>
          <xs:appinfo>
            <copyable:ignored/>
          </xs:appinfo>
        </xs:annotation>
      </xs:element>
    </xs:sequence>
  </xs:complexType>
  <!-- ... -->
</xs:schema>As you may guess, basic:ignored marks the field to be ignored for all the plugins, copyable:ignored - only for the copyable plugin.