From 7b51150138a68f7ab0a074b7054c8c141d8cf4e3 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Thu, 6 Oct 2022 15:34:37 +0200 Subject: [PATCH] Continued: - renamed utility classes *s to *Utils - moved them to their own package --- .../jproduct/model/category/ProductCategory.java | 6 ++++-- .../jproduct/model/product/GenericProduct.java | 14 +++++++------- .../Categories.java => utils/CategoryUtils.java} | 7 ++++--- .../Products.java => utils/ProductUtils.java} | 7 ++++--- 4 files changed, 19 insertions(+), 15 deletions(-) rename src/org/mxchange/jproduct/model/{category/Categories.java => utils/CategoryUtils.java} (94%) rename src/org/mxchange/jproduct/model/{product/Products.java => utils/ProductUtils.java} (95%) diff --git a/src/org/mxchange/jproduct/model/category/ProductCategory.java b/src/org/mxchange/jproduct/model/category/ProductCategory.java index ef537fd..4c1a7ab 100644 --- a/src/org/mxchange/jproduct/model/category/ProductCategory.java +++ b/src/org/mxchange/jproduct/model/category/ProductCategory.java @@ -33,7 +33,9 @@ import javax.persistence.Table; import javax.persistence.Temporal; import javax.persistence.TemporalType; import javax.persistence.Transient; +import org.apache.commons.lang3.StringUtils; import org.mxchange.jcoreutils.Comparables; +import org.mxchange.jproduct.model.utils.CategoryUtils; /** * A product category @@ -148,9 +150,9 @@ public class ProductCategory implements Category { // Init comparators final int comparators[] = { // First check parent category - Categories.compare(this.getParentCategory(), category.getParentCategory()), + CategoryUtils.compare(this.getParentCategory(), category.getParentCategory()), // ... last is i18n key as it is unique - this.getCategoryI18nKey().compareTo(category.getCategoryI18nKey()) + StringUtils.compare(this.getCategoryI18nKey(), category.getCategoryI18nKey()) }; // Check all values diff --git a/src/org/mxchange/jproduct/model/product/GenericProduct.java b/src/org/mxchange/jproduct/model/product/GenericProduct.java index 2454b84..04457e3 100644 --- a/src/org/mxchange/jproduct/model/product/GenericProduct.java +++ b/src/org/mxchange/jproduct/model/product/GenericProduct.java @@ -40,14 +40,14 @@ import javax.persistence.TemporalType; import javax.persistence.Transient; import org.apache.commons.lang3.StringUtils; import org.mxchange.jcontactsbusiness.model.basicdata.BasicData; -import org.mxchange.jcontactsbusiness.model.basicdata.BasicDataUtils; import org.mxchange.jcontactsbusiness.model.basicdata.BusinessBasicData; +import org.mxchange.jcontactsbusiness.model.utils.BasicDataUtils; import org.mxchange.jcoreutils.Comparables; import org.mxchange.jcoreutils.SafeNumberUtils; -import org.mxchange.jproduct.model.category.Categories; import org.mxchange.jproduct.model.category.Category; import org.mxchange.jproduct.model.category.ProductCategory; import org.mxchange.jproduct.model.product.agegroup.AgeGroup; +import org.mxchange.jproduct.model.utils.CategoryUtils; /** * Generic product POJO (entity) @@ -301,21 +301,21 @@ public class GenericProduct implements Product { // ... size StringUtils.compare(this.getProductSize(), product.getProductSize()), // ... then i18n key - this.getProductI18nKey().compareTo(product.getProductI18nKey()), + StringUtils.compare(this.getProductI18nKey(), product.getProductI18nKey()), // ... gross price - this.getProductGrossPrice().compareTo(product.getProductGrossPrice()), + SafeNumberUtils.compare(this.getProductGrossPrice(), product.getProductGrossPrice()), // ... net price SafeNumberUtils.compare(this.getProductNetPrice(), product.getProductNetPrice()), // ... tax rate SafeNumberUtils.compare(this.getProductTaxRate(), product.getProductTaxRate()), // ... unit amount - this.getProductUnitAmount().compareTo(product.getProductUnitAmount()), + SafeNumberUtils.compare(this.getProductUnitAmount(), product.getProductUnitAmount()), // ... currency code - this.getProductCurrencyCode().compareTo(product.getProductCurrencyCode()), + StringUtils.compare(this.getProductCurrencyCode(), product.getProductCurrencyCode()), // ... manufacturer BasicDataUtils.compare(this.getProductManufacturer(), product.getProductManufacturer()), // ... category - Categories.compare(this.getProductCategory(), product.getProductCategory()) + CategoryUtils.compare(this.getProductCategory(), product.getProductCategory()) }; // Check all values diff --git a/src/org/mxchange/jproduct/model/category/Categories.java b/src/org/mxchange/jproduct/model/utils/CategoryUtils.java similarity index 94% rename from src/org/mxchange/jproduct/model/category/Categories.java rename to src/org/mxchange/jproduct/model/utils/CategoryUtils.java index 72efca7..891f1d8 100644 --- a/src/org/mxchange/jproduct/model/category/Categories.java +++ b/src/org/mxchange/jproduct/model/utils/CategoryUtils.java @@ -14,17 +14,18 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -package org.mxchange.jproduct.model.category; +package org.mxchange.jproduct.model.utils; import java.io.Serializable; import java.util.Objects; +import org.mxchange.jproduct.model.category.Category; /** * An utilities class for product categories *

* @author Roland Häder */ -public class Categories implements Serializable { +public class CategoryUtils implements Serializable { /** * Serial number @@ -86,7 +87,7 @@ public class Categories implements Serializable { /** * Utility classes should have no instances */ - private Categories () { + private CategoryUtils () { // Private constructor } diff --git a/src/org/mxchange/jproduct/model/product/Products.java b/src/org/mxchange/jproduct/model/utils/ProductUtils.java similarity index 95% rename from src/org/mxchange/jproduct/model/product/Products.java rename to src/org/mxchange/jproduct/model/utils/ProductUtils.java index fc73b10..7c8f383 100644 --- a/src/org/mxchange/jproduct/model/product/Products.java +++ b/src/org/mxchange/jproduct/model/utils/ProductUtils.java @@ -14,17 +14,18 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -package org.mxchange.jproduct.model.product; +package org.mxchange.jproduct.model.utils; import java.io.Serializable; import java.util.Objects; +import org.mxchange.jproduct.model.product.Product; /** * An utilities class for generic products *

* @author Roland Häder */ -public class Products implements Serializable { +public class ProductUtils implements Serializable { /** * Serial number @@ -99,7 +100,7 @@ public class Products implements Serializable { /** * Utility classes should have no instances */ - private Products () { + private ProductUtils () { // Private constructor } -- 2.39.5