From fb565a9a8e56de80a70ca829ee622effae930964 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Mon, 6 Jun 2016 15:30:26 +0200 Subject: [PATCH] added interface/class for events being fired when an administrator has linked a new user account with existing contact data --- .../user/linked/AdminLinkedUserEvent.java | 37 ++++++++++ .../user/linked/AdminUserLinkedEvent.java | 67 +++++++++++++++++++ 2 files changed, 104 insertions(+) create mode 100644 src/org/mxchange/jusercore/events/user/linked/AdminLinkedUserEvent.java create mode 100644 src/org/mxchange/jusercore/events/user/linked/AdminUserLinkedEvent.java diff --git a/src/org/mxchange/jusercore/events/user/linked/AdminLinkedUserEvent.java b/src/org/mxchange/jusercore/events/user/linked/AdminLinkedUserEvent.java new file mode 100644 index 0000000..c34ce80 --- /dev/null +++ b/src/org/mxchange/jusercore/events/user/linked/AdminLinkedUserEvent.java @@ -0,0 +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.linked; + +import java.io.Serializable; +import org.mxchange.jusercore.model.user.User; + +/** + * An interface for events being fired when an administrator linked a new user + * account with existing contact data. + *

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

+ * @return linked user instance + */ + User getLinkedUser (); + +} diff --git a/src/org/mxchange/jusercore/events/user/linked/AdminUserLinkedEvent.java b/src/org/mxchange/jusercore/events/user/linked/AdminUserLinkedEvent.java new file mode 100644 index 0000000..f35cc70 --- /dev/null +++ b/src/org/mxchange/jusercore/events/user/linked/AdminUserLinkedEvent.java @@ -0,0 +1,67 @@ +/* + * 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.linked; + +import java.text.MessageFormat; +import org.mxchange.jusercore.model.user.User; + +/** + * An event being fired when the administrator has linked a new user account + * with existing contact data. + *

+ * @author Roland Haeder + */ +public class AdminUserLinkedEvent implements AdminLinkedUserEvent { + + /** + * Serial number + */ + private static final long serialVersionUID = 14_785_787_174_676_290L; + + /** + * Linked user instance + */ + private final User linkedUser; + + /** + * Constructor with linked user instance + *

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