From c49e7d1872bc9ead8b8998234969e7ef95c77b7a Mon Sep 17 00:00:00 2001 From: Jan Rieke Date: Mon, 24 Sep 2018 18:25:03 +0200 Subject: SuperBuilder: customization documentation --- website/templates/features/experimental/SuperBuilder.html | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'website') diff --git a/website/templates/features/experimental/SuperBuilder.html b/website/templates/features/experimental/SuperBuilder.html index c0d24606..32877894 100644 --- a/website/templates/features/experimental/SuperBuilder.html +++ b/website/templates/features/experimental/SuperBuilder.html @@ -11,7 +11,7 @@

The @SuperBuilder annotation produces complex builder APIs for your classes. In contrast to @Builder, @SuperBuilder also works with fields from superclasses. - However, it only works for types, and cannot be customized by providing a partial builder implementation. + However, it only works for types, and customization possibilities are limited. Most importantly, it requires that all superclasses also have the @SuperBuilder annotation.

@SuperBuilder lets you automatically produce the code required to have your class be instantiable with code such as:
@@ -26,6 +26,9 @@ You can use @SuperBuilder(toBuilder = true) to also generate an instance method in your class called toBuilder(); it creates a new builder that starts out with all the values of this instance. You can put the @Builder.ObtainVia annotation on the fields to indicate alternative means by which the value for that field/parameter is obtained from this instance. For example, you can specify a method to be invoked: @Builder.ObtainVia(method = "calculateFoo").

To ensure type-safety, @SuperBuilder generates two inner builder classes for each annotated class, one abstract and one concrete class named FoobarBuilder and FoobarBuilderImpl (where Foobar is the name of the annotated class). +

+ Customizing the code generated by @SuperBuilder is limited to adding new methods or annotations to the builder classes, and providing custom implementations of builder() and build(). + You have to make sure that the builder class declaration headers match those that would have been generated by lombok. Due to the heavy generics usage, we strongly advice to copy the builder class definition header from the uncustomized delomboked code.

The configurable aspects of builder are: