We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
You added the ability to create builders for records (issue 69) after I requested it last year. Thanks for that, I use it often.
I'd like to request a tweak to the logic.
When generating a builder for a record, the plugin should not create a private constructor in the record that takes a Builder instance.
That is because a record by its very nature always has a public full-argument constructor which can be called from the Builder.
As an example, this is what the plugin currently does:
public record Request(Object argument) { private Request(Builder builder) { this(builder.argument); } public static Builder builder() { return new Builder(); } public static final class Builder { private Object argument; private Builder() {} public Builder argument(Object argument) { this.argument = argument; return this; } public Request build() { return new Request(this); } } }
This is what I believe would be a better alternative:
public record Request(Object argument) { public static Builder builder() { return new Builder(); } public static final class Builder { private Object argument; private Builder() {} public Builder argument(Object argument) { this.argument = argument; return this; } public Request build() { return new Request(argument); } } }
Less code and a more strict single canonical constructor for record instances.
The text was updated successfully, but these errors were encountered:
#71 - Avoid extra constructor + mockito update
455c2de
#71 - Doc update
06d03f5
Merge pull request #72 from helospark/gh-71-avoid-extra-constructor
2052f7f
Avoid extra constructor for records
Hi @mdewilde ! I released this change in 0.0.29.
Sorry, something went wrong.
No branches or pull requests
You added the ability to create builders for records (issue 69) after I requested it last year. Thanks for that, I use it often.
I'd like to request a tweak to the logic.
When generating a builder for a record, the plugin should not create a private constructor in the record that takes a Builder instance.
That is because a record by its very nature always has a public full-argument constructor which can be called from the Builder.
As an example, this is what the plugin currently does:
This is what I believe would be a better alternative:
Less code and a more strict single canonical constructor for record instances.
The text was updated successfully, but these errors were encountered: