From: Roland Häder Date: Tue, 18 Oct 2022 13:58:50 +0000 (+0200) Subject: Continued: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=8a9856aec6624e76aece51db15c740f048179e7b;p=jproduct-core.git Continued: - convention is to check parameters in the order they appear in method - added missing productAvailability to hashCode() method (always add in both) --- diff --git a/src/org/mxchange/jproduct/model/product/GenericProduct.java b/src/org/mxchange/jproduct/model/product/GenericProduct.java index 428244a..0aca37c 100644 --- a/src/org/mxchange/jproduct/model/product/GenericProduct.java +++ b/src/org/mxchange/jproduct/model/product/GenericProduct.java @@ -227,36 +227,36 @@ public class GenericProduct implements Product { this(); // Validate all parameters - if (null == productAvailability) { + if (null == productI18nKey) { // Throw NPE - throw new NullPointerException("productAvailability is null"); //NOI18N - } else if (null == productCategory) { - // Throw it again - throw new NullPointerException("productCategory is null"); //NOI18N - } else if (productCategory.getCategoryId() == null) { + throw new NullPointerException("productI18nKey is null"); //NOI18N + } else if (productI18nKey.isEmpty()) { + // Throw IAE + throw new IllegalArgumentException("productI18nKey is empty"); //NOI18N + } else if (null == productGrossPrice) { // Throw it again - throw new NullPointerException("productCategory.categoryId is null"); //NOI18N - } else if (productCategory.getCategoryId() < 1) { + throw new NullPointerException("productGrossPrice is null"); //NOI18N + } else if (productGrossPrice.longValue() < 0) { // Throw IAE - throw new IllegalArgumentException(MessageFormat.format("productCategory.categoryId={0} is invalid", productCategory.getCategoryId())); //NOI18N + throw new IllegalArgumentException(MessageFormat.format("productGrossPrice={0} is invalid. Do not enter discounts as products.", productGrossPrice)); //NOI18N } else if (null == productCurrencyCode) { // Throw it again throw new NullPointerException("productCurrencyCode is null"); //NOI18N } else if (productCurrencyCode.isEmpty()) { // Throw IAE throw new IllegalArgumentException("productCurrencyCode is empty"); //NOI18N - } else if (null == productGrossPrice) { + } else if (null == productCategory) { // Throw it again - throw new NullPointerException("productGrossPrice is null"); //NOI18N - } else if (productGrossPrice.longValue() < 0) { - // Throw IAE - throw new IllegalArgumentException(MessageFormat.format("productGrossPrice={0} is invalid. Do not enter discounts as products.", productGrossPrice)); //NOI18N - } else if (null == productI18nKey) { + throw new NullPointerException("productCategory is null"); //NOI18N + } else if (productCategory.getCategoryId() == null) { + // Throw it again + throw new NullPointerException("productCategory.categoryId is null"); //NOI18N + } else if (null == productAvailability) { // Throw NPE - throw new NullPointerException("productI18nKey is null"); //NOI18N - } else if (productI18nKey.isEmpty()) { + throw new NullPointerException("productAvailability is null"); //NOI18N + } else if (productCategory.getCategoryId() < 1) { // Throw IAE - throw new IllegalArgumentException("productI18nKey is empty"); //NOI18N + throw new IllegalArgumentException(MessageFormat.format("productCategory.categoryId={0} is invalid", productCategory.getCategoryId())); //NOI18N } else if (null == productUnitAmount) { // Throw it again throw new NullPointerException("productUnitAmount is null"); //NOI18N @@ -563,6 +563,7 @@ public class GenericProduct implements Product { int hash = 7; hash = 23 * hash + Objects.hashCode(this.getProductAgeGroup()); + hash = 23 * hash + Objects.hashCode(this.getProductAvailability()); hash = 23 * hash + Objects.hashCode(this.getProductBarCodeNumber()); hash = 23 * hash + Objects.hashCode(this.getProductCategory()); hash = 23 * hash + Objects.hashCode(this.getProductCurrencyCode());