From: Roland Haeder Date: Fri, 11 Sep 2015 13:37:06 +0000 (+0200) Subject: Introduced new exceptions X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=9f798cb4fa7d73c9bf6899107cea362aaccb342f;p=jcustomer-core.git Introduced new exceptions Signed-off-by:Roland Häder --- diff --git a/lib/jcoreee.jar b/lib/jcoreee.jar index b2760eb..893d1f9 100644 Binary files a/lib/jcoreee.jar and b/lib/jcoreee.jar differ diff --git a/src/org/mxchange/jshopcore/exceptions/BasketItemAlreadyAddedException.java b/src/org/mxchange/jshopcore/exceptions/BasketItemAlreadyAddedException.java index efd2492..ca4cbeb 100644 --- a/src/org/mxchange/jshopcore/exceptions/BasketItemAlreadyAddedException.java +++ b/src/org/mxchange/jshopcore/exceptions/BasketItemAlreadyAddedException.java @@ -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 index 0000000..1322005 --- /dev/null +++ b/src/org/mxchange/jshopcore/exceptions/CannotAddCategoryException.java @@ -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 . + */ +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 index 0000000..feef839 --- /dev/null +++ b/src/org/mxchange/jshopcore/exceptions/CannotAddProductException.java @@ -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 . + */ +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); + } +} diff --git a/src/org/mxchange/jshopcore/exceptions/CategoryTitleAlreadyUsedException.java b/src/org/mxchange/jshopcore/exceptions/CategoryTitleAlreadyUsedException.java index fa290f4..1718f01 100644 --- a/src/org/mxchange/jshopcore/exceptions/CategoryTitleAlreadyUsedException.java +++ b/src/org/mxchange/jshopcore/exceptions/CategoryTitleAlreadyUsedException.java @@ -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); - } } diff --git a/src/org/mxchange/jshopcore/exceptions/ProductTitleAlreadyUsedException.java b/src/org/mxchange/jshopcore/exceptions/ProductTitleAlreadyUsedException.java index 53ec406..dffa4b7 100644 --- a/src/org/mxchange/jshopcore/exceptions/ProductTitleAlreadyUsedException.java +++ b/src/org/mxchange/jshopcore/exceptions/ProductTitleAlreadyUsedException.java @@ -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 - } } diff --git a/src/org/mxchange/jshopcore/model/item/BasketItem.java b/src/org/mxchange/jshopcore/model/item/BasketItem.java index 52d6d9e..b09b273 100644 --- a/src/org/mxchange/jshopcore/model/item/BasketItem.java +++ b/src/org/mxchange/jshopcore/model/item/BasketItem.java @@ -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); + } }