From 7bd18b3e18d933b5a0a0cb61d8cddd24c147266c Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Tue, 23 Aug 2016 16:47:03 +0200 Subject: [PATCH] Always include primary key (id number) in equal() method --- .../model/email_address/EmailAddressChange.java | 11 +++++++++-- .../user/password_history/UserPasswordHistory.java | 4 ++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/org/mxchange/jusercore/model/email_address/EmailAddressChange.java b/src/org/mxchange/jusercore/model/email_address/EmailAddressChange.java index 2d8d738..718c4c5 100644 --- a/src/org/mxchange/jusercore/model/email_address/EmailAddressChange.java +++ b/src/org/mxchange/jusercore/model/email_address/EmailAddressChange.java @@ -173,11 +173,15 @@ public class EmailAddressChange implements ChangeableEmailAddress { final ChangeableEmailAddress otherEmail = (ChangeableEmailAddress) object; - if (!Objects.equals(this.getEmailAddress(), otherEmail.getEmailAddress())) { + if (!Objects.equals(this.getEmailChangeId(), otherEmail.getEmailChangeId())) { + return false; + } else if (!Objects.equals(this.getEmailAddress(), otherEmail.getEmailAddress())) { + return false; + } else if (!Objects.equals(this.getEmailChangeUser(), otherEmail.getEmailChangeUser())) { return false; } - return Objects.equals(this.getEmailChangeUser(), otherEmail.getEmailChangeUser()); + return true; } @Override @@ -257,8 +261,11 @@ public class EmailAddressChange implements ChangeableEmailAddress { @Override 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.getEmailChangeUser()); + return hash; } diff --git a/src/org/mxchange/jusercore/model/user/password_history/UserPasswordHistory.java b/src/org/mxchange/jusercore/model/user/password_history/UserPasswordHistory.java index 270ac6d..1cbdef1 100644 --- a/src/org/mxchange/jusercore/model/user/password_history/UserPasswordHistory.java +++ b/src/org/mxchange/jusercore/model/user/password_history/UserPasswordHistory.java @@ -119,9 +119,9 @@ public class UserPasswordHistory implements PasswordHistory { final PasswordHistory other = (PasswordHistory) object; - if (!Objects.equals(this.getUserPasswordHistoryPasswordHash(), other.getUserPasswordHistoryPasswordHash())) { + if (!Objects.equals(this.getUserPasswordHistoryId(), other.getUserPasswordHistoryId())) { return false; - } else if (!Objects.equals(this.getUserPasswordHistoryId(), other.getUserPasswordHistoryId())) { + } else if (!Objects.equals(this.getUserPasswordHistoryPasswordHash(), other.getUserPasswordHistoryPasswordHash())) { return false; } else if (!Objects.equals(this.getUserPasswordHistoryUser(), other.getUserPasswordHistoryUser())) { return false; -- 2.39.5