mirror of
https://gitlab.com/oeffi/public-transport-enabler.git
synced 2025-07-07 22:28:51 +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;
|
final Location other = (Location) o;
|
||||||
if (this.type != other.type)
|
if (this.type != other.type)
|
||||||
return false;
|
return false;
|
||||||
if (this.id != other.id)
|
if (this.id != 0 && this.id == other.id)
|
||||||
return false;
|
return true;
|
||||||
if (this.lat != other.lat || this.lon != other.lon)
|
if (this.lat != 0 && this.lon != 0 && this.lat == other.lat && this.lon == other.lon)
|
||||||
return false;
|
return true;
|
||||||
if (this.id == 0 && !nullSafeEquals(this.name, other.name)) // only discriminate by name if no ids are given
|
if (!nullSafeEquals(this.name, other.name)) // only discriminate by name if no ids are given
|
||||||
return false;
|
return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -136,11 +136,16 @@ public final class Location implements Serializable
|
||||||
int hashCode = 0;
|
int hashCode = 0;
|
||||||
hashCode += type.hashCode();
|
hashCode += type.hashCode();
|
||||||
hashCode *= 29;
|
hashCode *= 29;
|
||||||
hashCode += id;
|
if (id != 0)
|
||||||
hashCode *= 29;
|
{
|
||||||
hashCode += lat;
|
hashCode += id;
|
||||||
hashCode *= 29;
|
}
|
||||||
hashCode += lon;
|
else if (lat != 0 || lon != 0)
|
||||||
|
{
|
||||||
|
hashCode += lat;
|
||||||
|
hashCode *= 29;
|
||||||
|
hashCode += lon;
|
||||||
|
}
|
||||||
return hashCode;
|
return hashCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue