+ this.productUnitAmount = productUnitAmount;
+ this.productUnitI18nKey = productUnitI18nKey;
+ }
+
+ @Override
+ public int compareTo (final Product product) {
+ // Check parameter on null-reference and equality to this
+ if (null == product) {
+ // Should not happen
+ throw new NullPointerException("product is null"); //NOI18N
+ } else if (product.equals(this)) {
+ // Same object
+ return 0;
+ }
+
+ // Init comparators
+ final int comparators[] = {
+ // First check product number
+ SafeNumberUtils.compare(this.getProductNumber(), product.getProductNumber()),
+ // ... size
+ StringUtils.compare(this.getProductSize(), product.getProductSize()),
+ // ... then i18n key
+ this.getProductI18nKey().compareTo(product.getProductI18nKey()),
+ // ... gross price
+ this.getProductGrossPrice().compareTo(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()),
+ // ... currency code
+ this.getProductCurrencyCode().compareTo(product.getProductCurrencyCode()),
+ // ... manufacturer
+ BasicDataUtils.compare(this.getProductManufacturer(), product.getProductManufacturer()),
+ // ... category
+ Categories.compare(this.getProductCategory(), product.getProductCategory())
+ };
+
+ // Check all values
+ final int comparison = Comparables.checkAll(comparators);
+
+ // Return value
+ return comparison;