From: Roland Häder Date: Sun, 19 Nov 2017 00:35:58 +0000 (+0100) Subject: Continued: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=f5cec5d705a79fa421926fcf3795195ed533a2ba;p=juser-core.git Continued: - userMustChangePassword is no longer optional, please do make a choice here - remember that userContact.contactId could be NULL when it has been created while the user's account has been created - added constructor with all required fields and validated them in it Signed-off-by: Roland Häder --- diff --git a/src/org/mxchange/jusercore/model/user/LoginUser.java b/src/org/mxchange/jusercore/model/user/LoginUser.java index 25ba50a..0ba0fa1 100644 --- a/src/org/mxchange/jusercore/model/user/LoginUser.java +++ b/src/org/mxchange/jusercore/model/user/LoginUser.java @@ -140,7 +140,8 @@ public class LoginUser implements User { /** * Whether the user must change password after login */ - @Column (name = "user_must_change_password") + @Basic (optional = false) + @Column (name = "user_must_change_password", nullable = false) private Boolean userMustChangePassword; /** @@ -173,6 +174,56 @@ public class LoginUser implements User { this.userProfileMode = ProfileMode.INVISIBLE; } + /** + * Constructor with all required fields + *

+ * @param userName Username + * @param userProfileMode Profile mode + * @param userMustChangePassword Whether user must change password + * @param userEncryptedPassword Encrypted password + * @param userAccountStatus Account status + * @param userContact User's contact data + */ + public LoginUser (final String userName, final ProfileMode userProfileMode, final Boolean userMustChangePassword, final String userEncryptedPassword, final UserAccountStatus userAccountStatus, final Contact userContact) { + // Call other constructor first + this(); + + // Validate all parameter + if (null == userName) { + // Throw NPE + throw new NullPointerException("userName is null"); //NOI18N + } else if (userName.isEmpty()) { + // Throw IAE + throw new IllegalArgumentException("userName is empty"); //NOI18N + } else if (null == userProfileMode) { + // Throw NPE + throw new NullPointerException("userProfileMode is null"); //NOI18N + } else if (null == userMustChangePassword) { + // Throw it again + throw new NullPointerException("userMustChangePassword is null"); //NOI18N + } else if (null == userEncryptedPassword) { + // Throw it again + throw new NullPointerException("userEncryptedPassword is null"); //NOI18N + } else if (userEncryptedPassword.isEmpty()) { + // Throw IAE + throw new IllegalArgumentException("userEncryptedPassword is empty"); //NOI18N + } else if (null == userAccountStatus) { + // Throw NPE + throw new NullPointerException("userAccountStatus is null"); //NOI18N + } else if (null == userContact) { + // Throw it again + throw new NullPointerException("userContact is null"); //NOI18N + } + + // Set all fields + this.userAccountStatus = userAccountStatus; + this.userEncryptedPassword = userEncryptedPassword; + this.userMustChangePassword = userMustChangePassword; + this.userName = userName; + this.userProfileMode = userProfileMode; + this.userContact = userContact; + } + @Override public boolean equals (final Object object) { if (null == object) {