From: Roland Häder Date: Thu, 16 Apr 2020 22:23:15 +0000 (+0200) Subject: Continued: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=a6d6ac431ab5e71976f22df3f07df07417432e3b;p=juser-core.git Continued: - don't use primary key in equals()/hashCode() methods, better try to distinct entities with other properties Signed-off-by: Roland Häder --- 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; }