]> git.mxchange.org Git - juser-core.git/commitdiff
Continued:
authorRoland Häder <roland@mxchange.org>
Mon, 18 Apr 2016 16:05:13 +0000 (18:05 +0200)
committerRoland Häder <roland@mxchange.org>
Mon, 18 Apr 2016 16:05:13 +0000 (18:05 +0200)
- added event for administrators adding user accounts
- added detailed checks on given user instances
- Renamed fields for better naming convention

src/org/mxchange/jusercore/events/login/UserLoggedInEvent.java
src/org/mxchange/jusercore/events/login/UserLoginEvent.java
src/org/mxchange/jusercore/events/registration/RegisteredUserEvent.java
src/org/mxchange/jusercore/events/registration/UserRegisteredEvent.java
src/org/mxchange/jusercore/events/user/AdminAddedUserEvent.java [new file with mode: 0644]
src/org/mxchange/jusercore/events/user/AdminUserAddedEvent.java [new file with mode: 0644]

index 960ca57dbb8e003eca76a6eaf4bbbde357a678fe..184649077f03f5489acea941bb0ba8d48121127c 100644 (file)
@@ -31,5 +31,6 @@ public interface UserLoggedInEvent extends Serializable {
         * <p>
         * @return User instance
         */
-       User getUser ();
+       User getLoggedInUser ();
+
 }
index 3973a414ccd4554d2f820ed435bd2b279a7e5e94..2ad452bda8405a67f0c156e799f2739b60f7dc0b 100644 (file)
  */
 package org.mxchange.jusercore.events.login;
 
+import java.text.MessageFormat;
 import org.mxchange.jusercore.model.user.User;
 
 /**
- * This event is fired when the user has logged in
+ * This event is fired when the loggedInUser has logged in
  * <p>
  * @author Roland Haeder<roland@mxchange.org>
  */
