From 80af03a3e48456e14b1b3da250047c531f460bb4 Mon Sep 17 00:00:00 2001
From: Jan Rieke @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"
)
"builder"
)
+ toBuilder()
(default: no)
@SuperBuilder(buildMethodName = "execute", builderMethodName = "helloWorld")
@SuperBuilder(buildMethodName = "execute", builderMethodName = "helloWorld", toBuilder = true)