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

Migrate from @lombok.Value to Java records #141

Closed
timtebeek opened this issue Oct 30, 2022 · 0 comments · Fixed by #319
Closed

Migrate from @lombok.Value to Java records #141

timtebeek opened this issue Oct 30, 2022 · 0 comments · Fixed by #319
Labels
recipe Recipe requested

Comments

@timtebeek
Copy link
Contributor

Convert the simplest cases of Lombok value classes into Java Records.
Narrowly scoped initially, as there's a lot of sometimes experimental Lombok annotations that can complicate matters.

Initial classes should:

  • not have any other Lombok annotations
  • not have any fields with Lombok annotations
  • not have an explicit constructor
  • not have explicit methods
  • not use generics

The conversion should:

  • create a record with the same fields, in the same order
  • replace any class getter calls with record accessor calls
  • remove the lombok.Value annotation & import

The conversion could;

  • have a parameter to create an exact .toString() replacement

Ideally, given the limited scope, the implementation should not suffer from a lack of Lombok support in the parser. A one-to-one replacement for these simplest of cases should mostly behave the same, with the exception of the .toString() method by default.

Similar to #116 & #124.

@pway99 pway99 moved this to Backlog in OpenRewrite Nov 1, 2022
@pway99 pway99 moved this from Backlog to Recipes Wanted in OpenRewrite Nov 3, 2022
kevin0x90 added a commit to kevin0x90/rewrite-migrate-java that referenced this issue Oct 14, 2023
kevin0x90 added a commit to kevin0x90/rewrite-migrate-java that referenced this issue Oct 15, 2023
kevin0x90 added a commit to kevin0x90/rewrite-migrate-java that referenced this issue Oct 16, 2023
kevin0x90 added a commit to kevin0x90/rewrite-migrate-java that referenced this issue Oct 16, 2023
kevin0x90 added a commit to kevin0x90/rewrite-migrate-java that referenced this issue Oct 16, 2023
kevin0x90 added a commit to kevin0x90/rewrite-migrate-java that referenced this issue Oct 16, 2023
kevin0x90 added a commit to kevin0x90/rewrite-migrate-java that referenced this issue Oct 19, 2023
kevin0x90 added a commit to kevin0x90/rewrite-migrate-java that referenced this issue Oct 19, 2023
@timtebeek timtebeek linked a pull request Oct 19, 2023 that will close this issue
3 tasks
kevin0x90 added a commit to kevin0x90/rewrite-migrate-java that referenced this issue Oct 19, 2023
kevin0x90 added a commit to kevin0x90/rewrite-migrate-java that referenced this issue Oct 19, 2023
kevin0x90 added a commit to kevin0x90/rewrite-migrate-java that referenced this issue Oct 19, 2023
kevin0x90 added a commit to kevin0x90/rewrite-migrate-java that referenced this issue Oct 19, 2023
kevin0x90 added a commit to kevin0x90/rewrite-migrate-java that referenced this issue Oct 23, 2023
kevin0x90 added a commit to kevin0x90/rewrite-migrate-java that referenced this issue Oct 26, 2023
timtebeek added a commit that referenced this issue Oct 27, 2023
* #141 add draft of lombok value to java record conversion

* License headers

* #141 extend implementation with further acceptance criterias

* #141 add useExactToString option to generate an exact version of the lombok toString method

* #141 format files

* #141 minor refactoring

* #141 re-order static member

* #141 review feedback adjustments

* #141 code review feedback, only convert classes without member field annotations

* #141 code review feedback, refactor to ScanningRecipe

* #141 add lombok value to record conversion to lombok recipes

* #141 remove final modifiers in order to align more to already existing code

* #141 adjusts precondition check to usage of use type in favor of MaybeUsesImport

* Use AnnotationMatcher in more places

* Add a test with a static field that breaks

* #141 do not convert classes with static members

* Collapse checks that all statements are record compatible fields

* Extract a separate ScannerVisitor

* Add TODO to add type to record constructor post conversion

* Any member assignment disqualifies, not just literal

* Polish

* Polish

* Polish

* #141 address review feedback

* Adopt Boolean for `useExactToString`

* Make `useExactToString` optional

---------

Co-authored-by: Tim te Beek <tim@moderne.io>
@github-project-automation github-project-automation bot moved this from Recipes Wanted to Done in OpenRewrite Oct 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
recipe Recipe requested
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

1 participant