Skip to content
Snippets Groups Projects
Commit 1f200c25 authored by Goik Martin's avatar Goik Martin
Browse files

implement equals() and hashCode()

parent 3a69e3dc
No related branches found
No related tags found
No related merge requests found
......@@ -13,7 +13,25 @@ public class Email {
public Email(final String emailAddress) {
setEmailAddress(emailAddress);
}
void sendEmail(final String subject, final String content) {
//Not yet implemented
@Override
public int hashCode() {
if (null == getEmailAddress()) {
return System.identityHashCode(this);
} else {
return getEmailAddress().hashCode();
}
}
@Override
public boolean equals(Object obj) {
if (null == getEmailAddress()) {
return false;
} else if ( null == obj) {
return false;
} else if (obj instanceof Email) {
Email other = (Email) obj;
return getEmailAddress().equals(other.getEmailAddress());
} else {
return false;
}
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment