mirror of
https://gitlab.com/oeffi/public-transport-enabler.git
synced 2025-07-09 19:48:48 +00:00
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:
parent
1c250f367a
commit
2de9f14e4d
2 changed files with 23 additions and 0 deletions
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue