Fix saving triggers metadata changed#9165
Conversation
Fixes #9159 Generate new equals, hashcode for FieldFormatterCleanup and toString methods
koppor
left a comment
There was a problem hiding this comment.
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-
| @Override | ||
| 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.
The new code seems to be the equial to the old one. ^^.
There was a problem hiding this comment.
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.
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.mddescribed in a way that is understandable for the average user (if applicable)