Replace explicit type conversion with instanceof pattern variable in part non-core modules#15842
Merged
Conversation
…part non-core modules Signed-off-by: Binlong Gao <gbinlong@amazon.com>
dweiss
reviewed
Apr 1, 2026
| } else { | ||
| if (((Hyphen) item).noBreak != null) { | ||
| res.append(((Hyphen) item).noBreak); | ||
| if (item instanceof Hyphen h && h.noBreak != null) { |
Contributor
There was a problem hiding this comment.
this is subtly different - the refactored version will silently pass when item is not a Hyphen (previously, it'd throw ClassCastException. I don't think this matters.
Contributor
Author
There was a problem hiding this comment.
Thanks, reverted that back.
Comment on lines
+97
to
+99
| if (q instanceof RegexpQuery query) { | ||
| String regexp = parseOutRegexp(query.toString("")); | ||
| String selected = selectLongestSubstring(regexp); |
Contributor
There was a problem hiding this comment.
I think I liked the previous version better - the short-circuit at the front instead of the long conditional block.
Contributor
Author
There was a problem hiding this comment.
Changed that, thanks!
Contributor
|
Also, conflict needs to be resolved. |
Signed-off-by: Binlong Gao <gbinlong@amazon.com>
Signed-off-by: Binlong Gao <gbinlong@amazon.com>
Signed-off-by: Binlong Gao <gbinlong@amazon.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
As a follow-up of #15837, replace all explicit type conversions with instanceof pattern variable in part non-core modules like analysis, codecs, facets, grouping, highlighter etc, using the modern style aims to improve the code readability and reduces potential ClassCastException risks.