]> git.mxchange.org Git - jcontacts-core.git/commitdiff
Added event for deleting contact data
authorRoland Häder <roland@mxchange.org>
Mon, 15 Aug 2016 10:24:09 +0000 (12:24 +0200)
committerRoland Häder <roland@mxchange.org>
Mon, 15 Aug 2016 10:24:09 +0000 (12:24 +0200)
src/org/mxchange/jcontacts/events/contact/add/AdminAddedContactEvent.java
src/org/mxchange/jcontacts/events/contact/deleted/AdminContactDeletedEvent.java [new file with mode: 0644]
src/org/mxchange/jcontacts/events/contact/deleted/AdminDeletedContactEvent.java [new file with mode: 0644]

index b34bafa00158780a947ce48e95a18b31481e0f94..0e790c858c71b36a2952a93ba62a1f4ab43a6111 100644 (file)
@@ -1,37 +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.add;\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
+/*
+ * 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.jcontacts.events.contact.add;
+
+import java.io.Serializable;
+import org.mxchange.jcontacts.contact.Contact;
+
+/**
+ * An interface for events being fired when an administrator added new contact
+ * data.
+ * <p>
+ * @author Roland Haeder<roland@mxchange.org>
+ */
+public interface AdminAddedContactEvent extends Serializable {
+
+       /**
+        * Getter for added contact instance
+        * <p>
+        * @return Added contact instance
+        */
+       Contact getAddedContact ();
+
+}
diff --git a/src/org/mxchange/jcontacts/events/contact/deleted/AdminContactDeletedEvent.java b/src/org/mxchange/jcontacts/events/contact/deleted/AdminContactDeletedEvent.java
new file mode 100644 (file)
index 0000000..457056e
--- /dev/null
@@ -0,0 +1,66 @@
+/*
+ * 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.jcontacts.events.contact.deleted;
+
+import java.text.MessageFormat;
+import org.mxchange.jcontacts.contact.Contact;
+
+/**
+ * An event being fired when the administrator has deleted a contact
+ * <p>
+ * @author Roland Haeder<roland@mxchange.org>
+ */
+public class AdminContactDeletedEvent implements AdminDeletedContactEvent {
+
+       /**
+        * Serial number
+        */
+       private static final long serialVersionUID = 14_785_787_174_676_290L;
+
+       /**
+        * Deleted contact instance
+        */
+       private final Contact deletedContact;
+
+       /**
+        * Constructor with deleted contact instance
+        * <p>
+        * @param deletedContact Deleted contact instance
+        */
+       public AdminContactDeletedEvent (final Contact deletedContact) {
+               // Is the contact instance valid?
+               if (null == deletedContact) {
+                       // Throw NPE
+                       throw new NullPointerException("deletedContact is null"); //NOI18N
+               } else if (deletedContact.getContactId() == null) {
+                       // Throw NPE again
+                       throw new NullPointerException("deletedContact.contactId is null"); //NOI18N
+               } else if (deletedContact.getContactId() < 1) {
+                       // Invalid id number
+                       throw new IllegalArgumentException(MessageFormat.format("deletedContact.contactId={0} is invalid.", deletedContact.getContactId())); //NOI18N
+               }
+
+               // Set it here
+               this.deletedContact = deletedContact;
+       }
+
+       @Override
+       public Contact getDeletedContact () {
+               return this.deletedContact;
+       }
+
+}
diff --git a/src/org/mxchange/jcontacts/events/contact/deleted/AdminDeletedContactEvent.java b/src/org/mxchange/jcontacts/events/contact/deleted/AdminDeletedContactEvent.java
new file mode 100644 (file)
index 0000000..d3a2a8c
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+ * 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.jcontacts.events.contact.deleted;
+
+import java.io.Serializable;
+import org.mxchange.jcontacts.contact.Contact;
+
+/**
+ * An interface for events being fired when an administrator deleted a contact.
+ * <p>
+ * @author Roland Haeder<roland@mxchange.org>
+ */
+public interface AdminDeletedContactEvent extends Serializable {
+
+       /**
+        * Getter for deleted contact instance
+        * <p>
+        * @return Deleted contact instance
+        */
+       Contact getDeletedContact ();
+
+}