]> git.mxchange.org Git - juser-core.git/commitdiff
Added event for user being deleted
authorRoland Häder <roland@mxchange.org>
Mon, 29 Aug 2016 09:20:19 +0000 (11:20 +0200)
committerRoland Häder <roland@mxchange.org>
Mon, 29 Aug 2016 09:52:24 +0000 (11:52 +0200)
src/org/mxchange/jusercore/events/user/delete/AdminDeletedUserEvent.java [new file with mode: 0644]
src/org/mxchange/jusercore/events/user/delete/AdminUserDeletedEvent.java [new file with mode: 0644]

diff --git a/src/org/mxchange/jusercore/events/user/delete/AdminDeletedUserEvent.java b/src/org/mxchange/jusercore/events/user/delete/AdminDeletedUserEvent.java
new file mode 100644 (file)
index 0000000..77b0211
--- /dev/null
@@ -0,0 +1,44 @@
+/*\r
+ * Copyright (C) 2016 Roland Haeder\r
+ *\r
+ * This program is free software: you can redistribute it and/or modify\r
+ * it under the terms of the GNU General Public License as published by\r
+ * the Free Software Foundation, either version 3 of the License, or\r
+ * (at your option) any later version.\r
+ *\r
+ * This program is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+ * GNU General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU General Public License\r
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.\r
+ */\r
+package org.mxchange.jusercore.events.user.delete;\r
+\r
+import java.io.Serializable;\r
+import org.mxchange.jusercore.model.user.User;\r
+\r
+/**\r
+ * An interface for events being fired when an administrator added a new user\r
+ * account.\r
+ * <p>\r
+ * @author Roland Haeder<roland@mxchange.org>\r
+ */\r
+public interface AdminDeletedUserEvent extends Serializable {\r
+\r
+       /**\r
+        * Getter for deleted user instance\r
+        * <p>\r
+        * @return Deleted user instance\r
+        */\r
+       User getDeletedUser ();\r
+\r
+       /**\r
+        * Getter for user delete reason\r
+        * <p>\r
+        * @return User delete reason\r
+        */\r
+       String getUserDeleteReason ();\r
+\r
+}\r
diff --git a/src/org/mxchange/jusercore/events/user/delete/AdminUserDeletedEvent.java b/src/org/mxchange/jusercore/events/user/delete/AdminUserDeletedEvent.java
new file mode 100644 (file)
index 0000000..c08a2f9
--- /dev/null
@@ -0,0 +1,78 @@
+/*\r
+ * Copyright (C) 2016 Roland Haeder\r
+ *\r
+ * This program is free software: you can redistribute it and/or modify\r
+ * it under the terms of the GNU General Public License as published by\r
+ * the Free Software Foundation, either version 3 of the License, or\r
+ * (at your option) any later version.\r
+ *\r
+ * This program is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+ * GNU General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU General Public License\r
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.\r
+ */\r
+package org.mxchange.jusercore.events.user.delete;\r
+\r
+import java.text.MessageFormat;\r
+import org.mxchange.jusercore.model.user.User;\r
+\r
+/**\r
+ * An event being fired when the administrator has deleted a user account\r
+ * <p>\r
+ * @author Roland Haeder<roland@mxchange.org>\r
+ */\r
+public class AdminUserDeletedEvent implements AdminDeletedUserEvent {\r
+\r
+       /**\r
+        * Serial number\r
+        */\r
+       private static final long serialVersionUID = 14_785_787_174_676_290L;\r
+\r
+       /**\r
+        * Deleted user instance\r
+        */\r
+       private final User deletedUser;\r
+\r
+       /**\r
+        * Delete reason\r
+        */\r
+       private final String userDeleteReason;\r
+\r
+       /**\r
+        * Constructor with deleted user instance\r
+        * <p>\r
+        * @param deletedUser Deleted user instance\r
+        * @param userDeleteReason Delete reason\r
+        */\r
+       public AdminUserDeletedEvent (final User deletedUser, final String userDeleteReason) {\r
+               // Is the user instance valid?\r
+               if (null == deletedUser) {\r
+                       // Throw NPE\r
+                       throw new NullPointerException("deletedUser is null"); //NOI18N\r
+               } else if (deletedUser.getUserId() == null) {\r
+                       // Throw NPE again\r
+                       throw new NullPointerException("deletedUser.userId is null"); //NOI18N\r
+               } else if (deletedUser.getUserId() < 1) {\r
+                       // Invalid id number\r
+                       throw new IllegalArgumentException(MessageFormat.format("deletedUser.userId={0} is invalid.", deletedUser.getUserId())); //NOI18N\r
+               }\r
+\r
+               // Set it here\r
+               this.deletedUser = deletedUser;\r
+               this.userDeleteReason = userDeleteReason;\r
+       }\r
+\r
+       @Override\r
+       public User getDeletedUser () {\r
+               return this.deletedUser;\r
+       }\r
+\r
+       @Override\r
+       public String getUserDeleteReason () {\r
+               return this.userDeleteReason;\r
+       }\r
+\r
+}\r