Permalink
Browse files

Minor code enhancements

  • Loading branch information...
1 parent d0470e0 commit 8e3f77f7dcc183d15e8ef7ba3b5ae8e4c01451c0 @xeraa committed Jul 31, 2011
View
39 src/main/java/at/ac/tuwien/ec/mongouk2011/entities/ManagerEntity.java
@@ -69,5 +69,44 @@ public void postLoad(){
this.bonus = new BigDecimal(bonusString);
}
}
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = super.hashCode();
+ result = prime * result + ((approveFunds == null) ? 0 : approveFunds.hashCode());
+ result = prime * result + (approveHires ? 1231 : 1237);
+ result = prime * result + ((bonus == null) ? 0 : bonus.hashCode());
+ result = prime * result + ((bonusString == null) ? 0 : bonusString.hashCode());
+ return result;
+ }
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (!super.equals(obj))
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ ManagerEntity other = (ManagerEntity) obj;
+ if (approveFunds == null) {
+ if (other.approveFunds != null)
+ return false;
+ } else if (!approveFunds.equals(other.approveFunds))
+ return false;
+ if (approveHires != other.approveHires)
+ return false;
+ if (bonus == null) {
+ if (other.bonus != null)
+ return false;
+ } else if (!bonus.equals(other.bonus))
+ return false;
+ if (bonusString == null) {
+ if (other.bonusString != null)
+ return false;
+ } else if (!bonusString.equals(other.bonusString))
+ return false;
+ return true;
+ }
}
View
25 src/main/java/at/ac/tuwien/ec/mongouk2011/entities/WorkerEntity.java
@@ -26,5 +26,30 @@ public void setYearsExperience(Integer yearsExperience) {
public Integer getYearsExperience() {
return yearsExperience;
}
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = super.hashCode();
+ result = prime * result + ((yearsExperience == null) ? 0 : yearsExperience.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (!super.equals(obj))
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ WorkerEntity other = (WorkerEntity) obj;
+ if (yearsExperience == null) {
+ if (other.yearsExperience != null)
+ return false;
+ } else if (!yearsExperience.equals(other.yearsExperience))
+ return false;
+ return true;
+ }
}
View
1 src/test/java/at/ac/tuwien/ec/mongouk2011/test/PersistenceTest.java
@@ -57,7 +57,6 @@ public void persistCompanyEntity(){
"foobar@test.com");
ObjectId id = persistence.persistCompanyEntity(company);
assertNotNull("An ObjectId should have been generated when saving the entity", id);
- assertTrue("The id must be a valid ObjectId", id instanceof ObjectId);
assertEquals("The return value and actual value of the ObjectId should match", company.getId(), id);
}

0 comments on commit 8e3f77f

Please sign in to comment.