]> git.mxchange.org Git - juser-core.git/commitdiff
added interface/class for events being fired when an administrator has linked a new...
authorRoland Häder <roland@mxchange.org>
Mon, 6 Jun 2016 13:30:26 +0000 (15:30 +0200)
committerRoland Häder <roland@mxchange.org>
Mon, 6 Jun 2016 13:30:26 +0000 (15:30 +0200)
src/org/mxchange/jusercore/events/user/linked/AdminLinkedUserEvent.java [new file with mode: 0644]
src/org/mxchange/jusercore/events/user/linked/AdminUserLinkedEvent.java [new file with mode: 0644]

diff --git a/src/org/mxchange/jusercore/events/user/linked/AdminLinkedUserEvent.java b/src/org/mxchange/jusercore/events/user/linked/AdminLinkedUserEvent.java
new file mode 100644 (file)
index 0000000..c34ce80
--- /dev/null
@@ -0,0 +1,37 @@
+/*
+ * Copyright (C) 2016 Roland Haeder
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.jusercore.events.user.linked;
+
+import java.io.Serializable;
+import org.mxchange.jusercore.model.user.User;
+
+/**
+ * An interface for events being fired when an administrator linked a new user
+ * account with existing contact data.
+ * <p>
+ * @author Roland Haeder<roland@mxchange.org>
+ */
+public interface AdminLinkedUserEvent extends Serializable {
+
+       /**
+        * Getter for linked user instance
+        * <p>
+        * @return linked user instance
+        */
+       User getLinkedUser ();
+
+}
diff --git a/src/org/mxchange/jusercore/events/user/linked/AdminUserLinkedEvent.java b/src/org/mxchange/jusercore/events/user/linked/AdminUserLinkedEvent.java
new file mode 100644 (file)
index 0000000..f35cc70
--- /dev/null
@@ -0,0 +1,67 @@
+/*
+ * Copyright (C) 2016 Roland Haeder
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.jusercore.events.user.linked;
+
+import java.text.MessageFormat;
+import org.mxchange.jusercore.model.user.User;
+
+/**
+ * An event being fired when the administrator has linked a new user account
+ * with existing contact data.
+ * <p>
+ * @author Roland Haeder<roland@mxchange.org>
+ */
+public class AdminUserLinkedEvent implements AdminLinkedUserEvent {
+
+       /**
+        * Serial number
+        */
+       private static final long serialVersionUID = 14_785_787_174_676_290L;
+
+       /**
+        * Linked user instance
+        */
+       private final User linkedUser;
+
+       /**
+        * Constructor with linked user instance
+        * <p>
+        * @param linkedUser Linked user instance
+        */
+       public AdminUserLinkedEvent (final User linkedUser) {
+               // Is the user instance valid?
+               if (null == linkedUser) {
+                       // Throw NPE
+                       throw new NullPointerException("linkedUser is null"); //NOI18N
+               } else if (linkedUser.getUserId() == null) {
+                       // Throw NPE again
+                       throw new NullPointerException("linkedUser.userId is null"); //NOI18N
+               } else if (linkedUser.getUserId() < 1) {
+                       // Invalid id number
+                       throw new IllegalArgumentException(MessageFormat.format("linkedUser.userId={0} is invalid.", linkedUser.getUserId())); //NOI18N
+               }
+
+               // Set it here
+               this.linkedUser = linkedUser;
+       }
+
+       @Override
+       public User getLinkedUser () {
+               return this.linkedUser;
+       }
+
+}