@Override public FulfillmentGroupItem clone() { //this is likely an extended class - instantiate from the fully qualified name via reflection FulfillmentGroupItem clonedFulfillmentGroupItem; try { clonedFulfillmentGroupItem = (FulfillmentGroupItem) Class.forName(this.getClass().getName()).newInstance(); try { checkCloneable(clonedFulfillmentGroupItem); } catch (CloneNotSupportedException e) { LOG.warn("Clone implementation missing in inheritance hierarchy outside of Broadleaf: " + clonedFulfillmentGroupItem.getClass().getName(), e); } clonedFulfillmentGroupItem.setFulfillmentGroup(getFulfillmentGroup()); clonedFulfillmentGroupItem.setOrderItem(getOrderItem()); clonedFulfillmentGroupItem.setQuantity(getQuantity()); clonedFulfillmentGroupItem.setTotalItemAmount(getTotalItemAmount()); clonedFulfillmentGroupItem.setTotalItemTaxableAmount(getTotalItemTaxableAmount()); if (getStatus() != null) { clonedFulfillmentGroupItem.setStatus(getStatus()); } } catch (Exception e) { throw new RuntimeException(e); } return clonedFulfillmentGroupItem; }
@Override public <G extends FulfillmentGroupItem> CreateResponse<G> createOrRetrieveCopyInstance(MultiTenantCopyContext context) throws CloneNotSupportedException { CreateResponse<G> createResponse = context.createOrRetrieveCopyInstance(this); if (createResponse.isAlreadyPopulated()) { return createResponse; } FulfillmentGroupItem cloned = createResponse.getClone(); cloned.setFulfillmentGroup(fulfillmentGroup.createOrRetrieveCopyInstance(context).getClone()); cloned.setOrderItem(orderItem.createOrRetrieveCopyInstance(context).getClone()); cloned.setProratedOrderAdjustmentAmount(proratedOrderAdjustment == null ? null : new Money(proratedOrderAdjustment)); cloned.setQuantity(quantity); if (getStatus() != null) { cloned.setStatus(getStatus()); } cloneTaxDetails(context, cloned); cloned.setTotalItemAmount(totalItemAmount == null ? null : new Money(totalItemAmount)); cloned.setTotalItemTaxableAmount(totalItemTaxableAmount == null ? null : new Money(totalItemTaxableAmount)); cloned.setTotalTax(totalTax == null ? null : new Money(totalTax)); return createResponse; }