Skip to content
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

Improve handling of interfaces in LombokValueToRecord #452

Merged

Conversation

holgpar
Copy link
Contributor

@holgpar holgpar commented Apr 3, 2024

What's changed?

Before, no conversion was done when any interface was implemented.
Now, it is checked that the interface declares a method which would "conflict" with the conversion.

What's your motivation?

Anything in particular you'd like reviewers to focus on?

Anyone you would like to review specifically?

@knutwannheden

Have you considered any alternatives or workarounds?

Any additional context

Checklist

  • I've added unit tests to cover both positive and negative cases
  • I've read and applied the recipe conventions and best practices
  • I've used the IntelliJ IDEA auto-formatter on affected files

@holgpar holgpar force-pushed the dontConvertClassesThatImplementInterfaces branch from d0321f0 to 84b7b1f Compare April 3, 2024 15:30
github-actions[bot]

This comment was marked as outdated.

@holgpar holgpar force-pushed the dontConvertClassesThatImplementInterfaces branch from 84b7b1f to 73a3101 Compare April 3, 2024 15:37
github-actions[bot]

This comment was marked as outdated.

&& !J.ClassDeclaration.Kind.Type.Record.equals(classDeclaration.getKind())
&& classDeclaration.getAllAnnotations().stream()
.allMatch(ann -> LOMBOK_VALUE_MATCHER.matches(ann) && (ann.getArguments() == null || ann.getArguments().isEmpty()))
&& !allAnnotations.isEmpty()
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is necessary because allMatch will return true on an empty set. The recipe would then convert an empty interface to a record. Not sure why that did not cause issue before.

this also considers methods inherited by super-interfaces.
@holgpar holgpar force-pushed the dontConvertClassesThatImplementInterfaces branch from 73a3101 to c5e8a58 Compare April 3, 2024 15:42
@holgpar holgpar marked this pull request as ready for review April 3, 2024 15:43
github-actions[bot]

This comment was marked as outdated.

@timtebeek timtebeek added the enhancement New feature or request label Apr 24, 2024
@timtebeek timtebeek self-requested a review April 24, 2024 10:05
Copy link
Contributor

@timtebeek timtebeek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice extension of what can now be converted for this recipe; thanks a lot @holgpar !
Hope that helps you convert more cases there to records.

@timtebeek timtebeek merged commit dfbee69 into openrewrite:main Apr 24, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants