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

fix symmetricity of CustomEmojiImpl/RichCustomEmojiImpl#equals #2519

Merged
merged 2 commits into from
Aug 14, 2023
Merged

fix symmetricity of CustomEmojiImpl/RichCustomEmojiImpl#equals #2519

merged 2 commits into from
Aug 14, 2023

Conversation

danthe1st
Copy link
Contributor

@danthe1st danthe1st commented Aug 8, 2023

Pull Request Etiquette

Changes

  • Internal code
  • Library interface (affecting end-user code)
  • Documentation
  • Other: _____

Closes Issue: NaN

Description

The contract of Object#equals specifies:

It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.

This should hold when calling equals on an instance of RichCustomEmojiImpl and CustomEmojiImpl.

This is because CustomEmojiImpl allows any CustomEmoji and checks the id while RichCustomEmojiImpl expects a RichCustomEmojiImpl.

CustomEmoji a = new RichCustomEmojiImpl(123, someGuild);//using internal classes for demonstration
CustomEmoji b = new CustomEmojiImpl("a",123,true);
assert a.equals(b) == b.equals(a);//false

This PR changes RichCustomEmojiImpl to allow any CustomEmoji instances and CustomEmoji in order to check the emoji name just like RichCustomEmojiImpl.
This allows JDA users to easily compare two CustomEmoji instances.

@MinnDevelopment MinnDevelopment merged commit 79b1b56 into discord-jda:master Aug 14, 2023
1 check passed
@danthe1st danthe1st deleted the fix-emoji-equals-symmetricity branch August 14, 2023 19:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants