From 96596838569930013e99519b23742861a34eea6c Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Mon, 15 Aug 2016 12:24:09 +0200 Subject: [PATCH] Added event for deleting contact data --- .../contact/add/AdminAddedContactEvent.java | 74 +++++++++---------- .../deleted/AdminContactDeletedEvent.java | 66 +++++++++++++++++ .../deleted/AdminDeletedContactEvent.java | 36 +++++++++ 3 files changed, 139 insertions(+), 37 deletions(-) create mode 100644 src/org/mxchange/jcontacts/events/contact/deleted/AdminContactDeletedEvent.java create mode 100644 src/org/mxchange/jcontacts/events/contact/deleted/AdminDeletedContactEvent.java diff --git a/src/org/mxchange/jcontacts/events/contact/add/AdminAddedContactEvent.java b/src/org/mxchange/jcontacts/events/contact/add/AdminAddedContactEvent.java index b34bafa..0e790c8 100644 --- a/src/org/mxchange/jcontacts/events/contact/add/AdminAddedContactEvent.java +++ b/src/org/mxchange/jcontacts/events/contact/add/AdminAddedContactEvent.java @@ -1,37 +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.add; - -import java.io.Serializable; -import org.mxchange.jcontacts.contact.Contact; - -/** - * An interface for events being fired when an administrator added a new user - * account. - *

- * @author Roland Haeder - */ -public interface AdminAddedContactEvent extends Serializable { - - /** - * Getter for added contact instance - *

- * @return Added contact instance - */ - Contact getAddedContact (); - -} +/* + * 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.add; + +import java.io.Serializable; +import org.mxchange.jcontacts.contact.Contact; + +/** + * An interface for events being fired when an administrator added new contact + * data. + *

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

+ * @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 index 0000000..457056e --- /dev/null +++ b/src/org/mxchange/jcontacts/events/contact/deleted/AdminContactDeletedEvent.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.deleted; + +import java.text.MessageFormat; +import org.mxchange.jcontacts.contact.Contact; + +/** + * An event being fired when the administrator has deleted a contact + *

+ * @author Roland Haeder + */ +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 + *

+ * @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 index 0000000..d3a2a8c --- /dev/null +++ b/src/org/mxchange/jcontacts/events/contact/deleted/AdminDeletedContactEvent.java @@ -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 . + */ +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. + *

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

+ * @return Deleted contact instance + */ + Contact getDeletedContact (); + +} -- 2.39.5