fixed equals/hashCode

git-svn-id: https://public-transport-enabler.googlecode.com/svn/trunk@950 0924bc21-9374-b0fa-ee44-9ff1593b38f0
This commit is contained in:
andreas.schildbach@gmail.com 2012-02-18 20:27:37 +00:00
parent 1f08364904
commit ed3ce3ccc5

View file

@ -123,9 +123,11 @@ public final class Location implements Serializable
return false;
if (this.id != other.id)
return false;
if (this.id != 0) // TODO needed?
return true;
return nullSafeEquals(this.name, other.name);
if (this.lat != other.lat || this.lon != other.lon)
return false;
if (this.id == 0 && !nullSafeEquals(this.name, other.name)) // only discriminate by name if no ids are given
return false;
return true;
}
@Override
@ -136,7 +138,9 @@ public final class Location implements Serializable
hashCode *= 29;
hashCode += id;
hashCode *= 29;
hashCode += nullSafeHashCode(name);
hashCode += lat;
hashCode *= 29;
hashCode += lon;
return hashCode;
}