apple / pkl

A configuration as code language with rich validation and tooling.
https://pkl-lang.org
Apache License 2.0
10.34k stars 280 forks source link

codegen-java: Support generating record classes #804

Open translatenix opened 1 day ago

translatenix commented 1 day ago

codegen-java should support generating record classes instead of regular classes whenever possible. (codegen-kotlin already generates data classes whenever possible.)

I have this almost working, but one important question remains: how to deal with backward compatibility?

One option is to introduce a —generate-records flag and only generate record classes if this flag is set. Another option is to ask users to stay on the 0.27 code generator until they are ready to switch to record classes. In any case, generating record classes should eventually become the default.

bioball commented 1 day ago

Yeah, definitely. Now with Java 11 dropped, the code generator should generate records. I think this is okay as a breaking change (generate java records by default, require flag to retain old behavior).