*/\r
package org.mxchange.jusercore.events.user.update;\r
\r
-import java.io.Serializable;\r
+import java.text.MessageFormat;\r
import org.mxchange.jusercore.model.user.User;\r
\r
/**\r
- * An interface for events being fired when a user updates personal data.\r
+ * An event being fired when the user has updated personal data\r
* <p>\r
* @author Roland Häder<roland@mxchange.org>\r
*/\r
-public interface UpdatedUserPersonalDataEvent extends Serializable {\r
+public class UpdatedUserPersonalDataEvent implements ObservableUpdatedUserPersonalDataEvent {\r
\r
/**\r
- * Getter for updated user instance\r
+ * Serial number\r
+ */\r
+ private static final long serialVersionUID = 14_785_787_174_676_290L;\r
+\r
+ /**\r
+ * Updated user instance\r
+ */\r
+ private final User updatedUser;\r
+\r
+ /**\r
+ * Constructor with updated user instance\r
* <p>\r
- * @return Added user instance\r
+ * @param updatedUser Updated user instance\r
*/\r
- User getUpdatedUser ();\r
+ public UpdatedUserPersonalDataEvent (final User updatedUser) {\r
+ // Is the user instance valid?\r
+ if (null == updatedUser) {\r
+ // Throw NPE\r
+ throw new NullPointerException("updatedUser is null"); //NOI18N\r
+ } else if (updatedUser.getUserId() == null) {\r
+ // Throw NPE again\r
+ throw new NullPointerException("updatedUser.userId is null"); //NOI18N\r
+ } else if (updatedUser.getUserId() < 1) {\r
+ // Invalid id number\r
+ throw new IllegalArgumentException(MessageFormat.format("updatedUser.userId={0} is invalid.", updatedUser.getUserId())); //NOI18N\r
+ }\r
+\r
+ // Set it here\r
+ this.updatedUser = updatedUser;\r
+ }\r
+\r
+ @Override\r
+ public User getUpdatedUser () {\r
+ return this.updatedUser;\r
+ }\r
\r
}\r