]> git.mxchange.org Git - juser-core.git/commitdiff
Continued:
authorRoland Häder <roland@mxchange.org>
Thu, 6 Oct 2022 11:58:45 +0000 (13:58 +0200)
committerRoland Häder <roland@mxchange.org>
Thu, 6 Oct 2022 11:58:45 +0000 (13:58 +0200)
- if you compare class fields in equals() method also add them to hashCode()
- ops, I didn't do that!
- sorted members in hashCode() to fit sorting with if() blocks in equals()
  method
- added some more class fields for object-comparison

src/org/mxchange/jusercore/model/user/LoginUser.java
src/org/mxchange/jusercore/model/user/Users.java

index 581babeac4308acda97c2f3d7f1845b3a69224a3..7c673ac5ef1363de1d77d9aeeeff997cc28893da 100644 (file)
@@ -253,15 +253,19 @@ public class LoginUser implements User {
 
                if (!Objects.equals(this.getUserName(), user.getUserName())) {
                        return false;
+               } else if (!Objects.equals(this.getUserAccountStatus(), user.getUserAccountStatus())) {
+                       return false;
                } else if (!Objects.equals(this.getUserConfirmKey(), user.getUserConfirmKey())) {
                        return false;
-               } else if (!Objects.equals(this.getUserAccountStatus(), user.getUserAccountStatus())) {
+               } else if (!Objects.equals(this.getUserId(), user.getUserId())) {
                        return false;
-               } else if (!Objects.equals(this.getUserContact(), user.getUserContact())) {
+               } else if (!Objects.equals(this.getUserMustChangePassword(), user.getUserMustChangePassword())) {
+                       return false;
+               } else if (!Objects.equals(this.getUserName(), user.getUserName())) {
                        return false;
                } else if (!Objects.equals(this.getUserProfileMode(), user.getUserProfileMode())) {
                        return false;
-               } else if (!Objects.equals(this.getUserId(), user.getUserId())) {
+               } else if (!Objects.equals(this.getUserContact(), user.getUserContact())) {
                        return false;
                }
 
@@ -409,10 +413,12 @@ public class LoginUser implements User {
                int hash = 5;
 
                hash = 83 * hash + Objects.hashCode(this.getUserName());
-               hash = 83 * hash + Objects.hashCode(this.getUserConfirmKey());
                hash = 83 * hash + Objects.hashCode(this.getUserAccountStatus());
-               hash = 83 * hash + Objects.hashCode(this.getUserContact());
+               hash = 83 * hash + Objects.hashCode(this.getUserConfirmKey());
+               hash = 83 * hash + Objects.hashCode(this.getUserId());
+               hash = 83 * hash + Objects.hashCode(this.getUserMustChangePassword());
                hash = 83 * hash + Objects.hashCode(this.getUserProfileMode());
+               hash = 83 * hash + Objects.hashCode(this.getUserContact());
 
                return hash;
        }
index 6fdbc5676bd0433195291bfc9951bfe1346d3d2d..604d5cb3f8e82aec0b337e450274b300f6873784 100644 (file)
@@ -283,6 +283,15 @@ public class Users implements Serializable {
         * @return A formatted string from Date instance
         */
        public static String getFormattedTimestampFromUser (final User user, final Date date) {
+               // Validate parameter
+               if (null == user) {
+                       // Throw NPE
+                       throw new NullPointerException("Parameter 'user' is null"); //NOI18N
+               } else if (null == date) {
+                       // Throw NPE
+                       throw new NullPointerException("Parameter 'date' is null"); //NOI18N
+               }
+
                // Get formatter
                final DateFormat format = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.MEDIUM, user.getUserLocale());