mirror of
https://gitlab.com/oeffi/public-transport-enabler.git
synced 2025-07-07 18:18:49 +00:00
again fixed equals/hashCode
git-svn-id: https://public-transport-enabler.googlecode.com/svn/trunk@954 0924bc21-9374-b0fa-ee44-9ff1593b38f0
This commit is contained in:
parent
7fae472aac
commit
c43ce463f0
1 changed files with 15 additions and 10 deletions
|
@ -121,11 +121,11 @@ public final class Location implements Serializable
|
|||
final Location other = (Location) o;
|
||||
if (this.type != other.type)
|
||||
return false;
|
||||
if (this.id != other.id)
|
||||
return false;
|
||||
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
|
||||
if (this.id != 0 && this.id == other.id)
|
||||
return true;
|
||||
if (this.lat != 0 && this.lon != 0 && this.lat == other.lat && this.lon == other.lon)
|
||||
return true;
|
||||
if (!nullSafeEquals(this.name, other.name)) // only discriminate by name if no ids are given
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
@ -136,11 +136,16 @@ public final class Location implements Serializable
|
|||
int hashCode = 0;
|
||||
hashCode += type.hashCode();
|
||||
hashCode *= 29;
|
||||
hashCode += id;
|
||||
hashCode *= 29;
|
||||
hashCode += lat;
|
||||
hashCode *= 29;
|
||||
hashCode += lon;
|
||||
if (id != 0)
|
||||
{
|
||||
hashCode += id;
|
||||
}
|
||||
else if (lat != 0 || lon != 0)
|
||||
{
|
||||
hashCode += lat;
|
||||
hashCode *= 29;
|
||||
hashCode += lon;
|
||||
}
|
||||
return hashCode;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue