aboutsummaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
Diffstat (limited to 'src/core')
-rw-r--r--src/core/lombok/eclipse/handlers/HandleSuperBuilder.java5
-rw-r--r--src/core/lombok/javac/handlers/HandleSuperBuilder.java61
2 files changed, 40 insertions, 26 deletions
diff --git a/src/core/lombok/eclipse/handlers/HandleSuperBuilder.java b/src/core/lombok/eclipse/handlers/HandleSuperBuilder.java
index 3a92da4a..1100cbf0 100644
--- a/src/core/lombok/eclipse/handlers/HandleSuperBuilder.java
+++ b/src/core/lombok/eclipse/handlers/HandleSuperBuilder.java
@@ -333,6 +333,11 @@ public class HandleSuperBuilder extends EclipseAnnotationHandler<SuperBuilder> {
injectMethod(builderType, generateCleanMethod(builderFields, builderType, ast));
}
+ if ((td.modifiers & ClassFileConstants.AccAbstract) != 0) {
+ // Abstract classes to not get the Builder implementation nor the builder() method.
+ return;
+ }
+
// Create the builder implementation class.
EclipseNode builderImplType = findInnerClass(tdParent, builderImplClassName);
if (builderImplType == null) {
diff --git a/src/core/lombok/javac/handlers/HandleSuperBuilder.java b/src/core/lombok/javac/handlers/HandleSuperBuilder.java
index beee47a9..1835bd48 100644
--- a/src/core/lombok/javac/handlers/HandleSuperBuilder.java
+++ b/src/core/lombok/javac/handlers/HandleSuperBuilder.java
@@ -282,42 +282,51 @@ public class HandleSuperBuilder extends JavacAnnotationHandler<SuperBuilder> {
if (addCleaning) {
injectMethod(builderType, generateCleanMethod(builderFields, builderType, ast));
}
+
+ recursiveSetGeneratedBy(builderType.get(), ast, annotationNode.getContext());
- // Create the builder implementation class.
- JavacNode builderImplType = findInnerClass(tdParent, builderImplClassName);
- if (builderImplType == null) {
- builderImplType = generateBuilderImplClass(annotationNode, tdParent, builderImplClassName, builderClassName, typeParams, ast);
- } else {
- annotationNode.addError("@SuperBuilder does not support customized builders. Use @Builder instead.");
- return;
- }
+ if ((td.mods.flags & Flags.ABSTRACT) == 0) {
+ // Only non-abstract classes get the Builder implementation.
- // Create a simple constructor for the BuilderImpl class.
- JCMethodDecl cd = HandleConstructor.createConstructor(AccessLevel.PRIVATE, List.<JCAnnotation>nil(), builderImplType, List.<JavacNode>nil(), false, annotationNode);
- if (cd != null) {
- injectMethod(builderImplType, cd);
- }
+ // Create the builder implementation class.
+ JavacNode builderImplType = findInnerClass(tdParent, builderImplClassName);
+ if (builderImplType == null) {
+ builderImplType = generateBuilderImplClass(annotationNode, tdParent, builderImplClassName, builderClassName, typeParams, ast);
+ } else {
+ annotationNode.addError("@SuperBuilder does not support customized builders. Use @Builder instead.");
+ return;
+ }
+
+ // Create a simple constructor for the BuilderImpl class.
+ JCMethodDecl cd = HandleConstructor.createConstructor(AccessLevel.PRIVATE, List.<JCAnnotation>nil(), builderImplType, List.<JavacNode>nil(), false, annotationNode);
+ if (cd != null) {
+ injectMethod(builderImplType, cd);
+ }
- // Create the self() and build() methods in the BuilderImpl.
- injectMethod(builderImplType, generateSelfMethod(builderImplType));
- injectMethod(builderImplType, generateBuildMethod(buildMethodName, returnType, builderImplType, thrownExceptions));
+ // Create the self() and build() methods in the BuilderImpl.
+ injectMethod(builderImplType, generateSelfMethod(builderImplType));
+ injectMethod(builderImplType, generateBuildMethod(buildMethodName, returnType, builderImplType, thrownExceptions));
+
+ recursiveSetGeneratedBy(builderImplType.get(), ast, annotationNode.getContext());
+ }
// Generate a constructor in the annotated class that takes a builder as argument.
generateBuilderBasedConstructor(tdParent, typeParams, builderFields, annotationNode, builderClassName,
superclassBuilderClassExpression != null);
- // 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 builderMethod = generateBuilderMethod(builderMethodName, builderClassName, builderImplClassName, annotationNode, tdParent, typeParams);
- recursiveSetGeneratedBy(builderMethod, ast, annotationNode.getContext());
- if (builderMethod != null) {
- injectMethod(tdParent, builderMethod);
+ if ((td.mods.flags & Flags.ABSTRACT) == 0) {
+ // Only non-abstract classes get the Builder implementation and the builder() method.
+
+ // 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 builderMethod = generateBuilderMethod(builderMethodName, builderClassName, builderImplClassName, annotationNode, tdParent, typeParams);
+ recursiveSetGeneratedBy(builderMethod, ast, annotationNode.getContext());
+ if (builderMethod != null) {
+ injectMethod(tdParent, builderMethod);
+ }
}
}
-
- recursiveSetGeneratedBy(builderType.get(), ast, annotationNode.getContext());
- recursiveSetGeneratedBy(builderImplType.get(), ast, annotationNode.getContext());
}
/**