Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Location: equals(…) is not symmetric #558

Open
thtomate opened this issue Jan 29, 2024 · 0 comments
Open

Location: equals(…) is not symmetric #558

thtomate opened this issue Jan 29, 2024 · 0 comments

Comments

@thtomate
Copy link
Contributor

thtomate commented Jan 29, 2024

While developing a test for my last pull request, I encountered a problem with the comparison of Location objects.
It is not symmetric, i. e., the order of the objects of interest is relevant. This happens when only one of the objects has null as id or coord .

Example:
Define test stations:

Location station_with_name_and_id = new Location(LocationType.STATION, "1576", "Lummerland", "Muehle");
Location station_with_name = new Location(LocationType.STATION, null, "Lummerland", "Muehle");

Now:

station_with_name.equals(station_with_name_and_id)==true
station_with_name_and_id.equals(station_with_name)==false

This is unintuitive to use and mathematically unpleasing.

I guess the problem is at that line (and later for coord resp.):


There are pros and cons on which logical operator to use here when fixing.

@thtomate thtomate changed the title Location: equals(…) is not reflexive Location: equals(…) is not reflexive/symmetric Jan 29, 2024
@thtomate thtomate changed the title Location: equals(…) is not reflexive/symmetric Location: equals(…) is not symmetric Jan 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant