From 19ad4fd57d32afad1a33f20613fbb2e7607cfee0 Mon Sep 17 00:00:00 2001 From: Reinier Zwitserloot Date: Wed, 13 Jun 2018 23:21:00 +0200 Subject: [SuperBuilder] code review, style update, making it JDK1.6 compatible, documentation review, bugfix for setter auto-presuming chaining even when you didn’t configure it to chain. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- website/templates/features/experimental/SuperBuilder.html | 11 ++++------- website/templates/features/experimental/index.html | 2 +- 2 files changed, 5 insertions(+), 8 deletions(-) (limited to 'website') diff --git a/website/templates/features/experimental/SuperBuilder.html b/website/templates/features/experimental/SuperBuilder.html index 4801d373..0249e19a 100644 --- a/website/templates/features/experimental/SuperBuilder.html +++ b/website/templates/features/experimental/SuperBuilder.html @@ -3,7 +3,7 @@ <@f.scaffold title="@SuperBuilder" logline="Bob now knows his ancestors: Builders with fields from superclasses, too. "> <@f.history>

- @SuperBuilder was introduced as experimental feature in lombok v1.18.1. + @SuperBuilder was introduced as experimental feature in lombok v1.18.2.

@@ -19,10 +19,7 @@

@SuperBuilder can generate so-called 'singular' methods for collection parameters/fields. For details, see the @Singular documentation in @Builder.

- As lombok has no access to the fields of superclasses when generating the builder code, the methods for setting those superclass fields can only be in the builder of the superclass. - Therefore, a @SuperBuilder must extend the @SuperBuilder of the superclass in order to include those methods. - Furthermore, the generated builder code heavily relies on generics to avoid class casting when using the builder. - @SuperBuilder generates a private constructor on the class that takes a builder instances as a parameter. This constructor sets the fields of the new instance to the values from the builder. + @SuperBuilder generates a private constructor on the class that takes a builder instance as a parameter. This constructor sets the fields of the new instance to the values from the builder.

@SuperBuilder is not compatible with @Builder.

@@ -41,8 +38,6 @@

- <@f.snippets name="Builder" /> - <@f.confKeys>
lombok.superBuilder.flagUsage = [warning | error] (default: not set) @@ -66,6 +61,8 @@ The sorted collections (java.util: SortedSet, NavigableSet, SortedMap, NavigableMap and guava: ImmutableSortedSet, ImmutableSortedMap) require that the type argument of the collection has natural order (implements java.util.Comparable). There is no way to pass an explicit Comparator to use in the builder.

An ArrayList is used to store added elements as call methods of a @Singular marked field, if the target collection is from the java.util package, even if the collection is a set or map. Because lombok ensures that generated collections are compacted, a new backing instance of a set or map must be constructed anyway, and storing the data as an ArrayList during the build process is more efficient that storing it as a map or set. This behaviour is not externally visible, an implementation detail of the current implementation of the java.util recipes for @Singular. +

+ The generated builder code heavily relies on generics to avoid class casting when using the builder.

diff --git a/website/templates/features/experimental/index.html b/website/templates/features/experimental/index.html index 309303a0..988a7154 100644 --- a/website/templates/features/experimental/index.html +++ b/website/templates/features/experimental/index.html @@ -64,7 +64,7 @@ <@main.feature title="@SuperBuilder" href="SuperBuilder"> - Bob now knows his ancestors: Builders with fields from superclasses, too. + Bob now knows his ancestors: Builders with fields from superclasses, too. -- cgit