Skip to content

Commit

Permalink
Add hashcode and equals methods
Browse files Browse the repository at this point in the history
  • Loading branch information
kunklejr committed Nov 6, 2016
1 parent cd61a7f commit bbe1b59
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,18 @@ public int compareTo(DirectoryEntity o) {
}
return getId().compareTo(o.getId());
}

@Override
public boolean equals(Object o) {
if (!(o instanceof DirectoryEntity)) {
return false;
}
DirectoryEntity other = (DirectoryEntity)o;
return id.equals(other.id) && displayName.equals(other.displayName);
}

@Override
public int hashCode() {
return id.hashCode() + 31 * displayName.hashCode();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,17 @@ public DirectoryGroup(
public String getType() {
return TYPE_GROUP;
}

@Override
public boolean equals(Object o) {
if (o instanceof DirectoryGroup) {
return super.equals(o);
}
return false;
}

@Override
public int hashCode() {
return super.hashCode() + 13;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,18 @@ public String getType() {
public String getEmail() {
return email;
}

@Override
public boolean equals(Object o) {
if (!(o instanceof DirectoryPerson)) {
return false;
}
DirectoryPerson other = (DirectoryPerson)o;
return super.equals(other) && email.equals(other.email);
}

@Override
public int hashCode() {
return super.hashCode() + 31 * email.hashCode();
}
}

0 comments on commit bbe1b59

Please sign in to comment.