FreeBuilder
FreeBuilder copied to clipboard
Buildable types don't get setters accepting Builders when Builder is package private
trafficstars
When not part of the same package, that's necessary to avoid compile time errors, but here they are part of the same package. Note that I tested this on a composed @FreeBuilder type, not on other buildable types.
For example, this won't work because setNested2 doesn't have a overload that accepts a Nested2.Builder.
public class Foo {
void test() {
new Nested1.Builder().setNested2(new Nested2.Builder());
}
@FreeBuilder
abstract static class Nested1 {
abstract Nested2 getNested2();
static class Builder extends Foo_Nested1_Builder {}
}
@FreeBuilder
abstract static class Nested2 {
static class Builder extends Foo_Nested2_Builder {}
}
}
But if make Nested2.Builder public, even without making Nested2 public, i.e.
@FreeBuilder
abstract static class Nested2 {
public static class Builder extends Foo_Nested2_Builder {}
}
the setter is generated.