From: <gca...@us...> - 2011-12-01 08:34:55
|
Revision: 3715 http://openutils.svn.sourceforge.net/openutils/?rev=3715&view=rev Author: gcatania Date: 2011-12-01 08:34:48 +0000 (Thu, 01 Dec 2011) Log Message: ----------- BSHD-2 hashcode, equals on test model objects Modified Paths: -------------- trunk/openutils-bshd5/src/test/java/it/openutils/hibernate/test/model/Address.java trunk/openutils-bshd5/src/test/java/it/openutils/hibernate/test/model/Car.java trunk/openutils-bshd5/src/test/java/it/openutils/hibernate/test/model/CarMaker.java trunk/openutils-bshd5/src/test/java/it/openutils/hibernate/test/model/CarModel.java trunk/openutils-bshd5/src/test/java/it/openutils/hibernate/test/model/CurrencyAmount.java trunk/openutils-bshd5/src/test/java/it/openutils/hibernate/test/model/Designer.java trunk/openutils-bshd5/src/test/java/it/openutils/hibernate/test/model/Employee.java trunk/openutils-bshd5/src/test/java/it/openutils/hibernate/test/model/FullName.java trunk/openutils-bshd5/src/test/java/it/openutils/hibernate/test/model/Owner.java trunk/openutils-bshd5/src/test/java/it/openutils/hibernate/test/model/Person.java Modified: trunk/openutils-bshd5/src/test/java/it/openutils/hibernate/test/model/Address.java =================================================================== --- trunk/openutils-bshd5/src/test/java/it/openutils/hibernate/test/model/Address.java 2011-12-01 08:26:28 UTC (rev 3714) +++ trunk/openutils-bshd5/src/test/java/it/openutils/hibernate/test/model/Address.java 2011-12-01 08:34:48 UTC (rev 3715) @@ -198,7 +198,7 @@ { return false; } - if (getClass() != obj.getClass()) + if (!(obj instanceof Address)) { return false; } Modified: trunk/openutils-bshd5/src/test/java/it/openutils/hibernate/test/model/Car.java =================================================================== --- trunk/openutils-bshd5/src/test/java/it/openutils/hibernate/test/model/Car.java 2011-12-01 08:26:28 UTC (rev 3714) +++ trunk/openutils-bshd5/src/test/java/it/openutils/hibernate/test/model/Car.java 2011-12-01 08:34:48 UTC (rev 3715) @@ -147,4 +147,109 @@ return maker; } + /** + * {@inheritDoc} + */ + @Override + public int hashCode() + { + final int prime = 31; + int result = 1; + result = prime * result + ((id == null) ? 0 : id.hashCode()); + result = prime * result + ((maker == null) ? 0 : maker.hashCode()); + result = prime * result + ((marketValue == null) ? 0 : marketValue.hashCode()); + result = prime * result + ((model == null) ? 0 : model.hashCode()); + result = prime * result + ((owner == null) ? 0 : owner.hashCode()); + result = prime * result + ((registrationDate == null) ? 0 : registrationDate.hashCode()); + return result; + } + + /** + * {@inheritDoc} + */ + @Override + public boolean equals(Object obj) + { + if (this == obj) + { + return true; + } + if (obj == null) + { + return false; + } + if (!(obj instanceof Car)) + { + return false; + } + Car other = (Car) obj; + if (id == null) + { + if (other.id != null) + { + return false; + } + } + else if (!id.equals(other.id)) + { + return false; + } + if (maker == null) + { + if (other.maker != null) + { + return false; + } + } + else if (!maker.equals(other.maker)) + { + return false; + } + if (marketValue == null) + { + if (other.marketValue != null) + { + return false; + } + } + else if (!marketValue.equals(other.marketValue)) + { + return false; + } + if (model == null) + { + if (other.model != null) + { + return false; + } + } + else if (!model.equals(other.model)) + { + return false; + } + if (owner == null) + { + if (other.owner != null) + { + return false; + } + } + else if (!owner.equals(other.owner)) + { + return false; + } + if (registrationDate == null) + { + if (other.registrationDate != null) + { + return false; + } + } + else if (!registrationDate.equals(other.registrationDate)) + { + return false; + } + return true; + } + } Modified: trunk/openutils-bshd5/src/test/java/it/openutils/hibernate/test/model/CarMaker.java =================================================================== --- trunk/openutils-bshd5/src/test/java/it/openutils/hibernate/test/model/CarMaker.java 2011-12-01 08:26:28 UTC (rev 3714) +++ trunk/openutils-bshd5/src/test/java/it/openutils/hibernate/test/model/CarMaker.java 2011-12-01 08:34:48 UTC (rev 3715) @@ -116,4 +116,85 @@ this.models = models; } + /** + * {@inheritDoc} + */ + @Override + public int hashCode() + { + final int prime = 31; + int result = 1; + result = prime * result + ((capitalization == null) ? 0 : capitalization.hashCode()); + result = prime * result + ((id == null) ? 0 : id.hashCode()); + result = prime * result + ((models == null) ? 0 : models.hashCode()); + result = prime * result + ((name == null) ? 0 : name.hashCode()); + return result; + } + + /** + * {@inheritDoc} + */ + @Override + public boolean equals(Object obj) + { + if (this == obj) + { + return true; + } + if (obj == null) + { + return false; + } + if (!(obj instanceof CarMaker)) + { + return false; + } + CarMaker other = (CarMaker) obj; + if (capitalization == null) + { + if (other.capitalization != null) + { + return false; + } + } + else if (!capitalization.equals(other.capitalization)) + { + return false; + } + if (id == null) + { + if (other.id != null) + { + return false; + } + } + else if (!id.equals(other.id)) + { + return false; + } + if (models == null) + { + if (other.models != null) + { + return false; + } + } + else if (!models.equals(other.models)) + { + return false; + } + if (name == null) + { + if (other.name != null) + { + return false; + } + } + else if (!name.equals(other.name)) + { + return false; + } + return true; + } + } Modified: trunk/openutils-bshd5/src/test/java/it/openutils/hibernate/test/model/CarModel.java =================================================================== --- trunk/openutils-bshd5/src/test/java/it/openutils/hibernate/test/model/CarModel.java 2011-12-01 08:26:28 UTC (rev 3714) +++ trunk/openutils-bshd5/src/test/java/it/openutils/hibernate/test/model/CarModel.java 2011-12-01 08:34:48 UTC (rev 3715) @@ -94,4 +94,73 @@ this.year = year; } + /** + * {@inheritDoc} + */ + @Override + public int hashCode() + { + final int prime = 31; + int result = 1; + result = prime * result + ((id == null) ? 0 : id.hashCode()); + result = prime * result + ((name == null) ? 0 : name.hashCode()); + result = prime * result + ((year == null) ? 0 : year.hashCode()); + return result; + } + + /** + * {@inheritDoc} + */ + @Override + public boolean equals(Object obj) + { + if (this == obj) + { + return true; + } + if (obj == null) + { + return false; + } + if (!(obj instanceof CarModel)) + { + return false; + } + CarModel other = (CarModel) obj; + if (id == null) + { + if (other.id != null) + { + return false; + } + } + else if (!id.equals(other.id)) + { + return false; + } + if (name == null) + { + if (other.name != null) + { + return false; + } + } + else if (!name.equals(other.name)) + { + return false; + } + if (year == null) + { + if (other.year != null) + { + return false; + } + } + else if (!year.equals(other.year)) + { + return false; + } + return true; + } + } Modified: trunk/openutils-bshd5/src/test/java/it/openutils/hibernate/test/model/CurrencyAmount.java =================================================================== --- trunk/openutils-bshd5/src/test/java/it/openutils/hibernate/test/model/CurrencyAmount.java 2011-12-01 08:26:28 UTC (rev 3714) +++ trunk/openutils-bshd5/src/test/java/it/openutils/hibernate/test/model/CurrencyAmount.java 2011-12-01 08:34:48 UTC (rev 3715) @@ -62,4 +62,56 @@ return currency; } + /** + * {@inheritDoc} + */ + @Override + public int hashCode() + { + final int prime = 31; + int result = 1; + long temp; + temp = Double.doubleToLongBits(amount); + result = prime * result + (int) (temp ^ (temp >>> 32)); + result = prime * result + ((currency == null) ? 0 : currency.hashCode()); + return result; + } + + /** + * {@inheritDoc} + */ + @Override + public boolean equals(Object obj) + { + if (this == obj) + { + return true; + } + if (obj == null) + { + return false; + } + if (!(obj instanceof CurrencyAmount)) + { + return false; + } + CurrencyAmount other = (CurrencyAmount) obj; + if (Double.doubleToLongBits(amount) != Double.doubleToLongBits(other.amount)) + { + return false; + } + if (currency == null) + { + if (other.currency != null) + { + return false; + } + } + else if (!currency.equals(other.currency)) + { + return false; + } + return true; + } + } Modified: trunk/openutils-bshd5/src/test/java/it/openutils/hibernate/test/model/Designer.java =================================================================== --- trunk/openutils-bshd5/src/test/java/it/openutils/hibernate/test/model/Designer.java 2011-12-01 08:26:28 UTC (rev 3714) +++ trunk/openutils-bshd5/src/test/java/it/openutils/hibernate/test/model/Designer.java 2011-12-01 08:34:48 UTC (rev 3715) @@ -79,4 +79,54 @@ this.designedModels = designedModels; } + /** + * {@inheritDoc} + */ + @Override + public int hashCode() + { + final int prime = 31; + int result = super.hashCode(); + result = prime * result + ((designedModels == null) ? 0 : designedModels.hashCode()); + result = prime * result + hipsterFactor; + return result; + } + + /** + * {@inheritDoc} + */ + @Override + public boolean equals(Object obj) + { + if (this == obj) + { + return true; + } + if (!super.equals(obj)) + { + return false; + } + if (!(obj instanceof Designer)) + { + return false; + } + Designer other = (Designer) obj; + if (designedModels == null) + { + if (other.designedModels != null) + { + return false; + } + } + else if (!designedModels.equals(other.designedModels)) + { + return false; + } + if (hipsterFactor != other.hipsterFactor) + { + return false; + } + return true; + } + } Modified: trunk/openutils-bshd5/src/test/java/it/openutils/hibernate/test/model/Employee.java =================================================================== --- trunk/openutils-bshd5/src/test/java/it/openutils/hibernate/test/model/Employee.java 2011-12-01 08:26:28 UTC (rev 3714) +++ trunk/openutils-bshd5/src/test/java/it/openutils/hibernate/test/model/Employee.java 2011-12-01 08:34:48 UTC (rev 3715) @@ -136,4 +136,97 @@ this.employedSince = employedSince; } + /** + * {@inheritDoc} + */ + @Override + public int hashCode() + { + final int prime = 31; + int result = super.hashCode(); + result = prime * result + ((department == null) ? 0 : department.hashCode()); + result = prime * result + ((employedSince == null) ? 0 : employedSince.hashCode()); + result = prime * result + ((employer == null) ? 0 : employer.hashCode()); + result = prime * result + ((grossAnnualSalary == null) ? 0 : grossAnnualSalary.hashCode()); + result = prime * result + ((qualification == null) ? 0 : qualification.hashCode()); + return result; + } + + /** + * {@inheritDoc} + */ + @Override + public boolean equals(Object obj) + { + if (this == obj) + { + return true; + } + if (!super.equals(obj)) + { + return false; + } + if (!(obj instanceof Employee)) + { + return false; + } + Employee other = (Employee) obj; + if (department == null) + { + if (other.department != null) + { + return false; + } + } + else if (!department.equals(other.department)) + { + return false; + } + if (employedSince == null) + { + if (other.employedSince != null) + { + return false; + } + } + else if (!employedSince.equals(other.employedSince)) + { + return false; + } + if (employer == null) + { + if (other.employer != null) + { + return false; + } + } + else if (!employer.equals(other.employer)) + { + return false; + } + if (grossAnnualSalary == null) + { + if (other.grossAnnualSalary != null) + { + return false; + } + } + else if (!grossAnnualSalary.equals(other.grossAnnualSalary)) + { + return false; + } + if (qualification == null) + { + if (other.qualification != null) + { + return false; + } + } + else if (!qualification.equals(other.qualification)) + { + return false; + } + return true; + } + } Modified: trunk/openutils-bshd5/src/test/java/it/openutils/hibernate/test/model/FullName.java =================================================================== --- trunk/openutils-bshd5/src/test/java/it/openutils/hibernate/test/model/FullName.java 2011-12-01 08:26:28 UTC (rev 3714) +++ trunk/openutils-bshd5/src/test/java/it/openutils/hibernate/test/model/FullName.java 2011-12-01 08:34:48 UTC (rev 3715) @@ -130,7 +130,7 @@ { return false; } - if (getClass() != obj.getClass()) + if (!(obj instanceof FullName)) { return false; } @@ -157,15 +157,8 @@ { return false; } - if (title == null) + if (title != other.title) { - if (other.title != null) - { - return false; - } - } - else if (!title.equals(other.title)) - { return false; } return true; Modified: trunk/openutils-bshd5/src/test/java/it/openutils/hibernate/test/model/Owner.java =================================================================== --- trunk/openutils-bshd5/src/test/java/it/openutils/hibernate/test/model/Owner.java 2011-12-01 08:26:28 UTC (rev 3714) +++ trunk/openutils-bshd5/src/test/java/it/openutils/hibernate/test/model/Owner.java 2011-12-01 08:34:48 UTC (rev 3715) @@ -79,4 +79,61 @@ return totalValueOfCars; } + /** + * {@inheritDoc} + */ + @Override + public int hashCode() + { + final int prime = 31; + int result = super.hashCode(); + result = prime * result + ((cars == null) ? 0 : cars.hashCode()); + result = prime * result + ((totalValueOfCars == null) ? 0 : totalValueOfCars.hashCode()); + return result; + } + + /** + * {@inheritDoc} + */ + @Override + public boolean equals(Object obj) + { + if (this == obj) + { + return true; + } + if (!super.equals(obj)) + { + return false; + } + if (!(obj instanceof Owner)) + { + return false; + } + Owner other = (Owner) obj; + if (cars == null) + { + if (other.cars != null) + { + return false; + } + } + else if (!cars.equals(other.cars)) + { + return false; + } + if (totalValueOfCars == null) + { + if (other.totalValueOfCars != null) + { + return false; + } + } + else if (!totalValueOfCars.equals(other.totalValueOfCars)) + { + return false; + } + return true; + } + } Modified: trunk/openutils-bshd5/src/test/java/it/openutils/hibernate/test/model/Person.java =================================================================== --- trunk/openutils-bshd5/src/test/java/it/openutils/hibernate/test/model/Person.java 2011-12-01 08:26:28 UTC (rev 3714) +++ trunk/openutils-bshd5/src/test/java/it/openutils/hibernate/test/model/Person.java 2011-12-01 08:34:48 UTC (rev 3715) @@ -176,7 +176,7 @@ { return false; } - if (getClass() != obj.getClass()) + if (!(obj instanceof Person)) { return false; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |