According to the plugin documentation, the generated builder API should expose a static newBuilder() method on the outer class.
The documentation shows the following structure:
public class JavaBean {
private JavaBean(Builder builder) {
// ...
}
public static Builder newBuilder() {
return new Builder();
}
public static final class Builder {
private Builder() {
}
public JavaBean build() {
return new JavaBean(this);
}
}
}
So the expected usage is:
JavaBean.newBuilder()
.foo("value")
.build();
However, the plugin currently generates newBuilder() inside the nested Builder class instead of the outer class.
Actual generated code
public class TestDataClass2 {
private TestDataClass2(Builder builder) {
string = builder.string;
integer = builder.integer;
doubleNumber = builder.doubleNumber;
floatNumber = builder.floatNumber;
}
public static final class Builder {
private String string;
private int integer;
private Double doubleNumber;
private float floatNumber;
private Builder() {
}
public static Builder newBuilder() {
return new Builder();
}
public TestDataClass2 build() {
return new TestDataClass2(this);
}
}
}
Because of this, the generated API requires the following call:
TestDataClass2.Builder.newBuilder()
.string("value")
.integer(1)
.build();
Expected behavior
The generated code should match the documentation and place newBuilder() in the outer class:
public class TestDataClass2 {
private TestDataClass2(Builder builder) {
string = builder.string;
integer = builder.integer;
doubleNumber = builder.doubleNumber;
floatNumber = builder.floatNumber;
}
public static Builder newBuilder() {
return new Builder();
}
public static final class Builder {
private Builder() {
}
public TestDataClass2 build() {
return new TestDataClass2(this);
}
}
}
Expected usage:
TestDataClass2.newBuilder()
.string("value")
.integer(1)
.build();
Why this is a problem
The generated code does not match the documented API.
Also, since the Builder constructor is private, users cannot instantiate it directly. The only available factory method is currently located inside the nested Builder class, which makes the public API less convenient and inconsistent with the documentation.
Possible fix
Move the generated newBuilder() method from the nested Builder class to the outer generated class.
Alternatively, if the current behavior is intentional, the documentation should be updated to show the actual generated API:
TestDataClass2.Builder.newBuilder()
instead of:
TestDataClass2.newBuilder()
Environment
- Plugin version:
1.3.0
- IDE version:
IntelliJ IDEA 2026.1.1
- Java version:
17
- Generated class:
TestDataClass2
According to the plugin documentation, the generated builder API should expose a static
newBuilder()method on the outer class.The documentation shows the following structure:
So the expected usage is:
However, the plugin currently generates
newBuilder()inside the nestedBuilderclass instead of the outer class.Actual generated code
Because of this, the generated API requires the following call:
Expected behavior
The generated code should match the documentation and place
newBuilder()in the outer class:Expected usage:
Why this is a problem
The generated code does not match the documented API.
Also, since the
Builderconstructor is private, users cannot instantiate it directly. The only available factory method is currently located inside the nestedBuilderclass, which makes the public API less convenient and inconsistent with the documentation.Possible fix
Move the generated
newBuilder()method from the nestedBuilderclass to the outer generated class.Alternatively, if the current behavior is intentional, the documentation should be updated to show the actual generated API:
instead of:
Environment
1.3.0IntelliJ IDEA 2026.1.117TestDataClass2