]> git.mxchange.org Git - jproduct-core.git/commitdiff
Introduced new exceptions
authorRoland Haeder <roland@mxchange.org>
Fri, 11 Sep 2015 13:37:06 +0000 (15:37 +0200)
committerRoland Haeder <roland@mxchange.org>
Fri, 11 Sep 2015 13:37:06 +0000 (15:37 +0200)
Signed-off-by:Roland Häder <roland@mxchange.org>

lib/jcoreee.jar
src/org/mxchange/jshopcore/exceptions/BasketItemAlreadyAddedException.java
src/org/mxchange/jshopcore/exceptions/CannotAddCategoryException.java [new file with mode: 0644]
src/org/mxchange/jshopcore/exceptions/CannotAddProductException.java [new file with mode: 0644]
src/org/mxchange/jshopcore/exceptions/CategoryTitleAlreadyUsedException.java
src/org/mxchange/jshopcore/exceptions/ProductTitleAlreadyUsedException.java
src/org/mxchange/jshopcore/model/item/BasketItem.java

index b2760ebae295cbad0437e4e512da91af8eca0b2c..893d1f9aad9b8ec2bf4607d123795b6547d7a940 100644 (file)
Binary files a/lib/jcoreee.jar and b/lib/jcoreee.jar differ
index efd249227e2dbc15bd687bd610853476b4632273..ca4cbeb1847869d9a92ce05e8a9e043000f5f83b 100644 (file)
@@ -20,7 +20,7 @@ import java.text.MessageFormat;
 import org.mxchange.jshopcore.model.basket.AddableBasketItem;
 
 /**
- * An exception thrown when the given item is already added to the basket.
+ * An exception thrown when the given item is already added to the basketController.
  *
  * @author Roland Haeder
  */
diff --git a/src/org/mxchange/jshopcore/exceptions/CannotAddCategoryException.java b/src/org/mxchange/jshopcore/exceptions/CannotAddCategoryException.java
new file mode 100644 (file)
index 0000000..1322005
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2015 Roland Haeder
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.jshopcore.exceptions;
+
+/**
+ * An exception thrown when the category cannot be added for a "low level"
+ * reason.
+ *
+ * @author Roland Haeder
+ */
+public class CannotAddCategoryException extends Exception {
+       /**
+        * Serial number
+        */
+       private static final long serialVersionUID = 34_295_843_957_951L;
+
+       /**
+        * Constructor with cause
+        *
+        * @param cause Causing exception
+        */
+       public CannotAddCategoryException (final Throwable cause) {
+               // Call super constructor
+               super(cause);
+       }
+}
diff --git a/src/org/mxchange/jshopcore/exceptions/CannotAddProductException.java b/src/org/mxchange/jshopcore/exceptions/CannotAddProductException.java
new file mode 100644 (file)
index 0000000..feef839
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2015 Roland Haeder
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.jshopcore.exceptions;
+
+/**
+ * An exception thrown when the product cannot be added for a "low level"
+ * reason.
+ *
+ * @author Roland Haeder
+ */
+public class CannotAddProductException extends Exception {
+       /**
+        * Serial number
+        */
+       private static final long serialVersionUID = 48_574_857_485_748_175L;
+
+       /**
+        * Constructor with cause
+        *
+        * @param cause Causing exception
+        */
+       public CannotAddProductException (final Throwable cause) {
+               // Call super constructor
+               super(cause);
+       }
+}
index fa290f4819f9f473a70c8cab62fc611561b7394c..1718f0102dd2474528940cb68375d43dba101eb9 100644 (file)
@@ -39,14 +39,4 @@ public class CategoryTitleAlreadyUsedException extends Exception {
                // Call super constructor
                super(MessageFormat.format("Title {0} is already used.", category.getTitle())); //NOI18N
        }
-
-       /**
-        * Constructor with HttpServletRequest instance
-        *
-        * @param cause Cause for this exception
-        */
-       public CategoryTitleAlreadyUsedException (final Throwable cause) {
-               // Call super constructor
-               super(cause);
-       }
 }
index 53ec406389c1f34bf78dde57397581b3f16f3182..dffa4b706cd34570e1c24aaf5191d0b1e11fd90e 100644 (file)
@@ -39,14 +39,4 @@ public class ProductTitleAlreadyUsedException extends Exception {
                // Call super constructor
                super(MessageFormat.format("Title {0} is already used.", product.getTitle())); //NOI18N
        }
-
-       /**
-        * Constructor with HttpServletRequest instance
-        *
-        * @param cause Cause for this exception
-        */
-       public ProductTitleAlreadyUsedException (final Throwable cause) {
-               // Call super constructor
-               super(cause); //NOI18N
-       }
 }
index 52d6d9e91259796d09cba542edd34e50c8c5cbee..b09b2735d86b295b79b0a712e1d2a49235b33f3c 100644 (file)
@@ -58,4 +58,24 @@ public class BasketItem extends BaseItem implements AddableBasketItem {
                // Copy instance
                this.setProduct(product);
        }
+
+       /**
+        * Constructor for an item from given Product instance and amount.
+        * 
+        * @param product Product instance
+        * @param amount Ordered amount
+        */
+       public BasketItem (final Product product, final Long amount) {
+               // Other constructor
+               this(product);
+
+               // amount must not be null
+               if (null == amount) {
+                       // Abort here
+                       throw new NullPointerException("amount is null"); //NOI18N
+               }
+
+               // Set amount
+               this.setAmount(amount);
+       }
 }