From 0843bd06833c4d7ffd91188eef38c50a10b337b4 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Tue, 17 Oct 2017 23:14:23 +0200 Subject: [PATCH] Continued: - added documentation MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Roland Häder --- .../model/receipt/item/ReceiptItems.java | 49 +++++++++++-------- 1 file changed, 29 insertions(+), 20 deletions(-) diff --git a/src/org/mxchange/jfinancials/model/receipt/item/ReceiptItems.java b/src/org/mxchange/jfinancials/model/receipt/item/ReceiptItems.java index a386d9b..1f7fd23 100644 --- a/src/org/mxchange/jfinancials/model/receipt/item/ReceiptItems.java +++ b/src/org/mxchange/jfinancials/model/receipt/item/ReceiptItems.java @@ -32,7 +32,16 @@ public class ReceiptItems implements Serializable { */ private static final long serialVersionUID = 2_867_938_676_165_402L; - public static boolean isSameReceipt (final BillableReceiptItem receiptItem1, final BillableReceiptItem receiptItem2) { + /** + * Checks if both receipt items are the same by assigned receipt, product + * and quantity. + *

+ * @param receiptItem1 Receipt item 1 + * @param receiptItem2 Receipt item 2 + *

+ * @return Whether both are equal + */ + public static boolean isSameReceiptItem (final BillableReceiptItem receiptItem1, final BillableReceiptItem receiptItem2) { // Pre-compare both as entities (same id) if (Objects.equals(receiptItem1, receiptItem2)) { // Same entity (with id number) @@ -42,55 +51,55 @@ public class ReceiptItems implements Serializable { // Validate parameter if (null == receiptItem1) { // Throw NPE - throw new NullPointerException("receiptItem1 is null"); + throw new NullPointerException("receiptItem1 is null"); //NOI18N } else if ((receiptItem1.getItemId() instanceof Long) && (receiptItem1.getItemId() < 1)) { // Throw IAE - throw new IllegalArgumentException(MessageFormat.format("receiptItem1.itemId={0} is not valid.", receiptItem1.getItemId())); - } else if (receiptItem1.getItemReceipt()== null) { + throw new IllegalArgumentException(MessageFormat.format("receiptItem1.itemId={0} is not valid.", receiptItem1.getItemId())); //NOI18N + } else if (receiptItem1.getItemReceipt() == null) { // Throw NPE - throw new NullPointerException("receiptItem1.itemReceipt is null"); + throw new NullPointerException("receiptItem1.itemReceipt is null"); //NOI18N } else if (receiptItem1.getItemReceipt().getReceiptId() == null) { // Throw NPE - throw new NullPointerException("receiptItem1.itemReceipt.receiptId is null"); + throw new NullPointerException("receiptItem1.itemReceipt.receiptId is null"); //NOI18N } else if (receiptItem1.getItemReceipt().getReceiptId() < 1) { // Throw NPE - throw new NullPointerException(MessageFormat.format("receiptItem1.itemReceipt.receiptId={0} is not valid", receiptItem1.getItemReceipt().getReceiptId())); + throw new NullPointerException(MessageFormat.format("receiptItem1.itemReceipt.receiptId={0} is not valid", receiptItem1.getItemReceipt().getReceiptId())); //NOI18N } else if (receiptItem1.getItemProduct() == null) { // Throw NPE again - throw new NullPointerException("receiptItem1.itemProduct is null."); + throw new NullPointerException("receiptItem1.itemProduct is null."); //NOI18N } else if (receiptItem1.getItemProduct().getProductId() == null) { // Throw NPE again - throw new NullPointerException("receiptItem1.itemProduct.productId is null."); + throw new NullPointerException("receiptItem1.itemProduct.productId is null."); //NOI18N } else if (receiptItem1.getItemProduct().getProductId() < 1) { // Throw IAE - throw new IllegalArgumentException(MessageFormat.format("receiptItem1.itemProduct.productId={0} is invalid.", receiptItem1.getItemProduct().getProductId())); + throw new IllegalArgumentException(MessageFormat.format("receiptItem1.itemProduct.productId={0} is invalid.", receiptItem1.getItemProduct().getProductId())); //NOI18N } else if (null == receiptItem2) { // Throw NPE - throw new NullPointerException("receiptItem2 is null"); + throw new NullPointerException("receiptItem2 is null"); //NOI18N } else if ((receiptItem2.getItemId() instanceof Long) && (receiptItem2.getItemId() < 1)) { // Throw IAE - throw new IllegalArgumentException(MessageFormat.format("receiptItem2.itemId={0} is not valid.", receiptItem2.getItemId())); - } else if (receiptItem2.getItemReceipt()== null) { + throw new IllegalArgumentException(MessageFormat.format("receiptItem2.itemId={0} is not valid.", receiptItem2.getItemId())); //NOI18N + } else if (receiptItem2.getItemReceipt() == null) { // Throw NPE - throw new NullPointerException("receiptItem2.itemReceipt is null"); + throw new NullPointerException("receiptItem2.itemReceipt is null"); //NOI18N } else if (receiptItem2.getItemReceipt().getReceiptId() == null) { // Throw NPE - throw new NullPointerException("receiptItem2.itemReceipt.receiptId is null"); + throw new NullPointerException("receiptItem2.itemReceipt.receiptId is null"); //NOI18N } else if (receiptItem2.getItemReceipt().getReceiptId() < 1) { // Throw NPE - throw new NullPointerException(MessageFormat.format("receiptItem2.itemReceipt.receiptId={0} is not valid", receiptItem2.getItemReceipt().getReceiptId())); + throw new NullPointerException(MessageFormat.format("receiptItem2.itemReceipt.receiptId={0} is not valid", receiptItem2.getItemReceipt().getReceiptId())); //NOI18N } else if (receiptItem2.getItemProduct() == null) { // Throw NPE again - throw new NullPointerException("receiptItem2.itemProduct is null."); + throw new NullPointerException("receiptItem2.itemProduct is null."); //NOI18N } else if (receiptItem2.getItemProduct().getProductId() == null) { // Throw NPE again - throw new NullPointerException("receiptItem2.itemProduct.productId is null."); + throw new NullPointerException("receiptItem2.itemProduct.productId is null."); //NOI18N } else if (receiptItem2.getItemProduct().getProductId() < 1) { // Throw IAE - throw new IllegalArgumentException(MessageFormat.format("receiptItem2.itemProduct.productId={0} is invalid.", receiptItem2.getItemProduct().getProductId())); + throw new IllegalArgumentException(MessageFormat.format("receiptItem2.itemProduct.productId={0} is invalid.", receiptItem2.getItemProduct().getProductId())); //NOI18N } else if (null == receiptItem2) { // Throw NPE - throw new NullPointerException("receiptItem2 is null"); + throw new NullPointerException("receiptItem2 is null"); //NOI18N } // Now check all individually -- 2.39.5