From: Roland Häder Date: Mon, 29 Aug 2016 09:20:19 +0000 (+0200) Subject: Added event for user being deleted X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=a131ae97c838aedcd6b8c4ae12c0fb21c5747e59;p=juser-core.git Added event for user being deleted --- diff --git a/src/org/mxchange/jusercore/events/user/delete/AdminDeletedUserEvent.java b/src/org/mxchange/jusercore/events/user/delete/AdminDeletedUserEvent.java new file mode 100644 index 0000000..77b0211 --- /dev/null +++ b/src/org/mxchange/jusercore/events/user/delete/AdminDeletedUserEvent.java @@ -0,0 +1,44 @@ +/* + * 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.delete; + +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 AdminDeletedUserEvent extends Serializable { + + /** + * Getter for deleted user instance + *

+ * @return Deleted user instance + */ + User getDeletedUser (); + + /** + * Getter for user delete reason + *

+ * @return User delete reason + */ + String getUserDeleteReason (); + +} diff --git a/src/org/mxchange/jusercore/events/user/delete/AdminUserDeletedEvent.java b/src/org/mxchange/jusercore/events/user/delete/AdminUserDeletedEvent.java new file mode 100644 index 0000000..c08a2f9 --- /dev/null +++ b/src/org/mxchange/jusercore/events/user/delete/AdminUserDeletedEvent.java @@ -0,0 +1,78 @@ +/* + * 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.delete; + +import java.text.MessageFormat; +import org.mxchange.jusercore.model.user.User; + +/** + * An event being fired when the administrator has deleted a user account + *

+ * @author Roland Haeder + */ +public class AdminUserDeletedEvent implements AdminDeletedUserEvent { + + /** + * Serial number + */ + private static final long serialVersionUID = 14_785_787_174_676_290L; + + /** + * Deleted user instance + */ + private final User deletedUser; + + /** + * Delete reason + */ + private final String userDeleteReason; + + /** + * Constructor with deleted user instance + *

+ * @param deletedUser Deleted user instance + * @param userDeleteReason Delete reason + */ + public AdminUserDeletedEvent (final User deletedUser, final String userDeleteReason) { + // Is the user instance valid? + if (null == deletedUser) { + // Throw NPE + throw new NullPointerException("deletedUser is null"); //NOI18N + } else if (deletedUser.getUserId() == null) { + // Throw NPE again + throw new NullPointerException("deletedUser.userId is null"); //NOI18N + } else if (deletedUser.getUserId() < 1) { + // Invalid id number + throw new IllegalArgumentException(MessageFormat.format("deletedUser.userId={0} is invalid.", deletedUser.getUserId())); //NOI18N + } + + // Set it here + this.deletedUser = deletedUser; + this.userDeleteReason = userDeleteReason; + } + + @Override + public User getDeletedUser () { + return this.deletedUser; + } + + @Override + public String getUserDeleteReason () { + return this.userDeleteReason; + } + +}