-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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 saving triggers metadata changed #9165
Conversation
Fixes #9159 Generate new equals, hashcode for FieldFormatterCleanup and toString methods
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.
LGTM!
To cover cases when new fields are added to the classes, maybe, we should add test cases with deepEquals of AssertJ - https://stackoverflow.com/a/9633089/873282
Note to self: Testing equality by reflection is not an option, as a) it used reflection and b) is less performant: https://commons.apache.org/proper/commons-lang/apidocs/org/apache/commons/lang3/builder/EqualsBuilder.html#reflectionAppend-java.lang.Object-java.lang.Object-
public boolean equals(Object o) { | ||
if (this == o) { | ||
public boolean equals(Object obj) { | ||
if (this == obj) { | ||
return true; | ||
} | ||
if (o instanceof FieldFormatterCleanup) { | ||
FieldFormatterCleanup that = (FieldFormatterCleanup) o; | ||
return Objects.equals(field, that.field) && Objects.equals(formatter, that.formatter); | ||
if (!(obj instanceof FieldFormatterCleanup)) { | ||
return false; | ||
} | ||
return false; | ||
FieldFormatterCleanup other = (FieldFormatterCleanup) obj; | ||
return Objects.equals(field, other.field) && Objects.equals(formatter, other.formatter); | ||
} |
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.
The new code seems to be the equial to the old one. ^^.
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 just used eclipse to regenerate it to have it consistent with others
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(actions, enabled); | ||
} | ||
|
||
@Override | ||
public boolean equals(Object obj) { | ||
if (this == obj) { | ||
return true; | ||
} | ||
if (!(obj instanceof FieldFormatterCleanups)) { | ||
return false; | ||
} | ||
FieldFormatterCleanups other = (FieldFormatterCleanups) obj; | ||
return Objects.equals(actions, other.actions) && (enabled == other.enabled); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "FieldFormatterCleanups [enabled=" + enabled + ", actions=" + actions + "]"; | ||
} |
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.
Thank you for putting in the implementations here. I googled and found
By default, two objects are equal if and only if they are refer to the same memory location
Fixes #9159
Generate new equals, hashcode for FieldFormatterCleanup and toString methods
CHANGELOG.md
described in a way that is understandable for the average user (if applicable)