I have a large set of POJO classes (100+) that I would like to convert to Java records. I would like to automate the process.
I am on Java 18 (Amazon Coretto JDK) and IntelliJ 2022.1.4 (Ultimate Edition): Build #IU-221.6008.13, built on July 18, 2022
coretto-18
is configured to be module's default VM.
I followed the IntelliJ documentation (https://www.jetbrains.com/idea/guide/tips/convert-to-record/), but the Context Actions on won't show the option "Convert to a record" (expected).
Records are immutable - all their fields are final
. "Convert to a record" in the Context Actions doesn't show up because your class isn't equivalent to a record. To get it, make all fields final
or change @Data
to its immutable version @Value
.