mirror of
https://gitlab.com/oeffi/public-transport-enabler.git
synced 2025-07-21 01:39:51 +00:00
LineDestination.equals(): Compare only uniqueShortName() of destination location. This works around a rare case of Hafas destinations having IDs of other locations. Also, there are sometimes different IDs for almost the same locations.
This commit is contained in:
parent
2da1a0290c
commit
ff085d1245
1 changed files with 6 additions and 4 deletions
|
@ -48,17 +48,19 @@ public final class LineDestination implements Serializable {
|
|||
final LineDestination other = (LineDestination) o;
|
||||
if (!Objects.equal(this.line, other.line))
|
||||
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))
|
||||
final String thisDestinationName = this.destination != null ? this.destination.uniqueShortName() : null;
|
||||
final String otherDestinationName = other.destination != null ? other.destination.uniqueShortName() : null;
|
||||
if (!Objects.equal(thisDestinationName, otherDestinationName))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(line, destination);
|
||||
// This workaround is necessary because in rare cases destinations have IDs of other locations.
|
||||
final String destinationName = destination != null ? destination.uniqueShortName() : null;
|
||||
return Objects.hashCode(line, destinationName);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue