Mergeable plugin
Mergeable plugin
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).
Activation
Use the -Xmergeable argument to activate the plugin.
Configuration
By default, generated code uses org.jvnet.jaxb2_commons.lang.JAXBMergeStrategy as merge strategy. You can specify class name of your custom strategy using the -Xmergeable-mergeStrategyClass argument:
-Xmergeable-mergeStrategyClass=com.acme.foo.CustomMergeStrategy