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

Use kotlin auto-derived equals #13

Open
wants to merge 4 commits into
base: dev
Choose a base branch
from

Conversation

Profpatsch
Copy link

Kotlin can derive hashCode and equals automatically, I assume these were a leftover from a time when the code was still in Java?

In case some fields should be ignored for equality, you could put them in the body of the class, but nothing here ignored any fields it looks like.

@Stypox Stypox changed the base branch from master to dev November 29, 2024 21:24
equals() is the same as comparing each field, so we can use the Kotlin
impl, same for hashCode()
@Profpatsch Profpatsch force-pushed the use-auto-derived-equals branch from aa0242e to 70cc364 Compare November 29, 2024 21:26
@ShareASmile ShareASmile added the code quality Improvements to the codebase to improve the code quality label Nov 30, 2024
@Profpatsch Profpatsch force-pushed the use-auto-derived-equals branch from 70cc364 to 3405892 Compare November 30, 2024 11:57
@Profpatsch
Copy link
Author

Note: it is important that the classes are data classes, otherwise the default referential equality from Any (Object) is used.

Copy link
Member

@theScrabi theScrabi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
code quality Improvements to the codebase to improve the code quality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants