From: <ro...@us...> - 2009-05-14 12:38:08
|
Revision: 213 http://cse-ip.svn.sourceforge.net/cse-ip/?rev=213&view=rev Author: roekens Date: 2009-05-14 12:28:00 +0000 (Thu, 14 May 2009) Log Message: ----------- - fixed equals and hashCode methods in domain package Modified Paths: -------------- trunk/cse-ip/sc-cdmm/src/main/java/de/campussource/cse/cdmm/domain/Account.java trunk/cse-ip/sc-cdmm/src/main/java/de/campussource/cse/cdmm/domain/Course.java trunk/cse-ip/sc-cdmm/src/main/java/de/campussource/cse/cdmm/domain/Entity.java trunk/cse-ip/sc-cdmm/src/main/java/de/campussource/cse/cdmm/domain/Group.java trunk/cse-ip/sc-cdmm/src/main/java/de/campussource/cse/cdmm/domain/Role.java Modified: trunk/cse-ip/sc-cdmm/src/main/java/de/campussource/cse/cdmm/domain/Account.java =================================================================== --- trunk/cse-ip/sc-cdmm/src/main/java/de/campussource/cse/cdmm/domain/Account.java 2009-05-14 11:54:08 UTC (rev 212) +++ trunk/cse-ip/sc-cdmm/src/main/java/de/campussource/cse/cdmm/domain/Account.java 2009-05-14 12:28:00 UTC (rev 213) @@ -171,15 +171,6 @@ } } - @Override - public int hashCode() { - if (this.getId() == null) { - return super.hashCode(); - } else { - return this.getId().hashCode(); - } - } - public String toString() { return new ToStringBuilder(this, ToStringStyle.DEFAULT_STYLE).append(this.getId()).toString(); } Modified: trunk/cse-ip/sc-cdmm/src/main/java/de/campussource/cse/cdmm/domain/Course.java =================================================================== --- trunk/cse-ip/sc-cdmm/src/main/java/de/campussource/cse/cdmm/domain/Course.java 2009-05-14 11:54:08 UTC (rev 212) +++ trunk/cse-ip/sc-cdmm/src/main/java/de/campussource/cse/cdmm/domain/Course.java 2009-05-14 12:28:00 UTC (rev 213) @@ -221,5 +221,19 @@ return new ToStringBuilder(this, ToStringStyle.DEFAULT_STYLE).toString(); } - + @Override + public boolean equals(Object other) { + if (this == other) { + return true; + } + if (!(other instanceof Course)) { + return false; + } + if (this.getId() == null) { + return super.equals( other ); + } + else { + return this.getId().equals(((Course)other).getId()); + } + } } Modified: trunk/cse-ip/sc-cdmm/src/main/java/de/campussource/cse/cdmm/domain/Entity.java =================================================================== --- trunk/cse-ip/sc-cdmm/src/main/java/de/campussource/cse/cdmm/domain/Entity.java 2009-05-14 11:54:08 UTC (rev 212) +++ trunk/cse-ip/sc-cdmm/src/main/java/de/campussource/cse/cdmm/domain/Entity.java 2009-05-14 12:28:00 UTC (rev 213) @@ -121,30 +121,31 @@ return new ToStringBuilder(this, ToStringStyle.DEFAULT_STYLE).append(id).toString(); } - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((id == null) ? 0 : id.hashCode()); - return result; - } + @Override + public int hashCode() { + if (this.getId() == null) { + return super.hashCode(); + } + else { + return this.getId().hashCode(); + } + } - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - Entity other = (Entity) obj; - if (id == null) { - if (other.id != null) - return false; - } else if (!id.equals(other.id)) - return false; - return true; - } + @Override + public boolean equals(Object other) { + if (this == other) { + return true; + } + if (!(other instanceof Entity)) { + return false; + } + if (this.getId() == null) { + return super.equals( other ); + } + else { + return this.getId().equals(((Entity)other).getId()); + } + } public boolean isOlder(Date when) { return (date == null) || date.before(when); Modified: trunk/cse-ip/sc-cdmm/src/main/java/de/campussource/cse/cdmm/domain/Group.java =================================================================== --- trunk/cse-ip/sc-cdmm/src/main/java/de/campussource/cse/cdmm/domain/Group.java 2009-05-14 11:54:08 UTC (rev 212) +++ trunk/cse-ip/sc-cdmm/src/main/java/de/campussource/cse/cdmm/domain/Group.java 2009-05-14 12:28:00 UTC (rev 213) @@ -41,31 +41,23 @@ setId(id); } - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (!(obj instanceof Group)) { - return false; - } - if (this.getId() == null) { - return false; - } else { - return this.getId().equals(((Group) obj).getId()); - } - } + @Override + public boolean equals(Object other) { + if (this == other) { + return true; + } + if (!(other instanceof Group)) { + return false; + } + if (this.getId() == null) { + return super.equals( other ); + } + else { + return this.getId().equals(((Group)other).getId()); + } + } @Override - public int hashCode() { - if (this.getId() == null) { - return super.hashCode(); - } else { - return this.getId().hashCode(); - } - } - - @Override public String toString() { return new ToStringBuilder(this, ToStringStyle.DEFAULT_STYLE).append(this.getId()).toString(); } Modified: trunk/cse-ip/sc-cdmm/src/main/java/de/campussource/cse/cdmm/domain/Role.java =================================================================== --- trunk/cse-ip/sc-cdmm/src/main/java/de/campussource/cse/cdmm/domain/Role.java 2009-05-14 11:54:08 UTC (rev 212) +++ trunk/cse-ip/sc-cdmm/src/main/java/de/campussource/cse/cdmm/domain/Role.java 2009-05-14 12:28:00 UTC (rev 213) @@ -136,4 +136,20 @@ visitor.visit(this); } + @Override + public boolean equals(Object other) { + if (this == other) { + return true; + } + if (!(other instanceof Role)) { + return false; + } + if (this.getId() == null) { + return super.equals( other ); + } + else { + return this.getId().equals(((Role)other).getId()); + } + } + } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |