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
*/
--- /dev/null
+/*
+ * 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);
+ }
+}
--- /dev/null
+/*
+ * 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);
+ }
+}
// 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);
- }
}
// 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
- }
}
// 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);
+ }
}