aboutsummaryrefslogtreecommitdiff
path: root/src/core/lombok/javac/handlers
diff options
context:
space:
mode:
authorJan Rieke <rieke@subshell.com>2017-03-13 15:59:46 +0100
committerJan Rieke <rieke@subshell.com>2017-03-13 16:04:08 +0100
commitf51bbce3e396a0151bc0242d00e250f2bc720316 (patch)
tree54aa7e0e15d231557703c792708203e0e380ddec /src/core/lombok/javac/handlers
parentbd51fa8484fde587eef10fc58e4527f26ec16430 (diff)
downloadlombok-f51bbce3e396a0151bc0242d00e250f2bc720316.tar.gz
lombok-f51bbce3e396a0151bc0242d00e250f2bc720316.tar.bz2
lombok-f51bbce3e396a0151bc0242d00e250f2bc720316.zip
do not assign values in build() method for extendable builders (WIP)
Diffstat (limited to 'src/core/lombok/javac/handlers')
-rw-r--r--src/core/lombok/javac/handlers/HandleBuilder.java41
1 files changed, 22 insertions, 19 deletions
diff --git a/src/core/lombok/javac/handlers/HandleBuilder.java b/src/core/lombok/javac/handlers/HandleBuilder.java
index 7701d85c..41ff64e0 100644
--- a/src/core/lombok/javac/handlers/HandleBuilder.java
+++ b/src/core/lombok/javac/handlers/HandleBuilder.java
@@ -546,27 +546,30 @@ public class HandleBuilder extends JavacAnnotationHandler<Builder> {
JCExpression call;
ListBuffer<JCStatement> statements = new ListBuffer<JCStatement>();
-
- if (addCleaning) {
- JCExpression notClean = maker.Unary(CTC_NOT, maker.Select(maker.Ident(type.toName("this")), type.toName("$lombokUnclean")));
- JCStatement invokeClean = maker.Exec(maker.Apply(List.<JCExpression>nil(), maker.Ident(type.toName("$lombokClean")), List.<JCExpression>nil()));
- JCIf ifUnclean = maker.If(notClean, invokeClean, null);
- statements.append(ifUnclean);
- }
-
- for (BuilderFieldData bfd : builderFields) {
- if (bfd.singularData != null && bfd.singularData.getSingularizer() != null) {
- bfd.singularData.getSingularizer().appendBuildCode(bfd.singularData, type, source, statements, bfd.name);
- }
- }
-
ListBuffer<JCExpression> args = new ListBuffer<JCExpression>();
- for (BuilderFieldData bfd : builderFields) {
- args.append(maker.Ident(bfd.name));
- }
+
+ // Extendable builders assign their values in the constructor, not in this build() method.
+ if (!useBuilderBasedConstructor) {
+ if (addCleaning) {
+ JCExpression notClean = maker.Unary(CTC_NOT, maker.Select(maker.Ident(type.toName("this")), type.toName("$lombokUnclean")));
+ JCStatement invokeClean = maker.Exec(maker.Apply(List.<JCExpression>nil(), maker.Ident(type.toName("$lombokClean")), List.<JCExpression>nil()));
+ JCIf ifUnclean = maker.If(notClean, invokeClean, null);
+ statements.append(ifUnclean);
+ }
+
+ for (BuilderFieldData bfd : builderFields) {
+ if (bfd.singularData != null && bfd.singularData.getSingularizer() != null) {
+ bfd.singularData.getSingularizer().appendBuildCode(bfd.singularData, type, source, statements, bfd.name);
+ }
+ }
- if (addCleaning) {
- statements.append(maker.Exec(maker.Assign(maker.Select(maker.Ident(type.toName("this")), type.toName("$lombokUnclean")), maker.Literal(CTC_BOOLEAN, true))));
+ for (BuilderFieldData bfd : builderFields) {
+ args.append(maker.Ident(bfd.name));
+ }
+
+ if (addCleaning) {
+ statements.append(maker.Exec(maker.Assign(maker.Select(maker.Ident(type.toName("this")), type.toName("$lombokUnclean")), maker.Literal(CTC_BOOLEAN, true))));
+ }
}
if (builderName == null) {