From a6d6ac431ab5e71976f22df3f07df07417432e3b Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Fri, 17 Apr 2020 00:23:15 +0200 Subject: [PATCH] Continued: - don't use primary key in equals()/hashCode() methods, better try to distinct entities with other properties MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Roland Häder --- .../model/email_address/EmailAddressChange.java | 9 ++++++--- .../mxchange/jusercore/model/user/LoginUser.java | 15 +++++++++++++-- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/src/org/mxchange/jusercore/model/email_address/EmailAddressChange.java b/src/org/mxchange/jusercore/model/email_address/EmailAddressChange.java index 58c1cfb..3545486 100644 --- a/src/org/mxchange/jusercore/model/email_address/EmailAddressChange.java +++ b/src/org/mxchange/jusercore/model/email_address/EmailAddressChange.java @@ -167,9 +167,11 @@ public class EmailAddressChange implements ChangeableEmailAddress { final ChangeableEmailAddress otherEmail = (ChangeableEmailAddress) object; - if (!Objects.equals(this.getEmailChangeId(), otherEmail.getEmailChangeId())) { + if (!Objects.equals(this.getEmailAddress(), otherEmail.getEmailAddress())) { return false; - } else if (!Objects.equals(this.getEmailAddress(), otherEmail.getEmailAddress())) { + } else if (!Objects.equals(this.getEmailChangeHash(), otherEmail.getEmailChangeHash())) { + return false; + } else if (!Objects.equals(this.getEmailChangeStatus(), otherEmail.getEmailChangeStatus())) { return false; } else if (!Objects.equals(this.getEmailChangeUser(), otherEmail.getEmailChangeUser())) { return false; @@ -256,8 +258,9 @@ public class EmailAddressChange implements ChangeableEmailAddress { public int hashCode () { int hash = 5; - hash = 71 * hash + Objects.hashCode(this.getEmailChangeId()); hash = 71 * hash + Objects.hashCode(this.getEmailAddress()); + hash = 71 * hash + Objects.hashCode(this.getEmailChangeHash()); + hash = 71 * hash + Objects.hashCode(this.getEmailChangeStatus()); hash = 71 * hash + Objects.hashCode(this.getEmailChangeUser()); return hash; diff --git a/src/org/mxchange/jusercore/model/user/LoginUser.java b/src/org/mxchange/jusercore/model/user/LoginUser.java index 2cfbf4a..436d17c 100644 --- a/src/org/mxchange/jusercore/model/user/LoginUser.java +++ b/src/org/mxchange/jusercore/model/user/LoginUser.java @@ -258,7 +258,13 @@ public class LoginUser implements User { if (!Objects.equals(this.getUserName(), other.getUserName())) { return false; - } else if (!Objects.equals(this.getUserId(), other.getUserId())) { + } else if (!Objects.equals(this.getUserConfirmKey(), other.getUserConfirmKey())) { + return false; + } else if (!Objects.equals(this.getUserAccountStatus(), other.getUserAccountStatus())) { + return false; + } else if (!Objects.equals(this.getUserContact(), other.getUserContact())) { + return false; + } else if (!Objects.equals(this.getUserProfileMode(), other.getUserProfileMode())) { return false; } @@ -404,8 +410,13 @@ public class LoginUser implements User { @Override public int hashCode () { int hash = 5; + hash = 83 * hash + Objects.hashCode(this.getUserName()); - hash = 83 * hash + Objects.hashCode(this.getUserId()); + 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.getUserProfileMode()); + return hash; } -- 2.39.5