]> git.mxchange.org Git - jproduct-core.git/commitdiff
added event for when a shop category has been added
authorRoland Haeder <roland@mxchange.org>
Sun, 10 Apr 2016 13:53:57 +0000 (15:53 +0200)
committerRoland Haeder <roland@mxchange.org>
Sun, 10 Apr 2016 13:53:57 +0000 (15:53 +0200)
lib/jcoreee.jar
src/org/mxchange/jshopcore/events/category/AddedCategoryEvent.java [new file with mode: 0644]
src/org/mxchange/jshopcore/events/category/ShopCategoryAddedEvent.java [new file with mode: 0644]

index 3a32dfff27965a3b537e31aae5fea9bcc5de3288..ad61871dc3c447ae7b78f28e4fee6bf4892cb44f 100644 (file)
Binary files a/lib/jcoreee.jar and b/lib/jcoreee.jar differ
diff --git a/src/org/mxchange/jshopcore/events/category/AddedCategoryEvent.java b/src/org/mxchange/jshopcore/events/category/AddedCategoryEvent.java
new file mode 100644 (file)
index 0000000..bdef944
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2016 Roland Haeder<roland@mxchange.org>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero 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 Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.jshopcore.events.category;
+
+import java.io.Serializable;
+import org.mxchange.jshopcore.model.category.Category;
+
+/**
+ * An interface for added category events
+ * <p>
+ * @author Roland Haeder<roland@mxchange.org>
+ */
+public interface AddedCategoryEvent extends Serializable {
+
+       /**
+        * Getter for added category instance
+        * <p>
+        * @return Added category instance
+        */
+       public Category getAddedCategory ();
+
+}
diff --git a/src/org/mxchange/jshopcore/events/category/ShopCategoryAddedEvent.java b/src/org/mxchange/jshopcore/events/category/ShopCategoryAddedEvent.java
new file mode 100644 (file)
index 0000000..59f279f
--- /dev/null
@@ -0,0 +1,69 @@
+/*
+ * Copyright (C) 2016 Roland Haeder
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero 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 Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.jshopcore.events.category;
+
+import java.text.MessageFormat;
+import org.mxchange.jshopcore.model.category.Category;
+
+/**
+ * An event fired when a new shop category has been added.
+ * <p>
+ * @author Roland Haeder<roland@mxchange.org>
+ */
+public class ShopCategoryAddedEvent implements AddedCategoryEvent {
+
+       /**
+        * Serial number
+        */
+       private static final long serialVersionUID = 83_275_471_765_091_760L;
+
+       /**
+        * Category instance that has been added
+        */
+       private final Category addedCategory;
+
+       /**
+        * Constructor with added category instance
+        * <p>
+        * @param addedCategory Added category
+        */
+       public ShopCategoryAddedEvent (final Category addedCategory) {
+               // The category should be valid
+               if (null == addedCategory) {
+                       // Is NULL, throw NPE
+                       throw new NullPointerException("addedCategory is null"); //NOI18N
+               } else if (addedCategory.getCategoryTitle().isEmpty()) {
+                       // Empty title
+                       throw new IllegalArgumentException("addedCategory.categoryTitle is empty"); //NOI18N
+               } else if (addedCategory.getCategoryId() == null) {
+                       // Id is NULL
+                       throw new NullPointerException("addedCategory.categoryId is null"); //NOI18N
+               } else if (addedCategory.getCategoryId() <= 0) {
+                       // Not valid id
+                       throw new IllegalArgumentException(MessageFormat.format("addedCategory.categoryId={0} is not valid.", addedCategory.getCategoryId())); //NOI18N
+               }
+
+               // Set it here
+               this.addedCategory = addedCategory;
+       }
+
+       @Override
+       public Category getAddedCategory () {
+               return this.addedCategory;
+       }
+
+}