diff --git a/src/core/lombok/Builder.java b/src/core/lombok/Builder.java index 06ca3853ba..7fc89fc418 100644 --- a/src/core/lombok/Builder.java +++ b/src/core/lombok/Builder.java @@ -120,6 +120,14 @@ @Retention(SOURCE) public @interface Default {} + /** + * The field annotated with {@code @Exclude} will be excluded from the builder. Excluded objects will be initialized as null + * and primitives with their default value. + */ + @Target(FIELD) + @Retention(SOURCE) + @interface Exclude {} + /** @return Name of the method that creates a new builder instance. Default: {@code builder}. If the empty string, suppress generating the {@code builder} method. */ String builderMethodName() default "builder"; diff --git a/src/core/lombok/eclipse/handlers/HandleBuilder.java b/src/core/lombok/eclipse/handlers/HandleBuilder.java index a63d3b36b9..43f365bbd3 100755 --- a/src/core/lombok/eclipse/handlers/HandleBuilder.java +++ b/src/core/lombok/eclipse/handlers/HandleBuilder.java @@ -24,12 +24,14 @@ import static lombok.core.handlers.HandlerUtil.*; import static lombok.eclipse.Eclipse.*; import static lombok.eclipse.handlers.EclipseHandlerUtil.*; +import static lombok.javac.handlers.JavacHandlerUtil.findAnnotation; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.List; +import lombok.javac.JavacNode; import org.eclipse.jdt.internal.compiler.ast.ASTNode; import org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration; import org.eclipse.jdt.internal.compiler.ast.AbstractVariableDeclaration; @@ -228,6 +230,7 @@ static class BuilderFieldData { ObtainVia obtainVia; EclipseNode obtainViaNode; EclipseNode originalFieldNode; + boolean toExclude = false; List createdFields = new ArrayList(); } @@ -323,6 +326,10 @@ private static final char[] prefixWith(char[] prefix, char[] name) { bfd.type = fd.type; bfd.singularData = getSingularData(fieldNode, ast, annInstance.setterPrefix()); bfd.originalFieldNode = fieldNode; + EclipseNode isExcluded = findAnnotation(Builder.Exclude.class, fieldNode); + if (isExcluded != null) { + bfd.toExclude = true; + } if (bfd.singularData != null && isDefault != null) { isDefault.addError("@Builder.Default and @Singular cannot be mixed."); @@ -553,7 +560,9 @@ private static final char[] prefixWith(char[] prefix, char[] name) { } for (BuilderFieldData bfd : job.builderFields) { - makePrefixedSetterMethodsForBuilder(job, bfd, annInstance.setterPrefix()); + if (!bfd.toExclude) { + makePrefixedSetterMethodsForBuilder(job, bfd, annInstance.setterPrefix()); + } } { diff --git a/src/core/lombok/eclipse/handlers/HandleBuilderExclude.java b/src/core/lombok/eclipse/handlers/HandleBuilderExclude.java new file mode 100644 index 0000000000..bbd5826577 --- /dev/null +++ b/src/core/lombok/eclipse/handlers/HandleBuilderExclude.java @@ -0,0 +1,26 @@ +package lombok.eclipse.handlers; + +import lombok.Builder; +import lombok.core.AST; +import lombok.core.AnnotationValues; +import lombok.core.HandlerPriority; +import lombok.eclipse.EclipseAnnotationHandler; +import lombok.eclipse.EclipseNode; +import lombok.experimental.SuperBuilder; +import lombok.spi.Provides; +import org.eclipse.jdt.internal.compiler.ast.Annotation; + +@Provides +@HandlerPriority(-1025) //HandleBuilder's level, minus one. +public class HandleBuilderExclude extends EclipseAnnotationHandler { + @Override + public void handle(AnnotationValues annotation, Annotation ast, EclipseNode annotationNode) { + EclipseNode annotatedField = annotationNode.up(); + if (annotatedField.getKind() != AST.Kind.FIELD) return; + EclipseNode classWithAnnotatedField = annotatedField.up(); + if (!EclipseHandlerUtil.hasAnnotation(Builder.class, classWithAnnotatedField) && !EclipseHandlerUtil.hasAnnotation("lombok.experimental.Builder", classWithAnnotatedField) + && !EclipseHandlerUtil.hasAnnotation(SuperBuilder.class, classWithAnnotatedField)) { + annotationNode.addWarning("@Builder.Exclude requires @Builder or @SuperBuilder on the class for it to mean anything."); + } + } +} diff --git a/src/core/lombok/eclipse/handlers/HandleSuperBuilder.java b/src/core/lombok/eclipse/handlers/HandleSuperBuilder.java index 82e561de52..35dc7e771f 100644 --- a/src/core/lombok/eclipse/handlers/HandleSuperBuilder.java +++ b/src/core/lombok/eclipse/handlers/HandleSuperBuilder.java @@ -25,6 +25,7 @@ import static lombok.core.handlers.HandlerUtil.*; import static lombok.eclipse.Eclipse.*; import static lombok.eclipse.handlers.EclipseHandlerUtil.*; +import static lombok.javac.handlers.JavacHandlerUtil.findAnnotation; import java.lang.reflect.Modifier; import java.util.ArrayList; @@ -33,6 +34,7 @@ import java.util.HashSet; import java.util.List; +import lombok.javac.JavacNode; import org.eclipse.jdt.internal.compiler.ast.ASTNode; import org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration; import org.eclipse.jdt.internal.compiler.ast.AbstractVariableDeclaration; @@ -198,6 +200,7 @@ void setBuilderToAbstract() { boolean valuePresent = (hasAnnotation(lombok.Value.class, parent) || hasAnnotation("lombok.experimental.Value", parent)); for (EclipseNode fieldNode : HandleConstructor.findAllFields(parent, true)) { + FieldDeclaration fd = (FieldDeclaration) fieldNode.get(); EclipseNode isDefault = findAnnotation(Builder.Default.class, fieldNode); boolean isFinal = ((fd.modifiers & ClassFileConstants.AccFinal) != 0) || (valuePresent && !hasAnnotation(NonFinal.class, fieldNode)); @@ -212,6 +215,10 @@ void setBuilderToAbstract() { bfd.type = fd.type; bfd.singularData = getSingularData(fieldNode, ast, annInstance.setterPrefix()); bfd.originalFieldNode = fieldNode; + EclipseNode isExcluded = findAnnotation(Builder.Exclude.class, fieldNode); + if (isExcluded != null) { + bfd.toExclude = true; + } if (bfd.singularData != null && isDefault != null) { isDefault.addError("@Builder.Default and @Singular cannot be mixed."); @@ -389,7 +396,9 @@ void setBuilderToAbstract() { // Create the setter methods in the abstract builder. for (BuilderFieldData bfd : job.builderFields) { - generateSetterMethodsForBuilder(job, bfd, builderGenericName, annInstance.setterPrefix()); + if (!bfd.toExclude) { + generateSetterMethodsForBuilder(job, bfd, builderGenericName, annInstance.setterPrefix()); + } } // Generate abstract self() and build() methods in the abstract builder. diff --git a/src/core/lombok/javac/handlers/HandleBuilder.java b/src/core/lombok/javac/handlers/HandleBuilder.java index d814c05a93..42fd6afb3a 100644 --- a/src/core/lombok/javac/handlers/HandleBuilder.java +++ b/src/core/lombok/javac/handlers/HandleBuilder.java @@ -192,6 +192,7 @@ static class BuilderFieldData { ObtainVia obtainVia; JavacNode obtainViaNode; JavacNode originalFieldNode; + boolean toExclude = false; java.util.List createdFields = new ArrayList(); } @@ -264,6 +265,10 @@ static class BuilderFieldData { bfd.type = fd.vartype; bfd.singularData = getSingularData(fieldNode, annInstance.setterPrefix()); bfd.originalFieldNode = fieldNode; + JavacNode isExcluded = findAnnotation(Builder.Exclude.class, fieldNode, false); + if (isExcluded != null) { + bfd.toExclude = true; + } if (bfd.singularData != null && isDefault != null) { isDefault.addError("@Builder.Default and @Singular cannot be mixed."); @@ -489,7 +494,9 @@ static class BuilderFieldData { } for (BuilderFieldData bfd : job.builderFields) { - makePrefixedSetterMethodsForBuilder(job, bfd, annInstance.setterPrefix()); + if (!bfd.toExclude) { + makePrefixedSetterMethodsForBuilder(job, bfd, annInstance.setterPrefix()); + } } { diff --git a/src/core/lombok/javac/handlers/HandleBuilderExclude.java b/src/core/lombok/javac/handlers/HandleBuilderExclude.java new file mode 100644 index 0000000000..aa6221fea1 --- /dev/null +++ b/src/core/lombok/javac/handlers/HandleBuilderExclude.java @@ -0,0 +1,29 @@ +package lombok.javac.handlers; + +import com.sun.tools.javac.tree.JCTree; +import lombok.Builder; +import lombok.core.AST; +import lombok.core.AnnotationValues; +import lombok.core.HandlerPriority; +import lombok.experimental.SuperBuilder; +import lombok.javac.JavacAnnotationHandler; +import lombok.javac.JavacNode; +import lombok.spi.Provides; + +import static lombok.javac.handlers.JavacHandlerUtil.deleteAnnotationIfNeccessary; +import static lombok.javac.handlers.JavacHandlerUtil.hasAnnotation; + +@Provides +@HandlerPriority(-1026) //HandleBuilder's level, minus one. +public class HandleBuilderExclude extends JavacAnnotationHandler { + @Override public void handle(AnnotationValues annotation, JCTree.JCAnnotation ast, JavacNode annotationNode) { + JavacNode annotatedField = annotationNode.up(); + if (annotatedField.getKind() != AST.Kind.FIELD) return; + JavacNode classWithAnnotatedField = annotatedField.up(); + if (!hasAnnotation(Builder.class, classWithAnnotatedField) && !hasAnnotation("lombok.experimental.Builder", classWithAnnotatedField) + && !hasAnnotation(SuperBuilder.class, classWithAnnotatedField)) { + annotationNode.addWarning("@Builder.Exclude requires @Builder or @SuperBuilder on the class for it to mean anything."); + deleteAnnotationIfNeccessary(annotationNode, Builder.Exclude.class); + } + } +} diff --git a/src/core/lombok/javac/handlers/HandleBuilderExcludeRemove.java b/src/core/lombok/javac/handlers/HandleBuilderExcludeRemove.java new file mode 100644 index 0000000000..0f3533d10f --- /dev/null +++ b/src/core/lombok/javac/handlers/HandleBuilderExcludeRemove.java @@ -0,0 +1,25 @@ +package lombok.javac.handlers; + +import static lombok.javac.handlers.JavacHandlerUtil.*; + +import com.sun.tools.javac.tree.JCTree.JCAnnotation; + +import lombok.Builder; +import lombok.Builder.Exclude; +import lombok.core.AlreadyHandledAnnotations; +import lombok.core.AnnotationValues; +import lombok.core.HandlerPriority; +import lombok.javac.JavacAnnotationHandler; +import lombok.javac.JavacNode; +import lombok.spi.Provides; + +@Provides +@HandlerPriority(32768) +@AlreadyHandledAnnotations +public class HandleBuilderExcludeRemove extends JavacAnnotationHandler { + @Override public void handle(AnnotationValues annotation, JCAnnotation ast, JavacNode annotationNode) { + deleteAnnotationIfNeccessary(annotationNode, Builder.Exclude.class); + deleteImportFromCompilationUnit(annotationNode, Builder.class.getName()); + deleteImportFromCompilationUnit(annotationNode, Builder.Exclude.class.getName()); + } +} \ No newline at end of file diff --git a/src/core/lombok/javac/handlers/HandleSuperBuilder.java b/src/core/lombok/javac/handlers/HandleSuperBuilder.java index c468fb77f7..fa0db8de4c 100644 --- a/src/core/lombok/javac/handlers/HandleSuperBuilder.java +++ b/src/core/lombok/javac/handlers/HandleSuperBuilder.java @@ -190,6 +190,10 @@ public void handle(AnnotationValues annotation, JCAnnotation ast, bfd.type = fd.vartype; bfd.singularData = getSingularData(fieldNode, annInstance.setterPrefix()); bfd.originalFieldNode = fieldNode; + JavacNode isExcluded = findAnnotation(Builder.Exclude.class, fieldNode, false); + if (isExcluded != null) { + bfd.toExclude = true; + } if (bfd.singularData != null && isDefault != null) { isDefault.addError("@Builder.Default and @Singular cannot be mixed."); @@ -341,7 +345,9 @@ public void handle(AnnotationValues annotation, JCAnnotation ast, // Create the setter methods in the abstract builder. for (BuilderFieldData bfd : job.builderFields) { - generateSetterMethodsForBuilder(job, bfd, builderGenericName, annInstance.setterPrefix()); + if (!bfd.toExclude) { + generateSetterMethodsForBuilder(job, bfd, builderGenericName, annInstance.setterPrefix()); + } } // Generate abstract self() and build() methods in the abstract builder. diff --git a/test/transform/resource/after-delombok/BuilderExcludes.java b/test/transform/resource/after-delombok/BuilderExcludes.java new file mode 100644 index 0000000000..4fffd5a133 --- /dev/null +++ b/test/transform/resource/after-delombok/BuilderExcludes.java @@ -0,0 +1,72 @@ +public class BuilderExcludes { + long x; + int y; + int z; + + @java.lang.SuppressWarnings("all") + @lombok.Generated + BuilderExcludes(final long x, final int y, final int z) { + this.x = x; + this.y = y; + this.z = z; + } + + + @java.lang.SuppressWarnings("all") + @lombok.Generated + public static class BuilderExcludesBuilder { + @java.lang.SuppressWarnings("all") + @lombok.Generated + private long x; + @java.lang.SuppressWarnings("all") + @lombok.Generated + private int y; + @java.lang.SuppressWarnings("all") + @lombok.Generated + private int z; + + @java.lang.SuppressWarnings("all") + @lombok.Generated + BuilderExcludesBuilder() { + } + + /** + * @return {@code this}. + */ + @java.lang.SuppressWarnings("all") + @lombok.Generated + public BuilderExcludes.BuilderExcludesBuilder x(final long x) { + this.x = x; + return this; + } + + /** + * @return {@code this}. + */ + @java.lang.SuppressWarnings("all") + @lombok.Generated + public BuilderExcludes.BuilderExcludesBuilder y(final int y) { + this.y = y; + return this; + } + + @java.lang.SuppressWarnings("all") + @lombok.Generated + public BuilderExcludes build() { + return new BuilderExcludes(this.x, this.y, this.z); + } + + @java.lang.Override + @java.lang.SuppressWarnings("all") + @lombok.Generated + public java.lang.String toString() { + return "BuilderExcludes.BuilderExcludesBuilder(x=" + this.x + ", y=" + this.y + ", z=" + this.z + ")"; + } + } + + @java.lang.SuppressWarnings("all") + @lombok.Generated + public static BuilderExcludes.BuilderExcludesBuilder builder() { + return new BuilderExcludes.BuilderExcludesBuilder(); + } +} \ No newline at end of file diff --git a/test/transform/resource/after-delombok/BuilderExcludesWarnings.java b/test/transform/resource/after-delombok/BuilderExcludesWarnings.java new file mode 100644 index 0000000000..6b56e7eaf4 --- /dev/null +++ b/test/transform/resource/after-delombok/BuilderExcludesWarnings.java @@ -0,0 +1,153 @@ +public class BuilderExcludesWarnings { + long x; + int y; + int z; + + @java.lang.SuppressWarnings("all") + @lombok.Generated + BuilderExcludesWarnings(final long x, final int y, final int z) { + this.x = x; + this.y = y; + this.z = z; + } + + + @java.lang.SuppressWarnings("all") + @lombok.Generated + public static class BuilderExcludesWarningsBuilder { + @java.lang.SuppressWarnings("all") + @lombok.Generated + private long x; + @java.lang.SuppressWarnings("all") + @lombok.Generated + private int y; + @java.lang.SuppressWarnings("all") + @lombok.Generated + private int z; + + @java.lang.SuppressWarnings("all") + @lombok.Generated + BuilderExcludesWarningsBuilder() { + } + + /** + * @return {@code this}. + */ + @java.lang.SuppressWarnings("all") + @lombok.Generated + public BuilderExcludesWarnings.BuilderExcludesWarningsBuilder x(final long x) { + this.x = x; + return this; + } + + /** + * @return {@code this}. + */ + @java.lang.SuppressWarnings("all") + @lombok.Generated + public BuilderExcludesWarnings.BuilderExcludesWarningsBuilder y(final int y) { + this.y = y; + return this; + } + + @java.lang.SuppressWarnings("all") + @lombok.Generated + public BuilderExcludesWarnings build() { + return new BuilderExcludesWarnings(this.x, this.y, this.z); + } + + @java.lang.Override + @java.lang.SuppressWarnings("all") + @lombok.Generated + public java.lang.String toString() { + return "BuilderExcludesWarnings.BuilderExcludesWarningsBuilder(x=" + this.x + ", y=" + this.y + ", z=" + this.z + ")"; + } + } + + @java.lang.SuppressWarnings("all") + @lombok.Generated + public static BuilderExcludesWarnings.BuilderExcludesWarningsBuilder builder() { + return new BuilderExcludesWarnings.BuilderExcludesWarningsBuilder(); + } +} + +class NoBuilderButHasExcludes { + long x; + int y; + int z; + + public NoBuilderButHasExcludes(long x, int y, int z) { + this.x = x; + this.y = y; + this.z = z; + } + + + @java.lang.SuppressWarnings("all") + @lombok.Generated + public static class NoBuilderButHasExcludesBuilder { + @java.lang.SuppressWarnings("all") + @lombok.Generated + private long x; + @java.lang.SuppressWarnings("all") + @lombok.Generated + private int y; + @java.lang.SuppressWarnings("all") + @lombok.Generated + private int z; + + @java.lang.SuppressWarnings("all") + @lombok.Generated + NoBuilderButHasExcludesBuilder() { + } + + /** + * @return {@code this}. + */ + @java.lang.SuppressWarnings("all") + @lombok.Generated + public NoBuilderButHasExcludes.NoBuilderButHasExcludesBuilder x(final long x) { + this.x = x; + return this; + } + + /** + * @return {@code this}. + */ + @java.lang.SuppressWarnings("all") + @lombok.Generated + public NoBuilderButHasExcludes.NoBuilderButHasExcludesBuilder y(final int y) { + this.y = y; + return this; + } + + /** + * @return {@code this}. + */ + @java.lang.SuppressWarnings("all") + @lombok.Generated + public NoBuilderButHasExcludes.NoBuilderButHasExcludesBuilder z(final int z) { + this.z = z; + return this; + } + + @java.lang.SuppressWarnings("all") + @lombok.Generated + public NoBuilderButHasExcludes build() { + return new NoBuilderButHasExcludes(this.x, this.y, this.z); + } + + @java.lang.Override + @java.lang.SuppressWarnings("all") + @lombok.Generated + public java.lang.String toString() { + return "NoBuilderButHasExcludes.NoBuilderButHasExcludesBuilder(x=" + this.x + ", y=" + this.y + ", z=" + this.z + ")"; + } + } + + @java.lang.SuppressWarnings("all") + @lombok.Generated + public static NoBuilderButHasExcludes.NoBuilderButHasExcludesBuilder builder() { + return new NoBuilderButHasExcludes.NoBuilderButHasExcludesBuilder(); + } +} \ No newline at end of file diff --git a/test/transform/resource/after-delombok/BuilderExcludesWithAllArgsConstructor.java b/test/transform/resource/after-delombok/BuilderExcludesWithAllArgsConstructor.java new file mode 100644 index 0000000000..827ec6cbba --- /dev/null +++ b/test/transform/resource/after-delombok/BuilderExcludesWithAllArgsConstructor.java @@ -0,0 +1,73 @@ +public class BuilderExcludesWithAllArgsConstructor { + long x; + int y; + int z; + + + @java.lang.SuppressWarnings("all") + @lombok.Generated + public static class BuilderExcludesWithAllArgsConstructorBuilder { + @java.lang.SuppressWarnings("all") + @lombok.Generated + private long x; + @java.lang.SuppressWarnings("all") + @lombok.Generated + private int y; + @java.lang.SuppressWarnings("all") + @lombok.Generated + private int z; + + @java.lang.SuppressWarnings("all") + @lombok.Generated + BuilderExcludesWithAllArgsConstructorBuilder() { + } + + /** + * @return {@code this}. + */ + @java.lang.SuppressWarnings("all") + @lombok.Generated + public BuilderExcludesWithAllArgsConstructor.BuilderExcludesWithAllArgsConstructorBuilder x(final long x) { + this.x = x; + return this; + } + + /** + * @return {@code this}. + */ + @java.lang.SuppressWarnings("all") + @lombok.Generated + public BuilderExcludesWithAllArgsConstructor.BuilderExcludesWithAllArgsConstructorBuilder y(final int y) { + this.y = y; + return this; + } + + @java.lang.SuppressWarnings("all") + @lombok.Generated + public BuilderExcludesWithAllArgsConstructor build() { + return new BuilderExcludesWithAllArgsConstructor(this.x, this.y, this.z); + } + + @java.lang.Override + @java.lang.SuppressWarnings("all") + @lombok.Generated + public java.lang.String toString() { + return "BuilderExcludesWithAllArgsConstructor.BuilderExcludesWithAllArgsConstructorBuilder(x=" + this.x + ", y=" + this.y + ", z=" + this.z + ")"; + } + } + + @java.lang.SuppressWarnings("all") + @lombok.Generated + public static BuilderExcludesWithAllArgsConstructor.BuilderExcludesWithAllArgsConstructorBuilder builder() { + return new BuilderExcludesWithAllArgsConstructor.BuilderExcludesWithAllArgsConstructorBuilder(); + } + + @java.lang.SuppressWarnings("all") + @lombok.Generated + public BuilderExcludesWithAllArgsConstructor(final long x, final int y, final int z) { + this.x = x; + this.y = y; + this.z = z; + } +} + \ No newline at end of file diff --git a/test/transform/resource/after-delombok/BuilderExcludesWithDefault.java b/test/transform/resource/after-delombok/BuilderExcludesWithDefault.java new file mode 100644 index 0000000000..b1e8736320 --- /dev/null +++ b/test/transform/resource/after-delombok/BuilderExcludesWithDefault.java @@ -0,0 +1,83 @@ +public class BuilderExcludesWithDefault { + long x; + int y; + int z; + + @java.lang.SuppressWarnings("all") + @lombok.Generated + private static int $default$z() { + return 5; + } + + @java.lang.SuppressWarnings("all") + @lombok.Generated + BuilderExcludesWithDefault(final long x, final int y, final int z) { + this.x = x; + this.y = y; + this.z = z; + } + + + @java.lang.SuppressWarnings("all") + @lombok.Generated + public static class BuilderExcludesWithDefaultBuilder { + @java.lang.SuppressWarnings("all") + @lombok.Generated + private long x; + @java.lang.SuppressWarnings("all") + @lombok.Generated + private int y; + @java.lang.SuppressWarnings("all") + @lombok.Generated + private boolean z$set; + @java.lang.SuppressWarnings("all") + @lombok.Generated + private int z$value; + + @java.lang.SuppressWarnings("all") + @lombok.Generated + BuilderExcludesWithDefaultBuilder() { + } + + /** + * @return {@code this}. + */ + @java.lang.SuppressWarnings("all") + @lombok.Generated + public BuilderExcludesWithDefault.BuilderExcludesWithDefaultBuilder x(final long x) { + this.x = x; + return this; + } + + /** + * @return {@code this}. + */ + @java.lang.SuppressWarnings("all") + @lombok.Generated + public BuilderExcludesWithDefault.BuilderExcludesWithDefaultBuilder y(final int y) { + this.y = y; + return this; + } + + @java.lang.SuppressWarnings("all") + @lombok.Generated + public BuilderExcludesWithDefault build() { + int z$value = this.z$value; + if (!this.z$set) z$value = BuilderExcludesWithDefault.$default$z(); + return new BuilderExcludesWithDefault(this.x, this.y, z$value); + } + + @java.lang.Override + @java.lang.SuppressWarnings("all") + @lombok.Generated + public java.lang.String toString() { + return "BuilderExcludesWithDefault.BuilderExcludesWithDefaultBuilder(x=" + this.x + ", y=" + this.y + ", z$value=" + this.z$value + ")"; + } + } + + @java.lang.SuppressWarnings("all") + @lombok.Generated + public static BuilderExcludesWithDefault.BuilderExcludesWithDefaultBuilder builder() { + return new BuilderExcludesWithDefault.BuilderExcludesWithDefaultBuilder(); + } +} \ No newline at end of file diff --git a/test/transform/resource/after-delombok/SuperBuilderWithExcludes.java b/test/transform/resource/after-delombok/SuperBuilderWithExcludes.java new file mode 100644 index 0000000000..c7bccaa5f8 --- /dev/null +++ b/test/transform/resource/after-delombok/SuperBuilderWithExcludes.java @@ -0,0 +1,194 @@ +public class SuperBuilderWithExcludes { + + public static class Parent { + private long excludedParentField; + private N numberField; + private long randomFieldP; + + + @java.lang.SuppressWarnings("all") + @lombok.Generated + public static abstract class ParentBuilder, B extends SuperBuilderWithExcludes.Parent.ParentBuilder> { + @java.lang.SuppressWarnings("all") + @lombok.Generated + private long excludedParentField; + @java.lang.SuppressWarnings("all") + @lombok.Generated + private N numberField; + @java.lang.SuppressWarnings("all") + @lombok.Generated + private long randomFieldP; + + /** + * @return {@code this}. + */ + @java.lang.SuppressWarnings("all") + @lombok.Generated + public B numberField(final N numberField) { + this.numberField = numberField; + return self(); + } + + /** + * @return {@code this}. + */ + @java.lang.SuppressWarnings("all") + @lombok.Generated + public B randomFieldP(final long randomFieldP) { + this.randomFieldP = randomFieldP; + return self(); + } + + @java.lang.SuppressWarnings("all") + @lombok.Generated + protected abstract B self(); + + @java.lang.SuppressWarnings("all") + @lombok.Generated + public abstract C build(); + + @java.lang.Override + @java.lang.SuppressWarnings("all") + @lombok.Generated + public java.lang.String toString() { + return "SuperBuilderWithExcludes.Parent.ParentBuilder(excludedParentField=" + this.excludedParentField + ", numberField=" + this.numberField + ", randomFieldP=" + this.randomFieldP + ")"; + } + } + + + @java.lang.SuppressWarnings("all") + @lombok.Generated + private static final class ParentBuilderImpl extends SuperBuilderWithExcludes.Parent.ParentBuilder, SuperBuilderWithExcludes.Parent.ParentBuilderImpl> { + @java.lang.SuppressWarnings("all") + @lombok.Generated + private ParentBuilderImpl() { + } + + @java.lang.Override + @java.lang.SuppressWarnings("all") + @lombok.Generated + protected SuperBuilderWithExcludes.Parent.ParentBuilderImpl self() { + return this; + } + + @java.lang.Override + @java.lang.SuppressWarnings("all") + @lombok.Generated + public SuperBuilderWithExcludes.Parent build() { + return new SuperBuilderWithExcludes.Parent(this); + } + } + + @java.lang.SuppressWarnings("all") + @lombok.Generated + protected Parent(final SuperBuilderWithExcludes.Parent.ParentBuilder b) { + this.excludedParentField = b.excludedParentField; + this.numberField = b.numberField; + this.randomFieldP = b.randomFieldP; + } + + @java.lang.SuppressWarnings("all") + @lombok.Generated + public static SuperBuilderWithExcludes.Parent.ParentBuilder builder() { + return new SuperBuilderWithExcludes.Parent.ParentBuilderImpl(); + } + } + + + public static class Child extends Parent { + private double doubleField; + private long excludedChildField; + private long randomFieldC; + + + @java.lang.SuppressWarnings("all") + @lombok.Generated + public static abstract class ChildBuilder> extends Parent.ParentBuilder { + @java.lang.SuppressWarnings("all") + @lombok.Generated + private double doubleField; + @java.lang.SuppressWarnings("all") + @lombok.Generated + private long excludedChildField; + @java.lang.SuppressWarnings("all") + @lombok.Generated + private long randomFieldC; + + /** + * @return {@code this}. + */ + @java.lang.SuppressWarnings("all") + @lombok.Generated + public B doubleField(final double doubleField) { + this.doubleField = doubleField; + return self(); + } + + /** + * @return {@code this}. + */ + @java.lang.SuppressWarnings("all") + @lombok.Generated + public B randomFieldC(final long randomFieldC) { + this.randomFieldC = randomFieldC; + return self(); + } + + @java.lang.Override + @java.lang.SuppressWarnings("all") + @lombok.Generated + protected abstract B self(); + + @java.lang.Override + @java.lang.SuppressWarnings("all") + @lombok.Generated + public abstract C build(); + + @java.lang.Override + @java.lang.SuppressWarnings("all") + @lombok.Generated + public java.lang.String toString() { + return "SuperBuilderWithExcludes.Child.ChildBuilder(super=" + super.toString() + ", doubleField=" + this.doubleField + ", excludedChildField=" + this.excludedChildField + ", randomFieldC=" + this.randomFieldC + ")"; + } + } + + + @java.lang.SuppressWarnings("all") + @lombok.Generated + private static final class ChildBuilderImpl extends SuperBuilderWithExcludes.Child.ChildBuilder { + @java.lang.SuppressWarnings("all") + @lombok.Generated + private ChildBuilderImpl() { + } + + @java.lang.Override + @java.lang.SuppressWarnings("all") + @lombok.Generated + protected SuperBuilderWithExcludes.Child.ChildBuilderImpl self() { + return this; + } + + @java.lang.Override + @java.lang.SuppressWarnings("all") + @lombok.Generated + public SuperBuilderWithExcludes.Child build() { + return new SuperBuilderWithExcludes.Child(this); + } + } + + @java.lang.SuppressWarnings("all") + @lombok.Generated + protected Child(final SuperBuilderWithExcludes.Child.ChildBuilder b) { + super(b); + this.doubleField = b.doubleField; + this.excludedChildField = b.excludedChildField; + this.randomFieldC = b.randomFieldC; + } + + @java.lang.SuppressWarnings("all") + @lombok.Generated + public static SuperBuilderWithExcludes.Child.ChildBuilder builder() { + return new SuperBuilderWithExcludes.Child.ChildBuilderImpl(); + } + } +} \ No newline at end of file diff --git a/test/transform/resource/after-ecj/BuilderExcludes.java b/test/transform/resource/after-ecj/BuilderExcludes.java new file mode 100644 index 0000000000..c8d1384d0a --- /dev/null +++ b/test/transform/resource/after-ecj/BuilderExcludes.java @@ -0,0 +1,52 @@ +import lombok.Builder; + +public @Builder class BuilderExcludes { + public static @java.lang.SuppressWarnings("all") @lombok.Generated class BuilderExcludesBuilder { + private @java.lang.SuppressWarnings("all") @lombok.Generated long x; + private @java.lang.SuppressWarnings("all") @lombok.Generated int y; + private @java.lang.SuppressWarnings("all") @lombok.Generated int z; + + @java.lang.SuppressWarnings("all") @lombok.Generated BuilderExcludesBuilder() { + super(); + } + + /** + * @return {@code this}. + */ + public @java.lang.SuppressWarnings("all") @lombok.Generated BuilderExcludes.BuilderExcludesBuilder x(final long x) { + this.x = x; + return this; + } + + /** + * @return {@code this}. + */ + public @java.lang.SuppressWarnings("all") @lombok.Generated BuilderExcludes.BuilderExcludesBuilder y(final int y) { + this.y = y; + return this; + } + + public @java.lang.SuppressWarnings("all") @lombok.Generated BuilderExcludes build() { + return new BuilderExcludes(this.x, this.y, this.z); + } + + public @java.lang.Override @java.lang.SuppressWarnings("all") @lombok.Generated java.lang.String toString() { + return (((((("BuilderExcludes.BuilderExcludesBuilder(x=" + this.x) + ", y=") + this.y) + ", z=") + this.z) + ")"); + } + } + + long x; + int y; + @Builder.Exclude int z; + + @java.lang.SuppressWarnings("all") @lombok.Generated BuilderExcludes(final long x, final int y, final int z) { + super(); + this.x = x; + this.y = y; + this.z = z; + } + + public static @java.lang.SuppressWarnings("all") @lombok.Generated BuilderExcludes.BuilderExcludesBuilder builder() { + return new BuilderExcludes.BuilderExcludesBuilder(); + } +} diff --git a/test/transform/resource/after-ecj/BuilderExcludesWarnings.java b/test/transform/resource/after-ecj/BuilderExcludesWarnings.java new file mode 100644 index 0000000000..4dd5076e23 --- /dev/null +++ b/test/transform/resource/after-ecj/BuilderExcludesWarnings.java @@ -0,0 +1,111 @@ +import lombok.Builder; + +public @Builder class BuilderExcludesWarnings { + public static @java.lang.SuppressWarnings("all") @lombok.Generated class BuilderExcludesWarningsBuilder { + private @java.lang.SuppressWarnings("all") @lombok.Generated long x; + private @java.lang.SuppressWarnings("all") @lombok.Generated int y; + private @java.lang.SuppressWarnings("all") @lombok.Generated int z; + + @java.lang.SuppressWarnings("all") @lombok.Generated BuilderExcludesWarningsBuilder() { + super(); + } + + /** + * @return {@code this}. + */ + public @java.lang.SuppressWarnings("all") @lombok.Generated BuilderExcludesWarnings.BuilderExcludesWarningsBuilder x(final long x) { + this.x = x; + return this; + } + + /** + * @return {@code this}. + */ + public @java.lang.SuppressWarnings("all") @lombok.Generated BuilderExcludesWarnings.BuilderExcludesWarningsBuilder y(final int y) { + this.y = y; + return this; + } + + public @java.lang.SuppressWarnings("all") @lombok.Generated BuilderExcludesWarnings build() { + return new BuilderExcludesWarnings(this.x, this.y, this.z); + } + + public @java.lang.Override @java.lang.SuppressWarnings("all") @lombok.Generated java.lang.String toString() { + return (((((("BuilderExcludesWarnings.BuilderExcludesWarningsBuilder(x=" + this.x) + ", y=") + this.y) + ", z=") + this.z) + ")"); + } + } + + long x; + int y; + @Builder.Exclude int z; + + @java.lang.SuppressWarnings("all") @lombok.Generated BuilderExcludesWarnings(final long x, final int y, final int z) { + super(); + this.x = x; + this.y = y; + this.z = z; + } + + public static @java.lang.SuppressWarnings("all") @lombok.Generated BuilderExcludesWarnings.BuilderExcludesWarningsBuilder builder() { + return new BuilderExcludesWarnings.BuilderExcludesWarningsBuilder(); + } +} + +class NoBuilderButHasExcludes { + public static @java.lang.SuppressWarnings("all") @lombok.Generated class NoBuilderButHasExcludesBuilder { + private @java.lang.SuppressWarnings("all") @lombok.Generated long x; + private @java.lang.SuppressWarnings("all") @lombok.Generated int y; + private @java.lang.SuppressWarnings("all") @lombok.Generated int z; + + @java.lang.SuppressWarnings("all") @lombok.Generated NoBuilderButHasExcludesBuilder() { + super(); + } + + /** + * @return {@code this}. + */ + public @java.lang.SuppressWarnings("all") @lombok.Generated NoBuilderButHasExcludes.NoBuilderButHasExcludesBuilder x(final long x) { + this.x = x; + return this; + } + + /** + * @return {@code this}. + */ + public @java.lang.SuppressWarnings("all") @lombok.Generated NoBuilderButHasExcludes.NoBuilderButHasExcludesBuilder y(final int y) { + this.y = y; + return this; + } + + /** + * @return {@code this}. + */ + public @java.lang.SuppressWarnings("all") @lombok.Generated NoBuilderButHasExcludes.NoBuilderButHasExcludesBuilder z(final int z) { + this.z = z; + return this; + } + + public @java.lang.SuppressWarnings("all") @lombok.Generated NoBuilderButHasExcludes build() { + return new NoBuilderButHasExcludes(this.x, this.y, this.z); + } + + public @java.lang.Override @java.lang.SuppressWarnings("all") @lombok.Generated java.lang.String toString() { + return (((((("NoBuilderButHasExcludes.NoBuilderButHasExcludesBuilder(x=" + this.x) + ", y=") + this.y) + ", z=") + this.z) + ")"); + } + } + + long x; + int y; + @Builder.Exclude int z; + + public @Builder NoBuilderButHasExcludes(long x, int y, int z) { + super(); + this.x = x; + this.y = y; + this.z = z; + } + + public static @java.lang.SuppressWarnings("all") @lombok.Generated NoBuilderButHasExcludes.NoBuilderButHasExcludesBuilder builder() { + return new NoBuilderButHasExcludes.NoBuilderButHasExcludesBuilder(); + } +} \ No newline at end of file diff --git a/test/transform/resource/after-ecj/BuilderExcludesWithAllArgsConstructor.java b/test/transform/resource/after-ecj/BuilderExcludesWithAllArgsConstructor.java new file mode 100644 index 0000000000..9a088b2e85 --- /dev/null +++ b/test/transform/resource/after-ecj/BuilderExcludesWithAllArgsConstructor.java @@ -0,0 +1,53 @@ +import lombok.Builder; +import lombok.AllArgsConstructor; + +public @Builder @AllArgsConstructor class BuilderExcludesWithAllArgsConstructor { + public static @java.lang.SuppressWarnings("all") @lombok.Generated class BuilderExcludesWithAllArgsConstructorBuilder { + private @java.lang.SuppressWarnings("all") @lombok.Generated long x; + private @java.lang.SuppressWarnings("all") @lombok.Generated int y; + private @java.lang.SuppressWarnings("all") @lombok.Generated int z; + + @java.lang.SuppressWarnings("all") @lombok.Generated BuilderExcludesWithAllArgsConstructorBuilder() { + super(); + } + + /** + * @return {@code this}. + */ + public @java.lang.SuppressWarnings("all") @lombok.Generated BuilderExcludesWithAllArgsConstructor.BuilderExcludesWithAllArgsConstructorBuilder x(final long x) { + this.x = x; + return this; + } + + /** + * @return {@code this}. + */ + public @java.lang.SuppressWarnings("all") @lombok.Generated BuilderExcludesWithAllArgsConstructor.BuilderExcludesWithAllArgsConstructorBuilder y(final int y) { + this.y = y; + return this; + } + + public @java.lang.SuppressWarnings("all") @lombok.Generated BuilderExcludesWithAllArgsConstructor build() { + return new BuilderExcludesWithAllArgsConstructor(this.x, this.y, this.z); + } + + public @java.lang.Override @java.lang.SuppressWarnings("all") @lombok.Generated java.lang.String toString() { + return (((((("BuilderExcludesWithAllArgsConstructor.BuilderExcludesWithAllArgsConstructorBuilder(x=" + this.x) + ", y=") + this.y) + ", z=") + this.z) + ")"); + } + } + + long x; + int y; + @Builder.Exclude int z; + + public static @java.lang.SuppressWarnings("all") @lombok.Generated BuilderExcludesWithAllArgsConstructor.BuilderExcludesWithAllArgsConstructorBuilder builder() { + return new BuilderExcludesWithAllArgsConstructor.BuilderExcludesWithAllArgsConstructorBuilder(); + } + + public @java.lang.SuppressWarnings("all") @lombok.Generated BuilderExcludesWithAllArgsConstructor(final long x, final int y, final int z) { + super(); + this.x = x; + this.y = y; + this.z = z; + } +} \ No newline at end of file diff --git a/test/transform/resource/after-ecj/BuilderExcludesWithDefault.java b/test/transform/resource/after-ecj/BuilderExcludesWithDefault.java new file mode 100644 index 0000000000..e22f053424 --- /dev/null +++ b/test/transform/resource/after-ecj/BuilderExcludesWithDefault.java @@ -0,0 +1,60 @@ +import lombok.Builder; + +public @Builder class BuilderExcludesWithDefault { + public static @java.lang.SuppressWarnings("all") @lombok.Generated class BuilderExcludesWithDefaultBuilder { + private @java.lang.SuppressWarnings("all") @lombok.Generated long x; + private @java.lang.SuppressWarnings("all") @lombok.Generated int y; + private @java.lang.SuppressWarnings("all") @lombok.Generated int z$value; + private @java.lang.SuppressWarnings("all") @lombok.Generated boolean z$set; + + @java.lang.SuppressWarnings("all") @lombok.Generated BuilderExcludesWithDefaultBuilder() { + super(); + } + + /** + * @return {@code this}. + */ + public @java.lang.SuppressWarnings("all") @lombok.Generated BuilderExcludesWithDefault.BuilderExcludesWithDefaultBuilder x(final long x) { + this.x = x; + return this; + } + + /** + * @return {@code this}. + */ + public @java.lang.SuppressWarnings("all") @lombok.Generated BuilderExcludesWithDefault.BuilderExcludesWithDefaultBuilder y(final int y) { + this.y = y; + return this; + } + + public @java.lang.SuppressWarnings("all") @lombok.Generated BuilderExcludesWithDefault build() { + int z$value = this.z$value; + if ((! this.z$set)) + z$value = BuilderExcludesWithDefault.$default$z(); + return new BuilderExcludesWithDefault(this.x, this.y, z$value); + } + + public @java.lang.Override @java.lang.SuppressWarnings("all") @lombok.Generated java.lang.String toString() { + return (((((("BuilderExcludesWithDefault.BuilderExcludesWithDefaultBuilder(x=" + this.x) + ", y=") + this.y) + ", z$value=") + this.z$value) + ")"); + } + } + + long x; + int y; + @Builder.Exclude @Builder.Default int z; + + private static @java.lang.SuppressWarnings("all") @lombok.Generated int $default$z() { + return 5; + } + + @java.lang.SuppressWarnings("all") @lombok.Generated BuilderExcludesWithDefault(final long x, final int y, final int z) { + super(); + this.x = x; + this.y = y; + this.z = z; + } + + public static @java.lang.SuppressWarnings("all") @lombok.Generated BuilderExcludesWithDefault.BuilderExcludesWithDefaultBuilder builder() { + return new BuilderExcludesWithDefault.BuilderExcludesWithDefaultBuilder(); + } +} \ No newline at end of file diff --git a/test/transform/resource/after-ecj/SuperBuilderWithExcludes.java b/test/transform/resource/after-ecj/SuperBuilderWithExcludes.java new file mode 100644 index 0000000000..bcf981a376 --- /dev/null +++ b/test/transform/resource/after-ecj/SuperBuilderWithExcludes.java @@ -0,0 +1,135 @@ +public class SuperBuilderWithExcludes { + public static @lombok.experimental.SuperBuilder class Parent { + public static abstract @java.lang.SuppressWarnings("all") @lombok.Generated class ParentBuilder, B extends SuperBuilderWithExcludes.Parent.ParentBuilder> { + private @java.lang.SuppressWarnings("all") @lombok.Generated long excludedParentField; + private @java.lang.SuppressWarnings("all") @lombok.Generated N numberField; + private @java.lang.SuppressWarnings("all") @lombok.Generated long randomFieldP; + + public ParentBuilder() { + super(); + } + + /** + * @return {@code this}. + */ + public @java.lang.SuppressWarnings("all") @lombok.Generated B numberField(final N numberField) { + this.numberField = numberField; + return self(); + } + + /** + * @return {@code this}. + */ + public @java.lang.SuppressWarnings("all") @lombok.Generated B randomFieldP(final long randomFieldP) { + this.randomFieldP = randomFieldP; + return self(); + } + + protected abstract @java.lang.SuppressWarnings("all") @lombok.Generated B self(); + + public abstract @java.lang.SuppressWarnings("all") @lombok.Generated C build(); + + public @java.lang.Override @java.lang.SuppressWarnings("all") @lombok.Generated java.lang.String toString() { + return (((((("SuperBuilderWithExcludes.Parent.ParentBuilder(excludedParentField=" + this.excludedParentField) + ", numberField=") + this.numberField) + ", randomFieldP=") + this.randomFieldP) + ")"); + } + } + + private static final @java.lang.SuppressWarnings("all") @lombok.Generated class ParentBuilderImpl extends SuperBuilderWithExcludes.Parent.ParentBuilder, SuperBuilderWithExcludes.Parent.ParentBuilderImpl> { + private ParentBuilderImpl() { + super(); + } + + protected @java.lang.Override @java.lang.SuppressWarnings("all") @lombok.Generated SuperBuilderWithExcludes.Parent.ParentBuilderImpl self() { + return this; + } + + public @java.lang.Override @java.lang.SuppressWarnings("all") @lombok.Generated SuperBuilderWithExcludes.Parent build() { + return new SuperBuilderWithExcludes.Parent(this); + } + } + + private @lombok.Builder.Exclude long excludedParentField; + private N numberField; + private long randomFieldP; + + protected @java.lang.SuppressWarnings("all") @lombok.Generated Parent(final SuperBuilderWithExcludes.Parent.ParentBuilder b) { + super(); + this.excludedParentField = b.excludedParentField; + this.numberField = b.numberField; + this.randomFieldP = b.randomFieldP; + } + + public static @java.lang.SuppressWarnings("all") @lombok.Generated SuperBuilderWithExcludes.Parent.ParentBuilder builder() { + return new SuperBuilderWithExcludes.Parent.ParentBuilderImpl(); + } + } + + public static @lombok.experimental.SuperBuilder class Child extends Parent { + public static abstract @java.lang.SuppressWarnings("all") @lombok.Generated class ChildBuilder> extends Parent.ParentBuilder { + private @java.lang.SuppressWarnings("all") @lombok.Generated double doubleField; + private @java.lang.SuppressWarnings("all") @lombok.Generated long excludedChildField; + private @java.lang.SuppressWarnings("all") @lombok.Generated long randomFieldC; + + public ChildBuilder() { + super(); + } + + /** + * @return {@code this}. + */ + public @java.lang.SuppressWarnings("all") @lombok.Generated B doubleField(final double doubleField) { + this.doubleField = doubleField; + return self(); + } + + /** + * @return {@code this}. + */ + public @java.lang.SuppressWarnings("all") @lombok.Generated B randomFieldC(final long randomFieldC) { + this.randomFieldC = randomFieldC; + return self(); + } + + protected abstract @java.lang.Override @java.lang.SuppressWarnings("all") @lombok.Generated B self(); + + public abstract @java.lang.Override @java.lang.SuppressWarnings("all") @lombok.Generated C build(); + + public @java.lang.Override @java.lang.SuppressWarnings("all") @lombok.Generated java.lang.String toString() { + return (((((((("SuperBuilderWithExcludes.Child.ChildBuilder(super=" + super.toString()) + ", doubleField=") + this.doubleField) + ", excludedChildField=") + this.excludedChildField) + ", randomFieldC=") + this.randomFieldC) + ")"); + } + } + + private static final @java.lang.SuppressWarnings("all") @lombok.Generated class ChildBuilderImpl extends SuperBuilderWithExcludes.Child.ChildBuilder { + private ChildBuilderImpl() { + super(); + } + + protected @java.lang.Override @java.lang.SuppressWarnings("all") @lombok.Generated SuperBuilderWithExcludes.Child.ChildBuilderImpl self() { + return this; + } + + public @java.lang.Override @java.lang.SuppressWarnings("all") @lombok.Generated SuperBuilderWithExcludes.Child build() { + return new SuperBuilderWithExcludes.Child(this); + } + } + + private double doubleField; + private @lombok.Builder.Exclude long excludedChildField; + private long randomFieldC; + + protected @java.lang.SuppressWarnings("all") @lombok.Generated Child(final SuperBuilderWithExcludes.Child.ChildBuilder b) { + super(b); + this.doubleField = b.doubleField; + this.excludedChildField = b.excludedChildField; + this.randomFieldC = b.randomFieldC; + } + + public static @java.lang.SuppressWarnings("all") @lombok.Generated SuperBuilderWithExcludes.Child.ChildBuilder builder() { + return new SuperBuilderWithExcludes.Child.ChildBuilderImpl(); + } + } + + public SuperBuilderWithExcludes() { + super(); + } +} \ No newline at end of file diff --git a/test/transform/resource/before/BuilderExcludes.java b/test/transform/resource/before/BuilderExcludes.java new file mode 100644 index 0000000000..5e86f35cc9 --- /dev/null +++ b/test/transform/resource/before/BuilderExcludes.java @@ -0,0 +1,8 @@ +import lombok.Builder; + +@Builder +public class BuilderExcludes { + long x; + int y; + @Builder.Exclude int z; +} \ No newline at end of file diff --git a/test/transform/resource/before/BuilderExcludesWarnings.java b/test/transform/resource/before/BuilderExcludesWarnings.java new file mode 100644 index 0000000000..ff94538bfa --- /dev/null +++ b/test/transform/resource/before/BuilderExcludesWarnings.java @@ -0,0 +1,22 @@ +import lombok.Builder; + +@Builder +public class BuilderExcludesWarnings { + long x; + int y; + @Builder.Exclude int z; +} + +class NoBuilderButHasExcludes { + long x; + int y; + @Builder.Exclude int z; + + @Builder + public NoBuilderButHasExcludes(long x, int y, int z) { + this.x = x; + this.y = y; + this.z = z; + } +} + diff --git a/test/transform/resource/before/BuilderExcludesWithAllArgsConstructor.java b/test/transform/resource/before/BuilderExcludesWithAllArgsConstructor.java new file mode 100644 index 0000000000..8b16c74802 --- /dev/null +++ b/test/transform/resource/before/BuilderExcludesWithAllArgsConstructor.java @@ -0,0 +1,10 @@ +import lombok.Builder; +import lombok.AllArgsConstructor; + +@Builder +@AllArgsConstructor +public class BuilderExcludesWithAllArgsConstructor { + long x; + int y; + @Builder.Exclude int z; +} \ No newline at end of file diff --git a/test/transform/resource/before/BuilderExcludesWithDefault.java b/test/transform/resource/before/BuilderExcludesWithDefault.java new file mode 100644 index 0000000000..79380ae0e1 --- /dev/null +++ b/test/transform/resource/before/BuilderExcludesWithDefault.java @@ -0,0 +1,8 @@ +import lombok.Builder; + +@Builder +public class BuilderExcludesWithDefault { + long x; + int y; + @Builder.Exclude @Builder.Default int z = 5; +} \ No newline at end of file diff --git a/test/transform/resource/before/SuperBuilderWithExcludes.java b/test/transform/resource/before/SuperBuilderWithExcludes.java new file mode 100644 index 0000000000..796e35b2dd --- /dev/null +++ b/test/transform/resource/before/SuperBuilderWithExcludes.java @@ -0,0 +1,17 @@ +public class SuperBuilderWithExcludes { + @lombok.experimental.SuperBuilder + public static class Parent { + @lombok.Builder.Exclude + private long excludedParentField; + private N numberField; + private long randomFieldP; + } + + @lombok.experimental.SuperBuilder + public static class Child extends Parent { + private double doubleField; + @lombok.Builder.Exclude + private long excludedChildField; + private long randomFieldC; + } +} diff --git a/test/transform/resource/messages-delombok/BuilderExcludesWarnings.java.messages b/test/transform/resource/messages-delombok/BuilderExcludesWarnings.java.messages new file mode 100644 index 0000000000..231bdb5c80 --- /dev/null +++ b/test/transform/resource/messages-delombok/BuilderExcludesWarnings.java.messages @@ -0,0 +1 @@ +13 @Builder.Exclude requires @Builder or @SuperBuilder on the class for it to mean anything. \ No newline at end of file diff --git a/test/transform/resource/messages-ecj/BuilderExcludesWarnings.java.messages b/test/transform/resource/messages-ecj/BuilderExcludesWarnings.java.messages new file mode 100644 index 0000000000..231bdb5c80 --- /dev/null +++ b/test/transform/resource/messages-ecj/BuilderExcludesWarnings.java.messages @@ -0,0 +1 @@ +13 @Builder.Exclude requires @Builder or @SuperBuilder on the class for it to mean anything. \ No newline at end of file