From 9f798cb4fa7d73c9bf6899107cea362aaccb342f Mon Sep 17 00:00:00 2001 From: Roland Haeder Date: Fri, 11 Sep 2015 15:37:06 +0200 Subject: [PATCH] =?utf8?q?Introduced=20new=20exceptions=20Signed-off-by:Ro?= =?utf8?q?land=20H=C3=A4der=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- lib/jcoreee.jar | Bin 13934 -> 18417 bytes .../BasketItemAlreadyAddedException.java | 2 +- .../CannotAddCategoryException.java | 40 ++++++++++++++++++ .../exceptions/CannotAddProductException.java | 40 ++++++++++++++++++ .../CategoryTitleAlreadyUsedException.java | 10 ----- .../ProductTitleAlreadyUsedException.java | 10 ----- .../jshopcore/model/item/BasketItem.java | 20 +++++++++ 7 files changed, 101 insertions(+), 21 deletions(-) create mode 100644 src/org/mxchange/jshopcore/exceptions/CannotAddCategoryException.java create mode 100644 src/org/mxchange/jshopcore/exceptions/CannotAddProductException.java diff --git a/lib/jcoreee.jar b/lib/jcoreee.jar index b2760ebae295cbad0437e4e512da91af8eca0b2c..893d1f9aad9b8ec2bf4607d123795b6547d7a940 100644 GIT binary patch delta 4659 zcma)Adr(}}8UNjV-QBx)fh;VrKnURt%Nr8HCMJ-C5CnlhUPKf($p%qekU+Jzbxnp0VPI&G)wOzX4u_uX9#L?`2td(Y#Z z?>pZ)=llJ>@8n-&A0E=ozAn4N0NlWv(}&Fp+Z)q|n;){V{(6DDKdRtcE!OI#=+l~| zIH0YR;uWn`3b(CCitV=g^w{(bJEN1e^HuV5{gPz==v4HE;m8f+)3K?AW47DYii$^U z8yCGf9qM@e=!1)&wFB~$smJoOmCv4AQ)9r3d^eUDD8Nz=3=|rC73nB;qr`v zMQX<)v60%I>9MiC@zK~+bh7>CUD1iD(eapul%3PD-DA;$(Y*yR4lt2|DihVnR6QxB z>YSrS-R-Vdg~9B&XCyi`Ff} z!2TQ@&#=daMbgjlKp|y{DP00TTV_H6>BwNqfdDd-+J-sWhB%NzbFB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^yG0$n&?31i@xd_@`*A?_rj>g8anNL-4+#v&KZPpY891z=Miv(r%A^&LpQZgx z{yF`VfJzGWFfuBQbcJK4N@Hi%Y8KWr%4=y1BAZ#%5Mp{YR+UPr#v?nCi#+BeleKY~ zrJ+(kEw}mCO>|g#z*`eBEn%5+a9%{Ev(BSc&Y;}ya{e6dffUQ^dmAF+UW8|$%yQ2` zpNA1~U4cI3)vnxK40tXfNBwEJS2hT4@Y+I}<$4{yMVJGYYaYJqZ_;iGD+6e=&($VB z_7_eZL^lrOQI5wE$4Ly~3{K$%Byjzn#?Nk%c5XV-VSV# z()XJDAh=&vXIs7l0<{89(hGryVOwHF#JcF=_XYmaU`7+!Tl6ym<;W><&n7|okt#=I}cvUd9Dlo&96z zghn*|aQ3y_geE`ES&)wWYZE=pW-4=Yr>wl9(sHuJRj|cHTw26!IU~Xn@6>rx>hypf z@calLSR$a;L=4Mi88$}Vs(cr&ODJ9>KFa)pW$z(Q43@n<2V)-Ii2Dj&tz3dD;&k$F+kC1frjOT#62EBqOA z2-qSsFe=!LgAt!Ud&R7eWjmK10mCNCf_v z$bEx#`X+kuHV)thrGJYf_zNDvC)D#f2Jt0}@HUaXiB`^GB9$AvZOr+oYJ`}pBCumj zu0ooZrWc8}Dgrx*-%~{`ahQwWumx;o<_hp39otH0nL)z3gj8|$yd4zS@6hRp4fZ>9 zy}}0j9Uh>TjW7*gplO1tT|DEb#9s>$(aKFx=y$2v5cU-!>lyOLc>$VtARvPknXlX?07?9;vTz@^LYHw(%WBkQM_)jj9Y>7q{IUVg%WGT8w5no%6B1hXERpfeGiwrjlxzKJFDi`SI>aSvz zOULKY3-UsHsq}UDZMpm3G^>KRJo%9fw}Y_;mESret~?_Bn4 z=#7q2Tk!rHeogZ7. + */ +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); + } } -- 2.39.5