Builder pattern for Java records

Alberto Otero Rodríguez albest512 at hotmail.com
Fri May 21 15:37:04 UTC 2021


Hi, I have found this project on GitHub which creates a Builder for Java records:
https://github.com/Randgalt/record-builder
[https://opengraph.githubassets.com/a4e3a7b3c7b16b51e0854011fe4b031577bcc09919058baef412b03613295d20/Randgalt/record-builder]<https://github.com/Randgalt/record-builder>
GitHub - Randgalt/record-builder: Record builder generator for Java records<https://github.com/Randgalt/record-builder>
The target package for generation is the same as the package that contains the "Include" annotation. Use packagePattern to change this (see Javadoc for details).. Usage Maven. Add the dependency that contains the @RecordBuilder annotation. < dependency > < groupId >io.soabase.record-builder</ groupId > < artifactId >record-builder-core</ artifactId > < version >set-version-here</ version ...
github.com

And I was wondering if this could be made by default in all Java Records.

Technically a Builder is only used when creating the Object so I think is possible and, if Java creates it by default, would be less error prone than creating it manually.

Regards,

Alberto.


More information about the core-libs-dev mailing list