From 7b5c31ebc14da7e6609c1ec8c18b5efed105e6ea Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Fri, 24 Apr 2020 02:24:25 +0200 Subject: [PATCH] Continued: - added event being fired when an user has updated his contact data MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Roland Häder --- .../update/ObservableUpdatedContactEvent.java | 36 ++++++++++ .../contact/update/UpdatedContactEvent.java | 66 +++++++++++++++++++ 2 files changed, 102 insertions(+) create mode 100644 src/org/mxchange/jcontacts/events/contact/update/ObservableUpdatedContactEvent.java create mode 100644 src/org/mxchange/jcontacts/events/contact/update/UpdatedContactEvent.java diff --git a/src/org/mxchange/jcontacts/events/contact/update/ObservableUpdatedContactEvent.java b/src/org/mxchange/jcontacts/events/contact/update/ObservableUpdatedContactEvent.java new file mode 100644 index 0000000..fcf588a --- /dev/null +++ b/src/org/mxchange/jcontacts/events/contact/update/ObservableUpdatedContactEvent.java @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2016 - 2020 Free Software Foundation + * + * 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.model.contact.Contact; + +/** + * An interface for events being fired when an user updated a new user account. + *

+ * @author Roland Häder + */ +public interface ObservableUpdatedContactEvent extends Serializable { + + /** + * Getter for updated contact instance + *

+ * @return Updated contact instance + */ + Contact getUpdatedContact (); + +} diff --git a/src/org/mxchange/jcontacts/events/contact/update/UpdatedContactEvent.java b/src/org/mxchange/jcontacts/events/contact/update/UpdatedContactEvent.java new file mode 100644 index 0000000..7f94d20 --- /dev/null +++ b/src/org/mxchange/jcontacts/events/contact/update/UpdatedContactEvent.java @@ -0,0 +1,66 @@ +/* + * Copyright (C) 2016 - 2020 Free Software Foundation + * + * 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.model.contact.Contact; + +/** + * An event being fired when an user has updated a new user account + *

+ * @author Roland Häder + */ +public class UpdatedContactEvent implements ObservableUpdatedContactEvent { + + /** + * Serial number + */ + private static final long serialVersionUID = 185_381_945_234_803L; + + /** + * Updated contact instance + */ + private final Contact updatedContact; + + /** + * Constructor with updated contact instance + *

+ * @param updatedContact Updated contact instance + */ + public UpdatedContactEvent (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; + } + +} -- 2.39.5