diff options
author | Jan Rieke <it@janrieke.de> | 2018-05-30 22:49:34 +0200 |
---|---|---|
committer | Jan Rieke <it@janrieke.de> | 2018-05-30 22:49:34 +0200 |
commit | 36c75b2d68551df3f297e8dcf10a8909307c854a (patch) | |
tree | 9571224f1df289154ee69972a6374eacf7a0c2a0 /src | |
parent | 4c5a7cddab109391d7494be2a0fc575b466dfa43 (diff) | |
download | lombok-36c75b2d68551df3f297e8dcf10a8909307c854a.tar.gz lombok-36c75b2d68551df3f297e8dcf10a8909307c854a.tar.bz2 lombok-36c75b2d68551df3f297e8dcf10a8909307c854a.zip |
no custom builders allowed, so there cannot be a toString() method
Diffstat (limited to 'src')
-rw-r--r-- | src/core/lombok/javac/handlers/HandleSuperBuilder.java | 27 |
1 files changed, 13 insertions, 14 deletions
diff --git a/src/core/lombok/javac/handlers/HandleSuperBuilder.java b/src/core/lombok/javac/handlers/HandleSuperBuilder.java index 0bb16d56..116de47b 100644 --- a/src/core/lombok/javac/handlers/HandleSuperBuilder.java +++ b/src/core/lombok/javac/handlers/HandleSuperBuilder.java @@ -262,18 +262,17 @@ public class HandleSuperBuilder extends JavacAnnotationHandler<SuperBuilder> { } // Create the toString() method for the abstract builder. - if (methodExists("toString", builderType, 0) == MemberExistsResult.NOT_EXISTS) { - java.util.List<JavacNode> fieldNodes = new ArrayList<JavacNode>(); - for (BuilderFieldData bfd : builderFields) { - fieldNodes.addAll(bfd.createdFields); - } - // Let toString() call super.toString() if there is a superclass, so that it also shows fields from the superclass' builder. - JCMethodDecl md = HandleToString.createToString(builderType, fieldNodes, true, superclassBuilderClassExpression != null, FieldAccess.ALWAYS_FIELD, ast); - if (md != null) { - injectMethod(builderType, md); - } + java.util.List<JavacNode> fieldNodes = new ArrayList<JavacNode>(); + for (BuilderFieldData bfd : builderFields) { + fieldNodes.addAll(bfd.createdFields); + } + // Let toString() call super.toString() if there is a superclass, so that it also shows fields from the superclass' builder. + JCMethodDecl toStringMethod = HandleToString.createToString(builderType, fieldNodes, true, superclassBuilderClassExpression != null, FieldAccess.ALWAYS_FIELD, ast); + if (toStringMethod != null) { + injectMethod(builderType, toStringMethod); } + // If clean methods are requested, add them now. if (addCleaning) { injectMethod(builderType, generateCleanMethod(builderFields, builderType, ast)); } @@ -304,10 +303,10 @@ public class HandleSuperBuilder extends JavacAnnotationHandler<SuperBuilder> { // Add the builder() method to the annotated class. // Allow users to specify their own builder() methods, e.g., to provide default values. if (methodExists(builderMethodName, tdParent, -1) == MemberExistsResult.NOT_EXISTS) { - JCMethodDecl md = generateBuilderMethod(builderMethodName, builderClassName, builderImplClassName, annotationNode, tdParent, typeParams); - recursiveSetGeneratedBy(md, ast, annotationNode.getContext()); - if (md != null) { - injectMethod(tdParent, md); + JCMethodDecl builderMethod = generateBuilderMethod(builderMethodName, builderClassName, builderImplClassName, annotationNode, tdParent, typeParams); + recursiveSetGeneratedBy(builderMethod, ast, annotationNode.getContext()); + if (builderMethod != null) { + injectMethod(tdParent, builderMethod); } } |