From a73db9b83a31daf8dfa3119d353306f9728249d5 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Thu, 21 Apr 2016 11:42:05 +0200 Subject: [PATCH] Continued a bit: - moved "add-user" event to sub-package - added event when an administrator updated user data --- .../user/{ => add}/AdminAddedUserEvent.java | 74 +++++++++---------- .../user/{ => add}/AdminUserAddedEvent.java | 2 +- .../update/AdminUpdatedUserDataEvent.java | 36 +++++++++ .../update/AdminUserDataUpdatedEvent.java | 66 +++++++++++++++++ 4 files changed, 140 insertions(+), 38 deletions(-) rename src/org/mxchange/jusercore/events/user/{ => add}/AdminAddedUserEvent.java (92%) rename src/org/mxchange/jusercore/events/user/{ => add}/AdminUserAddedEvent.java (94%) create mode 100644 src/org/mxchange/jusercore/events/user/update/AdminUpdatedUserDataEvent.java create mode 100644 src/org/mxchange/jusercore/events/user/update/AdminUserDataUpdatedEvent.java diff --git a/src/org/mxchange/jusercore/events/user/AdminAddedUserEvent.java b/src/org/mxchange/jusercore/events/user/add/AdminAddedUserEvent.java similarity index 92% rename from src/org/mxchange/jusercore/events/user/AdminAddedUserEvent.java rename to src/org/mxchange/jusercore/events/user/add/AdminAddedUserEvent.java index 49cc25e..f1b8173 100644 --- a/src/org/mxchange/jusercore/events/user/AdminAddedUserEvent.java +++ b/src/org/mxchange/jusercore/events/user/add/AdminAddedUserEvent.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.jusercore.events.user; - -import java.io.Serializable; -import org.mxchange.jusercore.model.user.User; - -/** - * An interface for events being fired when an administrator added a new user - * account. - *

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

- * @return Added user instance - */ - User getAddedUser (); - -} +/* + * 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.add; + +import java.io.Serializable; +import org.mxchange.jusercore.model.user.User; + +/** + * An interface for events being fired when an administrator added a new user + * account. + *

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

+ * @return Added user instance + */ + User getAddedUser (); + +} diff --git a/src/org/mxchange/jusercore/events/user/AdminUserAddedEvent.java b/src/org/mxchange/jusercore/events/user/add/AdminUserAddedEvent.java similarity index 94% rename from src/org/mxchange/jusercore/events/user/AdminUserAddedEvent.java rename to src/org/mxchange/jusercore/events/user/add/AdminUserAddedEvent.java index a4d1fdd..8889084 100644 --- a/src/org/mxchange/jusercore/events/user/AdminUserAddedEvent.java +++ b/src/org/mxchange/jusercore/events/user/add/AdminUserAddedEvent.java @@ -14,7 +14,7 @@ * 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; +package org.mxchange.jusercore.events.user.add; import java.text.MessageFormat; import org.mxchange.jusercore.model.user.User; diff --git a/src/org/mxchange/jusercore/events/user/update/AdminUpdatedUserDataEvent.java b/src/org/mxchange/jusercore/events/user/update/AdminUpdatedUserDataEvent.java new file mode 100644 index 0000000..b1d675b --- /dev/null +++ b/src/org/mxchange/jusercore/events/user/update/AdminUpdatedUserDataEvent.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.jusercore.events.user.update; + +import java.io.Serializable; +import org.mxchange.jusercore.model.user.User; + +/** + * An interface for events being fired when an administrator updated user data. + *

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

+ * @return Added user instance + */ + User getUpdatedUser (); + +} diff --git a/src/org/mxchange/jusercore/events/user/update/AdminUserDataUpdatedEvent.java b/src/org/mxchange/jusercore/events/user/update/AdminUserDataUpdatedEvent.java new file mode 100644 index 0000000..4a9fda3 --- /dev/null +++ b/src/org/mxchange/jusercore/events/user/update/AdminUserDataUpdatedEvent.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 administrator has updated user data + *

+ * @author Roland Haeder + */ +public class AdminUserDataUpdatedEvent implements AdminUpdatedUserDataEvent { + + /** + * 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 AdminUserDataUpdatedEvent (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