Skip to content

Commit

Permalink
Minor code enhancements
Browse files Browse the repository at this point in the history
  • Loading branch information
xeraa committed Jul 31, 2011
1 parent d0470e0 commit 8e3f77f
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ public void persistCompanyEntity(){
"[email protected]");
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);
}

Expand Down

0 comments on commit 8e3f77f

Please sign in to comment.