@@ -33,20 +34,33 @@ public class UserLoginEvent implements UserLoggedInEvent {
        /**
         * User instance
         */
-       private final User user;
+       private final User loggedInUser;
 
        /**
-        * Constructor with updated user instance
+        * Constructor with updated loggedInUser instance
         * <p>
-        * @param user Updated user instance
+        * @param loggedInUser Updated loggedInUser instance
         */
-       public UserLoginEvent (final User user) {
-               // Set user
-               this.user = user;
+       public UserLoginEvent (final User loggedInUser) {
+               // Is the logged-in user instance valid?
+               if (null == loggedInUser) {
+                       // Throw NPE
+                       throw new NullPointerException("loggedInUser is null"); //NOI18N
+               } else if (loggedInUser.getUserId() == null) {
+                       // Throw NPE again
+                       throw new NullPointerException("loggedInUser.userId is null"); //NOI18N
+               } else if (loggedInUser.getUserId() < 1) {
+                       // Invalid id number
+                       throw new IllegalArgumentException(MessageFormat.format("loggedInUser.userId={0} is invalid.", loggedInUser.getUserId())); //NOI18N
+               }
+
+               // Set loggedInUser
+               this.loggedInUser = loggedInUser;
        }
 
        @Override
-       public User getUser () {
-               return this.user;
+       public User getLoggedInUser () {
+               return this.loggedInUser;
        }
+
 }
index 420c03f640510f9f442e71c27866e7400dc54a80..85ae4739090c602d6e999657659fe2a1b63f32c0 100644 (file)
  */
 package org.mxchange.jusercore.events.registration;
 
+import java.text.MessageFormat;
 import org.mxchange.jusercore.model.user.User;
 
 /**
- * An event, fireed if a new user has registered
+ * An event, fireed if a new registeredUser has registered
  * <p>
  * @author Roland Haeder<roland@mxchange.org>
  */
@@ -31,26 +32,40 @@ public class RegisteredUserEvent implements UserRegisteredEvent {
        private static final long serialVersionUID = 186_956_974_127_691L;
 
        /**
-        * Newly registered user;
+        * Newly registered registeredUser;
         */
-       private final User user;
+       private final User registeredUser;
 
        /**
-        * Constructor with newly registered user
+        * Constructor with newly registered registeredUser
         * <p>
-        * @param user Newly registered user
+        * @param registeredUser Newly registered registeredUser
         */
-       public RegisteredUserEvent (final User user) {
-               this.user = user;
+       public RegisteredUserEvent (final User registeredUser) {
+               // Is the registered user instance valid?
+               if (null == registeredUser) {
+                       // Throw NPE
+                       throw new NullPointerException("registeredUser is null"); //NOI18N
+               } else if (registeredUser.getUserId() == null) {
+                       // Throw NPE again
+                       throw new NullPointerException("registeredUser.userId is null"); //NOI18N
+               } else if (registeredUser.getUserId() < 1) {
+                       // Invalid id number
+                       throw new IllegalArgumentException(MessageFormat.format("registeredUser.userId={0} is invalid.", registeredUser.getUserId())); //NOI18N
+               }
+
+               // Set it here
+               this.registeredUser = registeredUser;
        }
 
        /**
-        * Getter for user instance
+        * Getter for registeredUser instance
         * <p>
         * @return User instance
         */
        @Override
-       public User getUser () {
-               return this.user;
+       public User getRegisteredUser () {
+               return this.registeredUser;
        }
+
 }
index 7755f6465ce7dea85cec9cc0d734d5616d9bc8d2..ee1ecbed9b082e35d64f758637e295f198a3f0c1 100644 (file)
@@ -31,5 +31,6 @@ public interface UserRegisteredEvent extends Serializable {
         * <p>
         * @return User instance
         */
-       User getUser ();
+       User getRegisteredUser ();
+
 }
diff --git a/src/org/mxchange/jusercore/events/user/AdminAddedUserEvent.java b/src/org/mxchange/jusercore/events/user/AdminAddedUserEvent.java
new file mode 100644 (file)
index 0000000..0238103
--- /dev/null
@@ -0,0 +1,37 @@
+/*\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;\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 AdminAddedUserEvent extends Serializable {\r
+\r
+       /**\r
+        * Getter for added user instance\r
+        * <p>\r
+        * @return Added user instance\r
+        */\r
+       User getAddedUser ();\r
+\r
+}\r
diff --git a/src/org/mxchange/jusercore/events/user/AdminUserAddedEvent.java b/src/org/mxchange/jusercore/events/user/AdminUserAddedEvent.java
new file mode 100644 (file)
index 0000000..e6b035b
--- /dev/null
@@ -0,0 +1,65 @@
+/*\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;\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 added a new user account\r
+ * <p>\r
+ * @author Roland Haeder<roland@mxchange.org>\r
+ */\r
+public class AdminUserAddedEvent implements AdminAddedUserEvent {\r
+\r
+       /**\r
+        * Serial number\r
+        */\r
+       private static final long serialVersionUID = 14_785_787_174_676_290L;\r
+\r
+       /**\r
+        * Added user instance\r
+        */\r
+       private final User addedUser;\r
+\r
+       /**\r
+        * Constructor with added user instance\r
+        * @param addedUser Added user instance\r
+        */\r
+       public AdminUserAddedEvent (final User addedUser) {\r
+               // Is the user instance valid?\r
+               if (null == addedUser) {\r
+                       // Throw NPE\r
+                       throw new NullPointerException("addedUser is null"); //NOI18N\r
+               } else if (addedUser.getUserId() == null) {\r
+                       // Throw NPE again\r
+                       throw new NullPointerException("addedUser.userId is null"); //NOI18N\r
+               } else if (addedUser.getUserId() < 1) {\r
+                       // Invalid id number\r
+                       throw new IllegalArgumentException(MessageFormat.format("addedUser.userId={0} is invalid.", addedUser.getUserId())); //NOI18N\r
+               }\r
+\r
+               // Set it here\r
+               this.addedUser = addedUser;\r
+       }\r
+\r
+       @Override\r
+       public User getAddedUser () {\r
+               return this.addedUser;\r
+       }\r
+\r
+}\r