-
Notifications
You must be signed in to change notification settings - Fork 71
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
Class To Record #391
Labels
recipe
Recipe requested
Comments
Thanks! Would indeed be nice to have, although we should be careful not to change this in libraries, as that would require that consumers are also updated. There had been a similar earlier issue logged as well, with a first implementation outline |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
What problem are you trying to solve?
It would be neat to have a capability to convert a
class
to arecord
What precondition(s) should be checked before applying this recipe?
class
to arecord
)class
from being arecord
, such as:this(...)
in the first lineDescribe the situation before applying the recipe
See Java's specification for Records for context:
https://docs.oracle.com/en/java/javase/17/language/records.html#GUID-6699E26F-4A9B-4393-A08B-1E47D4B2D263
Describe the situation after applying the recipe
getColor()
tocolor()
)equals
/hashCode
/toString
implementations are removed in favor of the defaultHave you considered any alternatives or workarounds?
Any additional context
The implementation for Lombok value to record likely has some useful code to reference/reuse.
This feels like a problem with many weird edge cases (even beyond what's written above), but even a naive implementation which only handles some of those scenarios could probably still be valuable, and the recipe could grow iteratively from there.
Are you interested in contributing this recipe to OpenRewrite?
Maybe; priority TBD
The text was updated successfully, but these errors were encountered: