-
Notifications
You must be signed in to change notification settings - Fork 99
JAXB2 Basics Plugins List
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.XmlNs
annotations topackage-info.java
files - 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
isXXX
togetXXX
. - CamelCase Plugin - changes the way class names are generated to always be in CamelCase..
-
XML ElementWrapper Plugin - support
@XmlElementWrapper
collection 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
setXXX
if 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.
- Home
- Migration guide
-
JAXB Maven Plugin
- Quick Start
-
User Guide
- Basic Usage
- Specifying What To Compile
- Referencing Resources in Maven Artifacts
- Using Catalogs
- Using Episodes
- Modular Schema Compilation
- Controlling the Output
- Using JAXB Plugins
- Using a Specific JAXB Version
- Configuring Extension, Validation and XML Security
- IDE Integration
- Miscellaneous
- Configuring Proxies
- Maven Documentation
- Configuration Cheat Sheet
- Common Pitfalls and Problems
-
JAXB2 Basics Plugins
- Using JAXB2 Basics Plugins
- JSR-305 Support
-
JAXB2 Basics Plugins List
- 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
- Default Value Plugin
- Fluent API Plugin
- Namespace Prefix Plugin
- Value Constructor Plugin
- Boolean Getter Plugin
- CamelCase Plugin
- XML ElementWrapper Plugin
- Parent Pointer Plugin
- Property Listener Injector Plugin
- Annox
- JAXB Annotate Plugin
-
HyperJAXB3
- Build System Support
- Customization Guide
- Databases
- Development guide
- Extension guide
- FAQ
- IDE Support
- Java Persistence
- JAXB
- JDK Support
- Project Templates
-
Reference
- Adding vendor-specific annotations
- Features
- Integrating Hyperjaxb3 in builds
- Introduction
- Making schema-derived classes ready for JPA
- Adding required properties
- Applying workarounds for JAXB vs. JPA conflicts
- Enforcing top-level classes
- Generating equals and hashCode methods
- Generating ORM metadata
- Generating persistence unit descriptor
- JPA 2 Support
- Making classes serializable
- Testing generated mappings
- Reference - single page
- Related Projects
- Sample projects
- Solutions
- Target Scenarios
- Test Projects
- Tutorials
- Best Practices
- FAQ
- Sample Projects
- Support
- License
- Distribution