Skip to content
This repository was archived by the owner on Oct 23, 2021. It is now read-only.

Added equals() and hashCode() to DiscordRichPresence #11

Merged
merged 3 commits into from
Dec 15, 2017

Conversation

Almighty-Alpaca
Copy link
Contributor

No description provided.

Copy link
Owner

@MinnDevelopment MinnDevelopment left a 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,
Copy link
Owner

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

Copy link
Contributor Author

@Almighty-Alpaca Almighty-Alpaca Dec 14, 2017

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.

Copy link
Owner

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())
Copy link
Owner

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);
Copy link
Owner

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?

@MinnDevelopment MinnDevelopment merged commit 90c5133 into MinnDevelopment:master Dec 15, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants