]> git.mxchange.org Git - jproduct-core.git/commitdiff
Continued:
authorRoland Häder <roland@mxchange.org>
Tue, 18 Oct 2022 13:58:50 +0000 (15:58 +0200)
committerRoland Häder <roland@mxchange.org>
Tue, 18 Oct 2022 14:00:52 +0000 (16:00 +0200)
- convention is to check parameters in the order they appear in method
- added missing productAvailability to hashCode() method (always add in both)

src/org/mxchange/jproduct/model/product/GenericProduct.java

index 428244a8a450d6f74a3ce946219a51d11c405383..0aca37c01602f79a4acad4052839b0ee4ce9902e 100644 (file)
@@ -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());