equals och hascode metoder

git-svn-id: svn://svn.dsv.su.se/scipro/scipro/trunk@269 73ecded7-942e-4092-bab0-0e58ef0ee984
This commit is contained in:
joha-asc 2011-03-02 09:58:33 +00:00
parent 3a842be5d1
commit 0d14da9c36
3 changed files with 50 additions and 2 deletions
src/main/java/se/su/dsv/scipro/data/dataobjects

@ -67,6 +67,31 @@ public class CommentThread extends DomainObject{
public void setCommentList(List<Comment> commentList) {
this.commentList = commentList;
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((id == null) ? 0 : id.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
CommentThread other = (CommentThread) obj;
if (id == null) {
if (other.id != null)
return false;
} else if (!id.equals(other.id))
return false;
return true;
}
}

@ -49,7 +49,29 @@ public abstract class Ratable extends DomainObject{
public void setUser(User user) {
this.user = user;
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((id == null) ? 0 : id.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
Ratable other = (Ratable) obj;
if (id == null) {
if (other.id != null)
return false;
} else if (!id.equals(other.id))
return false;
return true;
}
}

@ -31,4 +31,5 @@ public class Tag extends DomainObject {
public Long getId() {
return id;
}
}