@Column (name = "product_net_price")
private Float productNetPrice;
+ /**
+ * Number of product
+ */
+ @Column (name = "product_number")
+ private Long productNumber;
+
/**
* Tax rate (0-1, by 1=100%)
*/
/**
* Amount of this product (for example 1 for 1 liter)
*/
- @Column (name = "product_unit_amount")
+ @Basic (optional = false)
+ @Column (name = "product_unit_amount", nullable = false)
private Float productUnitAmount;
/**
* Unit type (for example liter)
*/
- @Column (name = "product_unit_type")
- private String productUnitType;
+ @Basic (optional = false)
+ @Column (name = "product_unit_i18n_key", nullable = false)
+ private String productUnitI18nKey;
/**
* Default constructor
* @param productCurrencyCode Currency code for both prices
* @param productCategory Category instance
* @param productAvailability Availability (selectable by customer)
+ * @param productUnitAmount Unit amount
+ * @param productUnitI18nKey Unit's i18n key
+ * <p>
* @throws NullPointerException If a parameter is null
- * @throws IllegalArgumentException If a parameter is empty (string) or out of bounds
+ * @throws IllegalArgumentException If a parameter is empty (string) or out
+ * of bounds
*/
- public GenericProduct (final String productI18nKey, final Float productGrossPrice, final String productCurrencyCode, final Category productCategory, final Boolean productAvailability) {
+ public GenericProduct (final String productI18nKey, final Float productGrossPrice, final String productCurrencyCode, final Category productCategory, final Boolean productAvailability, final Float productUnitAmount, final String productUnitI18nKey) {
// Call other constructor first
this();
} else if (productI18nKey.isEmpty()) {
// Throw IAE
throw new IllegalArgumentException("productI18nKey is empty"); //NOI18N
+ } else if (null == productUnitAmount) {
+ // Throw it again
+ throw new NullPointerException("productUnitAmount is null"); //NOI18N
+ } else if (productUnitAmount < 0) {
+ // Throw IAE
+ throw new IllegalArgumentException(MessageFormat.format("productUnitAmount={0} is invalid. Do not enter discounts as products.", productUnitAmount)); //NOI18N
+ } else if (null == productUnitI18nKey) {
+ // Throw NPE
+ throw new NullPointerException("productUnitI18nKey is null"); //NOI18N
+ } else if (productUnitI18nKey.isEmpty()) {
+ // Throw IAE
+ throw new IllegalArgumentException("productUnitI18nKey is empty"); //NOI18N
}
// Set all here
this.productCurrencyCode = productCurrencyCode.toUpperCase();
this.productCategory = productCategory;
this.productAvailability = productAvailability;
+ this.productUnitAmount = productUnitAmount;
+ this.productUnitI18nKey = productUnitI18nKey;
}
@Override
this.productNetPrice = productNetPrice;
}
+ @Override
+ public Long getProductNumber () {
+ return this.productNumber;
+ }
+
+ @Override
+ public void setProductNumber (final Long productNumber) {
+ this.productNumber = productNumber;
+ }
+
@Override
public Float getProductTaxRate () {
return this.productTaxRate;
}
@Override
- public String getProductUnitType () {
- return this.productUnitType;
+ public String getProductUnitI18nKey () {
+ return this.productUnitI18nKey;
}
@Override
- public void setProductUnitType (final String productUnitType) {
- this.productUnitType = productUnitType;
+ public void setProductUnitI18nKey (final String productUnitI18nKey) {
+ this.productUnitI18nKey = productUnitI18nKey;
}
@Override
void setProductUnitAmount (final Float productUnitAmount);
/**
- * Getter for product's unit type
+ * Getter for product's i18n key
* <p>
- * @return Product's unit type
+ * @return Product's i18n key
*/
- String getProductUnitType ();
+ String getProductUnitI18nKey ();
/**
- * Setter for product's unit type
+ * Setter for product's i18n key
* <p>
- * @param productUnitType Product's unit type
+ * @param productI18nKey Product's i18n key
*/
- void setProductUnitType (final String productUnitType);
+ void setProductUnitI18nKey (final String productI18nKey);
+
+ /**
+ * Getter for product's number
+ * <p>
+ * @return Product's number
+ */
+ Long getProductNumber ();
+
+ /**
+ * Setter for product's number
+ * <p>
+ * @param productNumber Product's number
+ */
+ void setProductNumber (final Long productNumber);
@Override
boolean equals (final Object object);