From 5adaba96f0f8fda8a57c0af379617cbbe6c488b7 Mon Sep 17 00:00:00 2001
From: =?utf8?q?Roland=20H=C3=A4der?= <roland@mxchange.org>
Date: Wed, 20 Apr 2016 16:52:13 +0200
Subject: [PATCH] added event when an administrator has added a new contact

---
 .../contact/AdminAddedContactEvent.java       | 37 +++++++++++
 .../contact/AdminContactAddedEvent.java       | 66 +++++++++++++++++++
 2 files changed, 103 insertions(+)
 create mode 100644 src/org/mxchange/jcontacts/events/contact/AdminAddedContactEvent.java
 create mode 100644 src/org/mxchange/jcontacts/events/contact/AdminContactAddedEvent.java

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