There are a few features that would be nice to add to the generator.
An option to add a static builder() method in the enclosing class. e.g.:
public record RecordA(String fieldOne, String fieldTwo) {
public static RecordABuilder builder() {
return new RecordABuilder();
}
public static final class RecordABuilder {
...
}
}
This would make the creation of the instances read a bit more fluent, e.g.:
RecordA a = RecordA.builder().withFieldOne("").build();
vs.
RecordA a = RecordABuilder.aRecordA().withFieldOne("").build();
A copy constructor for the builder, e.g.:
public record RecordA(String fieldOne, String fieldTwo) {
public static RecordABuilder builder() {
return new RecordABuilder();
}
public static RecordABuilder builder(RecordA recordA) {
return new RecordABuilder(recordA);
}
public static final class RecordABuilder {
private String fieldOne;
private String fieldTwo;
private RecordABuilder() {
}
private RecordABuilder(RecordA recordA) {
this.fieldOne = recordA.fieldOne();
this.fieldTwo = recordA.fieldTwo();
}
...
}
}
There are a few features that would be nice to add to the generator.
An option to add a static builder() method in the enclosing class. e.g.:
This would make the creation of the instances read a bit more fluent, e.g.:
vs.
A copy constructor for the builder, e.g.:
This would allow writing code like this:
Ability to ignore annotations on the class fields for which a builder is created. At the moment, it will generate the following: