From d26ff0b8f59d53d0fa6af5bfa7e3f8729cac5efe Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Fri, 24 Apr 2020 18:36:17 +0200 Subject: [PATCH] Don't cherry-pick: - added all fields (except primary key) for equals()/hashCode(). It should be possible to distinguish two entities without comparing the primary key. - Or? Hmm ... MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Roland Häder --- .../receipt_item/FinancialReceiptItem.java | 22 ++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/src/org/mxchange/jfinancials/model/receipt_item/FinancialReceiptItem.java b/src/org/mxchange/jfinancials/model/receipt_item/FinancialReceiptItem.java index 31d2d85..379d455 100644 --- a/src/org/mxchange/jfinancials/model/receipt_item/FinancialReceiptItem.java +++ b/src/org/mxchange/jfinancials/model/receipt_item/FinancialReceiptItem.java @@ -248,7 +248,17 @@ public class FinancialReceiptItem implements BillableReceiptItem { final BillableReceiptItem receiptItem = (BillableReceiptItem) object; - if (!Objects.equals(this.getItemId(), receiptItem.getItemId())) { + if (!Objects.equals(this.getItemBrandName(), receiptItem.getItemBrandName())) { + return false; + } else if (!Objects.equals(this.getItemCouponNumber(), receiptItem.getItemCouponNumber())) { + return false; + } else if (!Objects.equals(this.getItemGrossPrice(), receiptItem.getItemGrossPrice())) { + return false; + } else if (!Objects.equals(this.getItemIsDiscount(), receiptItem.getItemIsDiscount())) { + return false; + } else if (!Objects.equals(this.getItemIsRefund(), receiptItem.getItemIsRefund())) { + return false; + } else if (!Objects.equals(this.getItemManufacturer(), receiptItem.getItemManufacturer())) { return false; } else if (!Objects.equals(this.getItemNumber(), receiptItem.getItemNumber())) { return false; @@ -258,7 +268,7 @@ public class FinancialReceiptItem implements BillableReceiptItem { return false; } else if (!Objects.equals(this.getItemReceipt(), receiptItem.getItemReceipt())) { return false; - } else if (!Objects.equals(this.getItemCouponNumber(), receiptItem.getItemCouponNumber())) { + } else if (!Objects.equals(this.getItemTaxRate(), receiptItem.getItemTaxRate())) { return false; } @@ -423,12 +433,18 @@ public class FinancialReceiptItem implements BillableReceiptItem { public int hashCode () { int hash = 5; + hash = 53 * hash + Objects.hashCode(this.getItemBrandName()); + hash = 53 * hash + Objects.hashCode(this.getItemCouponNumber()); + hash = 53 * hash + Objects.hashCode(this.getItemGrossPrice()); hash = 53 * hash + Objects.hashCode(this.getItemId()); + hash = 53 * hash + Objects.hashCode(this.getItemIsDiscount()); + hash = 53 * hash + Objects.hashCode(this.getItemIsRefund()); + hash = 53 * hash + Objects.hashCode(this.getItemManufacturer()); hash = 53 * hash + Objects.hashCode(this.getItemNumber()); hash = 53 * hash + Objects.hashCode(this.getItemProduct()); hash = 53 * hash + Objects.hashCode(this.getItemProductQuantity()); hash = 53 * hash + Objects.hashCode(this.getItemReceipt()); - hash = 53 * hash + Objects.hashCode(this.getItemCouponNumber()); + hash = 53 * hash + Objects.hashCode(this.getItemTaxRate()); return hash; } -- 2.39.5