]> git.mxchange.org Git - pizzaservice-war.git/commitdiff
introduced clear() for clean code style
authorRoland Haeder <roland@mxchange.org>
Sun, 10 Apr 2016 14:29:46 +0000 (16:29 +0200)
committerRoland Haeder <roland@mxchange.org>
Sun, 10 Apr 2016 14:30:23 +0000 (16:30 +0200)
src/java/org/mxchange/pizzaapplication/beans/category/PizzaAdminCategoryWebRequestBean.java
src/java/org/mxchange/pizzaapplication/beans/product/PizzaAdminProductWebRequestBean.java
src/java/org/mxchange/pizzaapplication/beans/user/PizzaUserWebSessionBean.java

index 35df9066701ca13d449f7c5c13220e1ff477bb1a..e7a21692ddd99022e3a52f14afe6bcf8a5d56b5e 100644 (file)
@@ -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);
+       }
+
 }
index 3d115e0945612a0d918a0ee6732a5879c7b48954..faa17b4b126322c716bfe13f86d28cc290175115 100644 (file)
@@ -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);
+       }
+
 }
index a71bd4c80e82610d9468e299a1ce5074c8dc77d1..4b99a4d0d5da730a10ebbdafaa3c058e6564686d 100644 (file)
@@ -911,4 +911,5 @@ public class PizzaUserWebSessionBean implements PizzaUserWebSessionController {
                this.setBirthday(user.getUserContact().getContactBirthday());
                this.setComment(user.getUserContact().getContactComment());
        }
+
 }