From 361b3cc9f25141cb86aebc75b51b2ffc1b6eb8bc Mon Sep 17 00:00:00 2001 From: Roland Haeder Date: Sun, 10 Apr 2016 16:29:46 +0200 Subject: [PATCH] introduced clear() for clean code style --- .../PizzaAdminCategoryWebRequestBean.java | 11 +++++++++-- .../product/PizzaAdminProductWebRequestBean.java | 15 +++++++++++---- .../beans/user/PizzaUserWebSessionBean.java | 1 + 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/src/java/org/mxchange/pizzaapplication/beans/category/PizzaAdminCategoryWebRequestBean.java b/src/java/org/mxchange/pizzaapplication/beans/category/PizzaAdminCategoryWebRequestBean.java index 35df9066..e7a21692 100644 --- a/src/java/org/mxchange/pizzaapplication/beans/category/PizzaAdminCategoryWebRequestBean.java +++ b/src/java/org/mxchange/pizzaapplication/beans/category/PizzaAdminCategoryWebRequestBean.java @@ -102,8 +102,7 @@ public class PizzaAdminCategoryWebRequestBean implements PizzaAdminCategoryWebRe this.categoryAddedEvent.fire(new ShopCategoryAddedEvent(updatedCategory)); // Unset all older values - this.setCategoryTitle(""); //NOI18N - this.setParentCategory(null); + this.clear(); } catch (final CategoryTitleAlreadyUsedException | CannotAddCategoryException ex) { // Continue to throw throw new FaceletException(ex); @@ -130,4 +129,12 @@ public class PizzaAdminCategoryWebRequestBean implements PizzaAdminCategoryWebRe this.parentCategory = parentCategory; } + /** + * Clears this bean (example: when category has been added) + */ + private void clear () { + this.setCategoryTitle(""); //NOI18N + this.setParentCategory(null); + } + } diff --git a/src/java/org/mxchange/pizzaapplication/beans/product/PizzaAdminProductWebRequestBean.java b/src/java/org/mxchange/pizzaapplication/beans/product/PizzaAdminProductWebRequestBean.java index 3d115e09..faa17b4b 100644 --- a/src/java/org/mxchange/pizzaapplication/beans/product/PizzaAdminProductWebRequestBean.java +++ b/src/java/org/mxchange/pizzaapplication/beans/product/PizzaAdminProductWebRequestBean.java @@ -117,10 +117,7 @@ public class PizzaAdminProductWebRequestBean implements PizzaAdminProductWebRequ this.addedProductEvent.fire(new ShopProductAddedEvent(updatedProduct)); // Set all to null - this.setProductAvailability(Boolean.FALSE); - this.setProductCategory(null); - this.setProductPrice(null); - this.setProductTitle(null); + this.clear(); } catch (final ProductTitleAlreadyUsedException | CannotAddProductException ex) { // Continue to throw throw new FaceletException(ex); @@ -173,4 +170,14 @@ public class PizzaAdminProductWebRequestBean implements PizzaAdminProductWebRequ this.productTitle = productTitle; } + /** + * Clears this bean (example: product has been added) + */ + private void clear () { + this.setProductAvailability(Boolean.FALSE); + this.setProductCategory(null); + this.setProductPrice(null); + this.setProductTitle(null); + } + } diff --git a/src/java/org/mxchange/pizzaapplication/beans/user/PizzaUserWebSessionBean.java b/src/java/org/mxchange/pizzaapplication/beans/user/PizzaUserWebSessionBean.java index a71bd4c8..4b99a4d0 100644 --- a/src/java/org/mxchange/pizzaapplication/beans/user/PizzaUserWebSessionBean.java +++ b/src/java/org/mxchange/pizzaapplication/beans/user/PizzaUserWebSessionBean.java @@ -911,4 +911,5 @@ public class PizzaUserWebSessionBean implements PizzaUserWebSessionController { this.setBirthday(user.getUserContact().getContactBirthday()); this.setComment(user.getUserContact().getContactComment()); } + } -- 2.39.5