]> git.mxchange.org Git - juser-login-core.git/blob - src/org/mxchange/jusercore/events/user/update/AdminUpdatedUserDataEvent.java
db617ad55d90a791505d89588c22a9368737d77c
[juser-login-core.git] / src / org / mxchange / jusercore / events / user / update / AdminUpdatedUserDataEvent.java
1 /*\r
2  * Copyright (C) 2016 Roland Häder\r
3  *\r
4  * This program is free software: you can redistribute it and/or modify\r
5  * it under the terms of the GNU General Public License as published by\r
6  * the Free Software Foundation, either version 3 of the License, or\r
7  * (at your option) any later version.\r
8  *\r
9  * This program is distributed in the hope that it will be useful,\r
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
12  * GNU General Public License for more details.\r
13  *\r
14  * You should have received a copy of the GNU General Public License\r
15  * along with this program.  If not, see <http://www.gnu.org/licenses/>.\r
16  */\r
17 package org.mxchange.jusercore.events.user.update;\r
18 \r
19 import java.text.MessageFormat;\r
20 import org.mxchange.jusercore.model.user.User;\r
21 \r
22 /**\r
23  * An event being fired when the administrator has updated user data\r
24  * <p>\r
25  * @author Roland Häder<roland@mxchange.org>\r
26  */\r
27 public class AdminUpdatedUserDataEvent implements ObservableAdminUpdatedUserDataEvent {\r
28 \r
29         /**\r
30          * Serial number\r
31          */\r
32         private static final long serialVersionUID = 14_785_787_174_676_290L;\r
33 \r
34         /**\r
35          * Updated user instance\r
36          */\r
37         private final User updatedUser;\r
38 \r
39         /**\r
40          * Constructor with updated user instance\r
41          * <p>\r
42          * @param updatedUser Updated user instance\r
43          */\r
44         public AdminUpdatedUserDataEvent (final User updatedUser) {\r
45                 // Is the user instance valid?\r
46                 if (null == updatedUser) {\r
47                         // Throw NPE\r
48                         throw new NullPointerException("updatedUser is null"); //NOI18N\r
49                 } else if (updatedUser.getUserId() == null) {\r
50                         // Throw NPE again\r
51                         throw new NullPointerException("updatedUser.userId is null"); //NOI18N\r
52                 } else if (updatedUser.getUserId() < 1) {\r
53                         // Invalid id number\r
54                         throw new IllegalArgumentException(MessageFormat.format("updatedUser.userId={0} is invalid.", updatedUser.getUserId())); //NOI18N\r
55                 }\r
56 \r
57                 // Set it here\r
58                 this.updatedUser = updatedUser;\r
59         }\r
60 \r
61         @Override\r
62         public User getUpdatedUser () {\r
63                 return this.updatedUser;\r
64         }\r
65 \r
66 }\r