-
Notifications
You must be signed in to change notification settings - Fork 15.4k
MINOR: Implement toStringBase to avoid duplicated code #14391
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 1 commit
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 |
|---|---|---|
|
|
@@ -26,8 +26,17 @@ public class AssignmentChangeApplicationEvent extends ApplicationEvent { | |
| final long currentTimeMs; | ||
|
|
||
| public AssignmentChangeApplicationEvent(final Map<TopicPartition, OffsetAndMetadata> offsets, final long currentTimeMs) { | ||
| super(Type.ASSIGNMENT_CHANGE); | ||
| super(Type.ASSIGNMENT_CHANGE, AssignmentChangeApplicationEvent.class.getSimpleName()); | ||
|
Member
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. This would then change back to how it was if we agree on using the getClass().getSimpleName() in the |
||
| this.offsets = offsets; | ||
| this.currentTimeMs = currentTimeMs; | ||
| } | ||
|
|
||
| @Override | ||
| public String toString() { | ||
| return "AssignmentChangeApplicationEvent{" + | ||
| toStringBase() + | ||
| ", offsets=" + offsets + | ||
| ", currentTimeMs=" + currentTimeMs + | ||
| '}'; | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -37,7 +37,7 @@ public class ListOffsetsApplicationEvent extends CompletableApplicationEvent<Map | |
| private final boolean requireTimestamps; | ||
|
|
||
| public ListOffsetsApplicationEvent(Map<TopicPartition, Long> timestampToSearch, boolean requireTimestamps) { | ||
| super(Type.LIST_OFFSETS); | ||
| super(Type.LIST_OFFSETS, ListOffsetsApplicationEvent.class.getSimpleName()); | ||
| this.timestampsToSearch = Collections.unmodifiableMap(timestampToSearch); | ||
| this.requireTimestamps = requireTimestamps; | ||
| } | ||
|
|
@@ -85,9 +85,10 @@ public int hashCode() { | |
|
|
||
| @Override | ||
| public String toString() { | ||
| return getClass().getSimpleName() + " {" + | ||
| "timestampsToSearch=" + timestampsToSearch + ", " + | ||
| "requireTimestamps=" + requireTimestamps + '}'; | ||
| return "ListOffsetsApplicationEvent{" + | ||
|
Member
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 it intentional to explicitly include "ListOffsetsApplicationEvent" here? it is in the "owner" section of the toStringBase too.
Member
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. (Similar for all other events that are explicitly including the class name and then calling the toStringBase) |
||
| toStringBase() + | ||
| ", timestampsToSearch=" + timestampsToSearch + | ||
| ", requireTimestamps=" + requireTimestamps + | ||
| '}'; | ||
| } | ||
|
|
||
| } | ||
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.
As a simplification, this is not needed I would say. We could just remove the owner var and constructor param, and leave only a simple
toStringBaselike this:It would end up returning the simple name of the child class, which is what we want in the end.
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.
maybe we could get rid of owner after all, and just have the calling class to print its name so that we could follow a more conventional toString(). Here's an example of how it might look like after getting rid of owner. Would this work?
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.
Sure, the point was to avoid the duplicated info in the toString, result of including the class name in the base class and in the child implementations. See my previous comment related to this down below.