From: Roland Häder Date: Fri, 24 Apr 2020 00:24:25 +0000 (+0200) Subject: Continued: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=7b5c31ebc14da7e6609c1ec8c18b5efed105e6ea;p=jcontacts-core.git Continued: - added event being fired when an user has updated his contact data Signed-off-by: Roland Häder --- 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; + } + +}