From 80af03a3e48456e14b1b3da250047c531f460bb4 Mon Sep 17 00:00:00 2001 From: Jan Rieke Date: Mon, 24 Sep 2018 17:09:45 +0200 Subject: SuperBuilder toBuilder documentation --- website/templates/features/experimental/SuperBuilder.html | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'website') diff --git a/website/templates/features/experimental/SuperBuilder.html b/website/templates/features/experimental/SuperBuilder.html index 8189a254..c0d24606 100644 --- a/website/templates/features/experimental/SuperBuilder.html +++ b/website/templates/features/experimental/SuperBuilder.html @@ -22,6 +22,8 @@ @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. +

+ 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).

@@ -31,10 +33,12 @@ The build() method's name (default: "build")

  • The builder() method's name (default: "builder") +
  • + If you want toBuilder() (default: no)
  • Example usage where all options are changed from their defaults:
    - @SuperBuilder(buildMethodName = "execute", builderMethodName = "helloWorld")
    + @SuperBuilder(buildMethodName = "execute", builderMethodName = "helloWorld", toBuilder = true)

    -- cgit