Copyable plugin
Copyable plugin
Copyable plugin generates methods for content copying:
public class PurchaseOrderType implements Cloneable, CopyTo //, ... // ... public Object clone() { return copyTo(createNewInstance()); } public Object copyTo(Object target) { final CopyStrategy strategy = JAXBCopyStrategy.INSTANCE; return copyTo(null, target, strategy); } public Object copyTo(ObjectLocator locator, Object target, CopyStrategy strategy) { final Object draftCopy = ((target == null)?createNewInstance():target); if (draftCopy instanceof PurchaseOrderType) { final PurchaseOrderType copy = ((PurchaseOrderType) draftCopy); if (this.shipTo!= null) { USAddress sourceShipTo; sourceShipTo = this.getShipTo(); USAddress copyShipTo = ((USAddress) strategy.copy(LocatorUtils.property(locator, "shipTo", sourceShipTo), sourceShipTo)); copy.setShipTo(copyShipTo); } else { copy.shipTo = null; } if (this.billTo!= null) { USAddress sourceBillTo; sourceBillTo = this.getBillTo(); USAddress copyBillTo = ((USAddress) strategy.copy(LocatorUtils.property(locator, "billTo", sourceBillTo), sourceBillTo)); copy.setBillTo(copyBillTo); } else { copy.billTo = null; } // ... } return draftCopy; } public Object createNewInstance() { return new PurchaseOrderType(); } // ... }
Generated methods allow you to specify a custom copy creation strategy (copy strategy).
Activation
Use the -Xcopyable argument to activate the plugin.
Configuration
By default, generated code uses oorg.jvnet.jaxb2_commons.lang.JAXBCopyStrategy as equals strategy. You can specify class name of your custom strategy using the -Xcopyable-copyStrategyClass argument:
-Xcopyable-copyStrategyClass=com.acme.foo.CustomCopyStrategy