From: Roland Häder Date: Thu, 6 Oct 2022 11:58:45 +0000 (+0200) Subject: Continued: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=b00894a5432e1ff02bc682cc3acb4e712a448b39;p=juser-core.git Continued: - 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 --- diff --git a/src/org/mxchange/jusercore/model/user/LoginUser.java b/src/org/mxchange/jusercore/model/user/LoginUser.java index 581babe..7c673ac 100644 --- a/src/org/mxchange/jusercore/model/user/LoginUser.java +++ b/src/org/mxchange/jusercore/model/user/LoginUser.java @@ -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; } diff --git a/src/org/mxchange/jusercore/model/user/Users.java b/src/org/mxchange/jusercore/model/user/Users.java index 6fdbc56..604d5cb 100644 --- a/src/org/mxchange/jusercore/model/user/Users.java +++ b/src/org/mxchange/jusercore/model/user/Users.java @@ -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());