LineDestination.equals(): Compare all fields of destination location. This works around a rare case of Hafas destinations having IDs of other locations.

This commit is contained in:
Andreas Schildbach 2016-11-24 13:22:29 +01:00
parent 1c250f367a
commit 2de9f14e4d
2 changed files with 23 additions and 0 deletions

View file

@ -50,6 +50,9 @@ public final class LineDestination implements Serializable {
return false;
if (!Objects.equal(this.destination, other.destination))
return false;
// This workaround is necessary because in rare cases destinations have IDs of other locations.
if (this.destination != null && !this.destination.equalsAllFields(other.destination))
return false;
return true;
}

View file

@ -169,10 +169,30 @@ public final class Location implements Serializable {
return this.lat == other.lat && this.lon == other.lon;
// only discriminate by name/place if no ids are given
if (!Objects.equal(this.place, other.place))
return false;
if (!Objects.equal(this.name, other.name))
return false;
return true;
}
public boolean equalsAllFields(final Location other) {
if (other == this)
return true;
if (other == null)
return false;
if (!Objects.equal(this.type, other.type))
return false;
if (!Objects.equal(this.id, other.id))
return false;
if (this.lat != other.lat && this.lon != other.lon)
return false;
if (!Objects.equal(this.place, other.place))
return false;
if (!Objects.equal(this.name, other.name))
return false;
if (!Objects.equal(this.products, other.products))
return false;
return true;
}