]> git.mxchange.org Git - jcontacts-core.git/commitdiff
added event when an administrator has added a new contact
authorRoland Häder <roland@mxchange.org>
Wed, 20 Apr 2016 14:52:13 +0000 (16:52 +0200)
committerRoland Häder <roland@mxchange.org>
Wed, 20 Apr 2016 14:52:13 +0000 (16:52 +0200)
src/org/mxchange/jcontacts/events/contact/AdminAddedContactEvent.java [new file with mode: 0644]
src/org/mxchange/jcontacts/events/contact/AdminContactAddedEvent.java [new file with mode: 0644]

diff --git a/src/org/mxchange/jcontacts/events/contact/AdminAddedContactEvent.java b/src/org/mxchange/jcontacts/events/contact/AdminAddedContactEvent.java
new file mode 100644 (file)
index 0000000..2cbedf0
--- /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.jcontacts.events.contact;\r
+\r
+import java.io.Serializable;\r
+import org.mxchange.jcontacts.contact.Contact;\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 AdminAddedContactEvent extends Serializable {\r
+\r
+       /**\r
+        * Getter for added contact instance\r
+        * <p>\r
+        * @return Added contact instance\r
+        */\r
+       Contact getAddedContact ();\r
+\r
+}\r
diff --git a/src/org/mxchange/jcontacts/events/contact/AdminContactAddedEvent.java b/src/org/mxchange/jcontacts/events/contact/AdminContactAddedEvent.java
new file mode 100644 (file)
index 0000000..c52e8bb
--- /dev/null
@@ -0,0 +1,66 @@
+/*\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.jcontacts.events.contact;\r
+\r
+import java.text.MessageFormat;\r
+import org.mxchange.jcontacts.contact.Contact;\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 AdminContactAddedEvent implements AdminAddedContactEvent {\r
+\r
+       /**\r
+        * Serial number\r
+        */\r
+       private static final long serialVersionUID = 14_785_787_174_676_290L;\r
+\r
+       /**\r
+        * Added contact instance\r
+        */\r
+       private final Contact addedContact;\r
+\r
+       /**\r
+        * Constructor with added contact instance\r
+        * <p>\r
+        * @param addedContact Added contact instance\r
+        */\r
+       public AdminContactAddedEvent (final Contact addedContact) {\r
+               // Is the contact instance valid?\r
+               if (null == addedContact) {\r
+                       // Throw NPE\r
+                       throw new NullPointerException("addedContact is null"); //NOI18N\r
+               } else if (addedContact.getContactId() == null) {\r
+                       // Throw NPE again\r
+                       throw new NullPointerException("addedContact.contactId is null"); //NOI18N\r
+               } else if (addedContact.getContactId() < 1) {\r
+                       // Invalid id number\r
+                       throw new IllegalArgumentException(MessageFormat.format("addedContact.contactId={0} is invalid.", addedContact.getContactId())); //NOI18N\r
+               }\r
+\r
+               // Set it here\r
+               this.addedContact = addedContact;\r
+       }\r
+\r
+       @Override\r
+       public Contact getAddedContact () {\r
+               return this.addedContact;\r
+       }\r
+\r
+}\r