Source:
private void addPoItemsToProperties(Properties poProperties, List poItems) { List<Properties> poLines = new ArrayList<>(); for (Object obj : poItems) { if (obj instanceof PurchaseOrderItem) { PurchaseOrderItem poItem = (PurchaseOrderItem)obj; Properties lineProps = new Properties(); safelyAddProperty(lineProps, CUPurapConstants.AMOUNT.toLowerCase(), poItem.getTotalAmount()); safelyAddProperty(lineProps, CUPurapConstants.Einvoice.INVOICED_AMOUNT.toLowerCase(), poItem.getItemInvoicedTotalAmount()); safelyAddProperty(lineProps, CUPurapConstants.Einvoice.PO_QUANTITY, poItem.getItemQuantity()); safelyAddProperty(lineProps, CUPurapConstants.Einvoice.INVOICE_QUANTITY, poItem.getItemInvoicedTotalQuantity()); safelyAddProperty(lineProps, CUPurapConstants.Einvoice.UNIT_OF_MEASURE, poItem.getItemUnitOfMeasureCode()); safelyAddProperty(lineProps, CUPurapConstants.Einvoice.DESCRIPTION, poItem.getItemDescription()); safelyAddProperty(lineProps, CUPurapConstants.Einvoice.UNIT_PRICE, poItem.getItemUnitPrice()); safelyAddProperty(lineProps, CUPurapConstants.Einvoice.LINE_NUMBER, poItem.getItemLineNumber()); safelyAddProperty(lineProps, CUPurapConstants.Einvoice.PART_NUMBER, poItem.getItemAuxiliaryPartIdentifier()); safelyAddProperty(lineProps, CUPurapConstants.Einvoice.ITEM_TYPE_DESCRIPTION, poItem.getItemType()); safelyAddProperty(lineProps, CUPurapConstants.Einvoice.ITEM_TYPE_CODE, poItem.getItemTypeCode()); safelyAddProperty(lineProps, CUPurapConstants.Einvoice.PO_ITEM_ID, poItem.getItemIdentifier()); poLines.add(lineProps); } } poProperties.put(CUPurapConstants.Einvoice.ITEMS, poLines.toArray()); }

Target:
private void addPoItemsToProperties(Properties poProperties, List poItems) { List<Properties> poLines = new ArrayList<>(); for (Object obj : poItems) { if (obj instanceof PurchaseOrderItem) { PurchaseOrderItem poItem = (PurchaseOrderItem)obj; Properties lineProps = new Properties(); safelyAddProperty(lineProps, CUPurapConstants.Einvoice.AMOUNT, poItem.getTotalAmount()); safelyAddProperty(lineProps, CUPurapConstants.Einvoice.INVOICED_AMOUNT, poItem.getItemInvoicedTotalAmount()); safelyAddProperty(lineProps, CUPurapConstants.Einvoice.PO_QUANTITY, poItem.getItemQuantity()); safelyAddProperty(lineProps, CUPurapConstants.Einvoice.INVOICE_QUANTITY, poItem.getItemInvoicedTotalQuantity()); safelyAddProperty(lineProps, CUPurapConstants.Einvoice.UNIT_OF_MEASURE, poItem.getItemUnitOfMeasureCode()); safelyAddProperty(lineProps, CUPurapConstants.Einvoice.DESCRIPTION, poItem.getItemDescription()); safelyAddProperty(lineProps, CUPurapConstants.Einvoice.UNIT_PRICE, poItem.getItemUnitPrice()); safelyAddProperty(lineProps, CUPurapConstants.Einvoice.LINE_NUMBER, poItem.getItemLineNumber()); safelyAddProperty(lineProps, CUPurapConstants.Einvoice.PART_NUMBER, poItem.getItemAuxiliaryPartIdentifier()); safelyAddProperty(lineProps, CUPurapConstants.Einvoice.ITEM_TYPE_DESCRIPTION, poItem.getItemType()); safelyAddProperty(lineProps, CUPurapConstants.Einvoice.ITEM_TYPE_CODE, poItem.getItemTypeCode()); safelyAddProperty(lineProps, CUPurapConstants.Einvoice.PO_ITEM_ID, poItem.getItemIdentifier()); poLines.add(lineProps); } } poProperties.put(CUPurapConstants.Einvoice.ITEMS, poLines.toArray()); }