From: Roland Häder Date: Thu, 21 Apr 2016 11:27:41 +0000 (+0200) Subject: added event when a user updated personal data X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=20b227c0a6d41829fd6c4f1cf7f092f6249b3af7;p=juser-core.git added event when a user updated personal data --- 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; + } + +}