-
Notifications
You must be signed in to change notification settings - Fork 99
JAXB2 Mergeable Plugin
Laurent Schoelens edited this page Nov 13, 2023
·
2 revisions
Mergeable plugin generates merge(...)
methods to merge data from two source objects into this object :
public class PurchaseOrderType
implements MergeFrom//, ...
// ...
public Object createNewInstance() {
return new PurchaseOrderType();
}
public void mergeFrom(Object left, Object right) {
final MergeStrategy strategy = JAXBMergeStrategy.INSTANCE;
mergeFrom(null, null, left, right, strategy);
}
public void mergeFrom(ObjectLocator leftLocator, ObjectLocator rightLocator, Object left, Object right, MergeStrategy strategy) {
if (right instanceof PurchaseOrderType) {
final PurchaseOrderType target = this;
final PurchaseOrderType leftObject = ((PurchaseOrderType) left);
final PurchaseOrderType rightObject = ((PurchaseOrderType) right);
{
USAddress leftShipTo;
leftShipTo = leftObject.getShipTo();
USAddress rightShipTo;
rightShipTo = rightObject.getShipTo();
target.setShipTo(((USAddress) strategy.merge(LocatorUtils.property(leftLocator, "shipTo", leftShipTo), LocatorUtils.property(rightLocator, "shipTo", rightShipTo), leftShipTo, rightShipTo)));
}
{
USAddress leftBillTo;
leftBillTo = leftObject.getBillTo();
USAddress rightBillTo;
rightBillTo = rightObject.getBillTo();
target.setBillTo(((USAddress) strategy.merge(LocatorUtils.property(leftLocator, "billTo", leftBillTo), LocatorUtils.property(rightLocator, "billTo", rightBillTo), leftBillTo, rightBillTo)));
}
// ...
}
}
// ...
}
Generated methods allow you to specify a custom merging strategy (merge strategy).
Use the -Xmergeable
argument to activate the plugin.
By default, generated code uses :
-
org.jvnet.jaxb2_commons.lang.JAXBMergeStrategy
as merge strategy for JAXB 2 (javax
namespace). -
org.jvnet.jaxb.lang.JAXBMergeStrategy
as merge strategy for JAXB 3+ (jakarta
namespace).
You can specify class name of your custom strategy using the -Xmergeable-mergeStrategyClass
argument :
-Xmergeable-mergeStrategyClass=com.acme.foo.CustomMergeStrategy
- 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