From: Roland Häder Date: Thu, 9 Jun 2016 15:56:25 +0000 (+0200) Subject: added event for logged-out users X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=ac1f988740484cac5524d520723f6159418a5102;p=juser-login-core.git added event for logged-out users --- diff --git a/src/org/mxchange/jusercore/events/logout/ObserveableUserLogoutEvent.java b/src/org/mxchange/jusercore/events/logout/ObserveableUserLogoutEvent.java new file mode 100644 index 0000000..e9d430b --- /dev/null +++ b/src/org/mxchange/jusercore/events/logout/ObserveableUserLogoutEvent.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.logout; + +import java.io.Serializable; +import org.mxchange.jusercore.model.user.User; + +/** + * An interface for events after the user has logged in + *

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

+ * @return User instance + */ + User getLoggedOutUser (); + +} diff --git a/src/org/mxchange/jusercore/events/logout/UserLogoutEvent.java b/src/org/mxchange/jusercore/events/logout/UserLogoutEvent.java new file mode 100644 index 0000000..3ee0555 --- /dev/null +++ b/src/org/mxchange/jusercore/events/logout/UserLogoutEvent.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.logout; + +import java.text.MessageFormat; +import org.mxchange.jusercore.model.user.User; + +/** + * This event is fired when the loggedOutUser has logged in + *

+ * @author Roland Haeder + */ +public class UserLogoutEvent implements ObserveableUserLogoutEvent { + + /** + * Serial number + */ + private static final long serialVersionUID = 58_617_641_290_620L; + + /** + * User instance + */ + private final User loggedOutUser; + + /** + * Constructor with updated loggedOutUser instance + *

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