From 4644b92a81e4e5ca7ee80e871baa9dbd40d21cba Mon Sep 17 00:00:00 2001 From: Roland Haeder Date: Thu, 21 Apr 2016 22:15:05 +0200 Subject: [PATCH] Continued (similar to juser-core): - moved added-contact event to own package - added updated-contact event --- .../{ => add}/AdminAddedContactEvent.java | 2 +- .../{ => add}/AdminContactAddedEvent.java | 2 +- .../update/AdminContactUpdatedEvent.java | 66 +++++++++++++++++++ .../update/AdminUpdatedContactEvent.java | 37 +++++++++++ 4 files changed, 105 insertions(+), 2 deletions(-) rename src/org/mxchange/jcontacts/events/contact/{ => add}/AdminAddedContactEvent.java (92%) rename src/org/mxchange/jcontacts/events/contact/{ => add}/AdminContactAddedEvent.java (94%) create mode 100644 src/org/mxchange/jcontacts/events/contact/update/AdminContactUpdatedEvent.java create mode 100644 src/org/mxchange/jcontacts/events/contact/update/AdminUpdatedContactEvent.java diff --git a/src/org/mxchange/jcontacts/events/contact/AdminAddedContactEvent.java b/src/org/mxchange/jcontacts/events/contact/add/AdminAddedContactEvent.java similarity index 92% rename from src/org/mxchange/jcontacts/events/contact/AdminAddedContactEvent.java rename to src/org/mxchange/jcontacts/events/contact/add/AdminAddedContactEvent.java index 2cbedf0..b34bafa 100644 --- a/src/org/mxchange/jcontacts/events/contact/AdminAddedContactEvent.java +++ b/src/org/mxchange/jcontacts/events/contact/add/AdminAddedContactEvent.java @@ -14,7 +14,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -package org.mxchange.jcontacts.events.contact; +package org.mxchange.jcontacts.events.contact.add; import java.io.Serializable; import org.mxchange.jcontacts.contact.Contact; diff --git a/src/org/mxchange/jcontacts/events/contact/AdminContactAddedEvent.java b/src/org/mxchange/jcontacts/events/contact/add/AdminContactAddedEvent.java similarity index 94% rename from src/org/mxchange/jcontacts/events/contact/AdminContactAddedEvent.java rename to src/org/mxchange/jcontacts/events/contact/add/AdminContactAddedEvent.java index c52e8bb..bb7d004 100644 --- a/src/org/mxchange/jcontacts/events/contact/AdminContactAddedEvent.java +++ b/src/org/mxchange/jcontacts/events/contact/add/AdminContactAddedEvent.java @@ -14,7 +14,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -package org.mxchange.jcontacts.events.contact; +package org.mxchange.jcontacts.events.contact.add; import java.text.MessageFormat; import org.mxchange.jcontacts.contact.Contact; diff --git a/src/org/mxchange/jcontacts/events/contact/update/AdminContactUpdatedEvent.java b/src/org/mxchange/jcontacts/events/contact/update/AdminContactUpdatedEvent.java new file mode 100644 index 0000000..fcaac04 --- /dev/null +++ b/src/org/mxchange/jcontacts/events/contact/update/AdminContactUpdatedEvent.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 . + */ +package org.mxchange.jcontacts.events.contact.update; + +import java.text.MessageFormat; +import org.mxchange.jcontacts.contact.Contact; + +/** + * An event being fired when the administrator has updated a new user account + *

+ * @author Roland Haeder + */ +public class AdminContactUpdatedEvent implements AdminUpdatedContactEvent { + + /** + * Serial number + */ + private static final long serialVersionUID = 185_381_945_234_802L; + + /** + * Updated contact instance + */ + private final Contact updatedContact; + + /** + * Constructor with updated contact instance + *

+ * @param updatedContact Updated contact instance + */ + public AdminContactUpdatedEvent (final Contact updatedContact) { + // Is the contact instance valid? + if (null == updatedContact) { + // Throw NPE + throw new NullPointerException("updatedContact is null"); //NOI18N + } else if (updatedContact.getContactId() == null) { + // Throw NPE again + throw new NullPointerException("updatedContact.contactId is null"); //NOI18N + } else if (updatedContact.getContactId() < 1) { + // Invalid id number + throw new IllegalArgumentException(MessageFormat.format("updatedContact.contactId={0} is invalid.", updatedContact.getContactId())); //NOI18N + } + + // Set it here + this.updatedContact = updatedContact; + } + + @Override + public Contact getUpdatedContact () { + return this.updatedContact; + } + +} diff --git a/src/org/mxchange/jcontacts/events/contact/update/AdminUpdatedContactEvent.java b/src/org/mxchange/jcontacts/events/contact/update/AdminUpdatedContactEvent.java new file mode 100644 index 0000000..5a0d5a1 --- /dev/null +++ b/src/org/mxchange/jcontacts/events/contact/update/AdminUpdatedContactEvent.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 . + */ +package org.mxchange.jcontacts.events.contact.update; + +import java.io.Serializable; +import org.mxchange.jcontacts.contact.Contact; + +/** + * An interface for events being fired when an administrator updated a new user + * account. + *

+ * @author Roland Haeder + */ +public interface AdminUpdatedContactEvent extends Serializable { + + /** + * Getter for updated contact instance + *

+ * @return Updated contact instance + */ + Contact getUpdatedContact (); + +} -- 2.39.5