From: Roland Häder Date: Fri, 24 Apr 2020 16:36:17 +0000 (+0200) Subject: Don't cherry-pick: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=d26ff0b8f59d53d0fa6af5bfa7e3f8729cac5efe;p=jfinancials-core.git 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 ... Signed-off-by: Roland Häder --- 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; }