-
Notifications
You must be signed in to change notification settings - Fork 40
Added equals() and hashCode() to DiscordRichPresence #11
Added equals() and hashCode() to DiscordRichPresence #11
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you also add equals to the other structures
@Override | ||
public int hashCode() | ||
{ | ||
return Objects.hash(state, details, startTimestamp, endTimestamp, largeImageKey, largeImageText, smallImageKey, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe the identity hashCode is better for JNA structures as they represent a pointer value
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That would contradict the general contract of hashCode() though.
If two objects are equal according to the equals(Object) method, then calling the hashCode method on each of the two objects must produce the same integer result.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see, I still want the other structs to get the same treatment ^^
{ | ||
if (this == o) | ||
return true; | ||
if (o == null || getClass() != o.getClass()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the reason not to use instanceof
?
if (!super.equals(o)) | ||
return false; | ||
DiscordEventHandlers that = (DiscordEventHandlers) o; | ||
return Objects.equals(ready, that.ready) && Objects.equals(disconnected, that.disconnected) && Objects.equals(errored, that.errored) && Objects.equals(joinGame, that.joinGame) && Objects.equals(spectateGame, that.spectateGame) && Objects.equals(joinRequest, that.joinRequest); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this line so long?
No description provided.