From a3180298305ff64e9f671b51d663b750ba7c8efa Mon Sep 17 00:00:00 2001
From: Reinier Zwitserloot @Builder.Default
functionality was added in lombok v1.16.16.
@Builder(builderMethodName = "")
is legal (and will suppress generation of the builder method) starting with lombok v1.18.8.
+
+ @Builder(access = AccessLevel.PACKAGE)
is legal (and will generate the builder class, the builder method, etc with the indicated access level) starting with lombok v1.18.8.
"builder"
)
toBuilder()
(default: no)
+ public
).
@Builder(builderClassName = "HelloWorldBuilder", buildMethodName = "execute", builderMethodName = "helloWorld", toBuilder = true)
@Builder(builderClassName = "HelloWorldBuilder", buildMethodName = "execute", builderMethodName = "helloWorld", toBuilder = true, access = AccessLevel.PRIVATE)
builder
method if you just want this functionality, by using: @Builder(toBuilder = true, builderMethodName = "")
.
Due to a peculiar way javac processes static imports, trying to do a non-star static import of the static builder()
method won't work. Either use a star static import: `import static TypeThatHasABuilder.*;` or don't statically import the builder
method.
+
+ If setting the access level to PROTECTED
, all methods generated inside the builder class are actually generated as public
; the meaning of the
+ protected
keyword is different inside the inner class, and the precise behaviour that PROTECTED
would indicate (access by any source in the same package is allowed, as well as any subclasses from the outer class, marked with @Builder
is not possible, and marking the inner members public
is as close as we can get.