-
Notifications
You must be signed in to change notification settings - Fork 1
Added equals/hashCode/toString methods to all bean objects #127
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,6 +27,27 @@ public static AssignmentCacheEntry fromBanditAssignment(BanditAssignment assignm | |
new BanditCacheValue(assignment.getBandit(), assignment.getAction())); | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (o == null || getClass() != o.getClass()) return false; | ||
AssignmentCacheEntry that = (AssignmentCacheEntry) o; | ||
return Objects.equals(key, that.key) | ||
&& Objects.equals(value, that.value); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(key, value); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "AssignmentCacheEntry{" + | ||
"key=" + key + | ||
", value=" + value + | ||
'}'; | ||
} | ||
|
||
@NotNull public AssignmentCacheKey getKey() { | ||
return key; | ||
} | ||
|
@@ -43,17 +64,4 @@ public static AssignmentCacheEntry fromBanditAssignment(BanditAssignment assignm | |
return value; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) return true; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this not still a useful check for equivalency? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is. I just moved the method to be consistent with the where you had the methods in other bean classes. |
||
if (o == null || getClass() != o.getClass()) return false; | ||
AssignmentCacheEntry that = (AssignmentCacheEntry) o; | ||
return Objects.equals(key, that.key) | ||
&& Objects.equals(value.getValueIdentifier(), that.value.getValueIdentifier()); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(key, 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.
This is a behavior change. Does that matter?
Old:
New:
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.
We discussed this in a separate medium, and we want to revert this change.