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

simplifying equals(...), bug fix hashCode(...) using attribute instead of getter

parent 99dbe443
No related branches found
No related tags found
No related merge requests found
......@@ -73,11 +73,8 @@ public class User {
public boolean equals(Object other) {
if (this == other) {
return true;
} else if (getUid() == null) {
return false;
} else if (other instanceof User) {
final User that = (User) other;
return this.getUid().equals( that.getUid() );
return getUid().equals(((User) other).getUid());
} else {
return false;
}
......
......@@ -68,11 +68,8 @@ public class User {
public boolean equals(Object other) {
if (this == other) {
return true;
} else if (getUid() == null) {
return false;
} else if (other instanceof User) {
final User that = (User) other;
return this.getUid().equals( that.getUid() );
} else if (null != other && other instanceof User) {
return this.getUid().equals(((User) other).getUid() );
} else {
return false;
}
......
......@@ -25,11 +25,8 @@ public class Email {
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 if ( null != obj && obj instanceof Email) {
return getEmailAddress().equals(((Email) obj).getEmailAddress());
} else {
return false;
}
......
......@@ -71,11 +71,8 @@ public class User {
public boolean equals(Object other) {
if (this == other) {
return true;
} else if (getUid() == null) {
return false;
} else if (other instanceof User) {
final User that = (User) other;
return this.getUid().equals( that.getUid() );
} else if (null != other && other instanceof User) {
return this.getUid().equals(((User) other).getUid());
} else {
return false;
}
......
......@@ -25,9 +25,7 @@ public class Email {
public boolean equals(Object obj) {
if (null == getEmailAddress()) {
return false;
} else if ( null == obj) {
return false;
} else if (obj instanceof Email) {
} else if (null != obj && obj instanceof Email) {
Email other = (Email) obj;
return getEmailAddress().equals(other.getEmailAddress());
} else {
......
......@@ -73,11 +73,8 @@ public class User {
public boolean equals(Object other) {
if (this == other) {
return true;
} else if (getUid() == null) {
return false;
} else if (other instanceof User) {
final User that = (User) other;
return this.getUid().equals( that.getUid() );
} else if (null != other && other instanceof User) {
return this.getUid().equals(((User) other).getUid());
} else {
return false;
}
......
......@@ -66,21 +66,18 @@ public class User {
public boolean equals(Object other) {
if (this == other) {
return true;
} else if (id == null) {
return false;
} else if (other instanceof User) {
final User that = (User) other;
return this.id.equals( that.getId() );
} else if (null != other && other instanceof User) {
return getId().equals(((User) other).getId());
} else {
return false;
}
}
@Override
public int hashCode() {
if (null == id) {
if (null == getId()) {
return System.identityHashCode(this);
} else {
return id.hashCode();
return getId().hashCode();
}
}
}
\ No newline at end of file
......@@ -62,11 +62,8 @@ public class User {
public boolean equals(Object other) {
if (this == other) {
return true;
} else if (getUid() == null) {
return false;
} else if (other instanceof User) {
final User that = (User) other;
return this.getUid().equals( that.getUid() );
} else if (null != other && other instanceof User) {
return getUid().equals(((User) other).getUid());
} else {
return false;
}
......
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