From 20b227c0a6d41829fd6c4f1cf7f092f6249b3af7 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Thu, 21 Apr 2016 13:27:41 +0200 Subject: [PATCH] added event when a user updated personal data --- .../update/AdminUpdatedUserDataEvent.java | 2 +- .../update/UpdatedUserPersonalDataEvent.java | 35 ++++++++++ .../update/UserUpdatedPersonalDataEvent.java | 66 +++++++++++++++++++ 3 files changed, 102 insertions(+), 1 deletion(-) create mode 100644 src/org/mxchange/jusercore/events/user/update/UpdatedUserPersonalDataEvent.java create mode 100644 src/org/mxchange/jusercore/events/user/update/UserUpdatedPersonalDataEvent.java diff --git a/src/org/mxchange/jusercore/events/user/update/AdminUpdatedUserDataEvent.java b/src/org/mxchange/jusercore/events/user/update/AdminUpdatedUserDataEvent.java index b1d675b..5b32266 100644 --- a/src/org/mxchange/jusercore/events/user/update/AdminUpdatedUserDataEvent.java +++ b/src/org/mxchange/jusercore/events/user/update/AdminUpdatedUserDataEvent.java @@ -27,7 +27,7 @@ import org.mxchange.jusercore.model.user.User; public interface AdminUpdatedUserDataEvent extends Serializable { /** - * Getter for added user instance + * Getter for updated user instance *

* @return Added user instance */ diff --git a/src/org/mxchange/jusercore/events/user/update/UpdatedUserPersonalDataEvent.java b/src/org/mxchange/jusercore/events/user/update/UpdatedUserPersonalDataEvent.java new file mode 100644 index 0000000..93c849a --- /dev/null +++ b/src/org/mxchange/jusercore/events/user/update/UpdatedUserPersonalDataEvent.java @@ -0,0 +1,35 @@ +/* + * 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.jusercore.events.user.update; + +import org.mxchange.jusercore.model.user.User; + +/** + * An interface for events being fired when a user updates personal data. + *

+ * @author Roland Haeder + */ +public interface UpdatedUserPersonalDataEvent { + + /** + * Getter for updated user instance + *

+ * @return Added user instance + */ + User getUpdatedUser (); + +} diff --git a/src/org/mxchange/jusercore/events/user/update/UserUpdatedPersonalDataEvent.java b/src/org/mxchange/jusercore/events/user/update/UserUpdatedPersonalDataEvent.java new file mode 100644 index 0000000..e78e595 --- /dev/null +++ b/src/org/mxchange/jusercore/events/user/update/UserUpdatedPersonalDataEvent.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.jusercore.events.user.update; + +import java.text.MessageFormat; +import org.mxchange.jusercore.model.user.User; + +/** + * An event being fired when the user has updated personal data + *

+ * @author Roland Haeder + */ +public class UserUpdatedPersonalDataEvent implements UpdatedUserPersonalDataEvent { + + /** + * Serial number + */ + private static final long serialVersionUID = 14_785_787_174_676_290L; + + /** + * Updated user instance + */ + private final User updatedUser; + + /** + * Constructor with updated user instance + *

+ * @param updatedUser Updated user instance + */ + public UserUpdatedPersonalDataEvent (final User updatedUser) { + // Is the user instance valid? + if (null == updatedUser) { + // Throw NPE + throw new NullPointerException("updatedUser is null"); //NOI18N + } else if (updatedUser.getUserId() == null) { + // Throw NPE again + throw new NullPointerException("updatedUser.userId is null"); //NOI18N + } else if (updatedUser.getUserId() < 1) { + // Invalid id number + throw new IllegalArgumentException(MessageFormat.format("updatedUser.userId={0} is invalid.", updatedUser.getUserId())); //NOI18N + } + + // Set it here + this.updatedUser = updatedUser; + } + + @Override + public User getUpdatedUser () { + return this.updatedUser; + } + +} -- 2.39.5