From: Roland Häder Date: Sat, 5 Nov 2022 07:07:03 +0000 (+0100) Subject: Continued: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=718e3d3a53da783918ed440916b13149bfbb984c;p=jproduct-core.git Continued: - also compare primary keys --- diff --git a/src/org/mxchange/jproduct/model/category/ProductCategory.java b/src/org/mxchange/jproduct/model/category/ProductCategory.java index 418b6ec..643aeb3 100644 --- a/src/org/mxchange/jproduct/model/category/ProductCategory.java +++ b/src/org/mxchange/jproduct/model/category/ProductCategory.java @@ -151,8 +151,10 @@ public class ProductCategory implements Category { final int comparators[] = { // First check parent category CategoryUtils.compare(this.getParentCategory(), category.getParentCategory()), - // ... last is i18n key as it is unique - StringUtils.compare(this.getCategoryI18nKey(), category.getCategoryI18nKey()) + // ... i18n key as it is unique + StringUtils.compare(this.getCategoryI18nKey(), category.getCategoryI18nKey()), + // ... primary key + Long.compare(this.getCategoryId(), category.getCategoryId()) }; // Check all values @@ -256,9 +258,9 @@ public class ProductCategory implements Category { int hash = 7; hash = 13 * hash + Objects.hashCode(this.getCategoryI18nKey()); - hash = 13 * hash + Objects.hashCode(this.getCategoryId()); hash = 13 * hash + Objects.hashCode(this.getCategoryShownInStatistics()); hash = 13 * hash + Objects.hashCode(this.getParentCategory()); + hash = 13 * hash + Objects.hashCode(this.getCategoryId()); return hash; } diff --git a/src/org/mxchange/jproduct/model/product/GenericProduct.java b/src/org/mxchange/jproduct/model/product/GenericProduct.java index 84a7294..5642d8e 100644 --- a/src/org/mxchange/jproduct/model/product/GenericProduct.java +++ b/src/org/mxchange/jproduct/model/product/GenericProduct.java @@ -294,7 +294,9 @@ public class GenericProduct implements Product { // Init comparators final int comparators[] = { - // First check product number + // First compare id numbers + Long.compare(this.getProductId(), product.getProductId()), + // ... next product number SafeNumberUtils.compare(this.getProductNumber(), product.getProductNumber()), // ... bar-code number StringUtils.compare(this.getProductBarCodeNumber(), product.getProductBarCodeNumber()),