@Test public void testEquals() { PlayerDetails details1 = new PlayerDetails("tom@foo.bar", "11212-123434", "+12323425"); PlayerDetails details2 = new PlayerDetails("tom@foo.bar", "11212-123434", "+12323425"); assertEquals(details1, details2); PlayerDetails details3 = new PlayerDetails("john@foo.bar", "16412-123439", "+34323432"); assertFalse(details1.equals(details3)); }
@Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } PlayerDetails other = (PlayerDetails) obj; if (bankAccountNumber == null) { if (other.bankAccountNumber != null) { return false; } } else if (!bankAccountNumber.equals(other.bankAccountNumber)) { return false; } if (emailAddress == null) { if (other.emailAddress != null) { return false; } } else if (!emailAddress.equals(other.emailAddress)) { return false; } if (phoneNumber == null) { if (other.phoneNumber != null) { return false; } } else if (!phoneNumber.equals(other.phoneNumber)) { return false; } return true; }
PlayerDetails { @Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } PlayerDetails other = (PlayerDetails) obj; if (bankAccountNumber == null) { if (other.bankAccountNumber != null) { return false; } } else if (!bankAccountNumber.equals(other.bankAccountNumber)) { return false; } if (emailAddress == null) { if (other.emailAddress != null) { return false; } } else if (!emailAddress.equals(other.emailAddress)) { return false; } if (phoneNumber == null) { if (other.phoneNumber != null) { return false; } } else if (!phoneNumber.equals(other.phoneNumber)) { return false; } return true; } }
PlayerDetails { @Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } PlayerDetails other = (PlayerDetails) obj; if (bankAccountNumber == null) { if (other.bankAccountNumber != null) { return false; } } else if (!bankAccountNumber.equals(other.bankAccountNumber)) { return false; } if (emailAddress == null) { if (other.emailAddress != null) { return false; } } else if (!emailAddress.equals(other.emailAddress)) { return false; } if (phoneNumber == null) { if (other.phoneNumber != null) { return false; } } else if (!phoneNumber.equals(other.phoneNumber)) { return false; } return true; } PlayerDetails(String email, String bankAccount, String phone); }
PlayerDetails { @Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } PlayerDetails other = (PlayerDetails) obj; if (bankAccountNumber == null) { if (other.bankAccountNumber != null) { return false; } } else if (!bankAccountNumber.equals(other.bankAccountNumber)) { return false; } if (emailAddress == null) { if (other.emailAddress != null) { return false; } } else if (!emailAddress.equals(other.emailAddress)) { return false; } if (phoneNumber == null) { if (other.phoneNumber != null) { return false; } } else if (!phoneNumber.equals(other.phoneNumber)) { return false; } return true; } PlayerDetails(String email, String bankAccount, String phone); String getEmail(); String getBankAccount(); String getPhoneNumber(); @Override String toString(); @Override int hashCode(); @Override boolean equals(Object obj); }
PlayerDetails { @Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } PlayerDetails other = (PlayerDetails) obj; if (bankAccountNumber == null) { if (other.bankAccountNumber != null) { return false; } } else if (!bankAccountNumber.equals(other.bankAccountNumber)) { return false; } if (emailAddress == null) { if (other.emailAddress != null) { return false; } } else if (!emailAddress.equals(other.emailAddress)) { return false; } if (phoneNumber == null) { if (other.phoneNumber != null) { return false; } } else if (!phoneNumber.equals(other.phoneNumber)) { return false; } return true; } PlayerDetails(String email, String bankAccount, String phone); String getEmail(); String getBankAccount(); String getPhoneNumber(); @Override String toString(); @Override int hashCode(); @Override boolean equals(Object obj);  }