From a3180298305ff64e9f671b51d663b750ba7c8efa Mon Sep 17 00:00:00 2001 From: Reinier Zwitserloot Date: Wed, 1 May 2019 00:41:32 +0200 Subject: [fixes #2083] adds feature ‘access level’ to `@Builder` MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- website/templates/features/Builder.html | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'website/templates/features/Builder.html') diff --git a/website/templates/features/Builder.html b/website/templates/features/Builder.html index 0818f9d2..4fe416ee 100644 --- a/website/templates/features/Builder.html +++ b/website/templates/features/Builder.html @@ -12,6 +12,8 @@ @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.

@@ -64,10 +66,12 @@ The builder() method's name (default: "builder")
  • If you want toBuilder() (default: no) +
  • + The access level of all generated elements (default: public).
  • Example usage where all options are changed from their defaults:
    - @Builder(builderClassName = "HelloWorldBuilder", buildMethodName = "execute", builderMethodName = "helloWorld", toBuilder = true)
    + @Builder(builderClassName = "HelloWorldBuilder", buildMethodName = "execute", builderMethodName = "helloWorld", toBuilder = true, access = AccessLevel.PRIVATE)

    @@ -194,6 +198,9 @@ public class JacksonExample { 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.

    -- cgit