Skip to content

Use pattern matching instead of type casting. #2785

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

Closed
junghoon-vans opened this issue Nov 30, 2023 · 0 comments · Fixed by #2784
Closed

Use pattern matching instead of type casting. #2785

junghoon-vans opened this issue Nov 30, 2023 · 0 comments · Fixed by #2784
Labels
status: waiting-for-triage An issue we've not yet triaged

Comments

@junghoon-vans
Copy link
Contributor

junghoon-vans commented Nov 30, 2023

If a type is resolved using the instanceof method, there is no need to explicitly cast the type.
This is thanks to the addition of JEP 394: Pattern Matching for instanceof in Java 16.

For example, a CriteriaFilterProcessor.java might change to the following:

AS-IS

if (value instanceof Box) {
    geoBBox = GeoBox.fromBox((Box) value);
}

TO-BE

if (value instanceof Box box) {
    geoBBox = GeoBox.fromBox(box);
}
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Nov 30, 2023
sothawo pushed a commit that referenced this issue Dec 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: waiting-for-triage An issue we've not yet triaged
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants