Open NightJarJar opened 1 year ago
It's by design. There are two idioms for builder creation, and at least at the time of introduction of the @Builder
annotation in Lombok, there was no clear preference in the Java community.
So Lombok chose one (and IMO its the better one, because it's shorter and more readable especially when there are type parameters like with @SuperBuilder
). And as there should not be two syntactical ways for the same task, Lombok does not support the other idiom.
BTW: You can still customize your builder and manually implement a public constructor (it's just empty), and suppress the generation of the builder()
method by @Builder(builderMethodName="")
.
Hi, I am looking at the issues in this project so that I could contribute to this project. From the above discussion it seems that this bug could be closed ? Can I go ahead close this ?
I use the @Builder annotation in my project; when I try to get the Builder object using the new SomePojo.SomePojoBuilder() method, access is restricted By decompiling the class file, you can see that the Builder internal class modifier in the compiled class file is public static. Usually, in Java, an internal class modified by public static can be accessed externally; used @Builder class unused @Builder class Since the compiled class file has the internal class modified as public static, why can't I get the builder by new in my code? Instead, you have to call the static method builder() to get the builder.
This is my own hand-written Builder, which can be instantiated by way of new;
Is this a bug or is it by design?