diff options
31 files changed, 383 insertions, 18 deletions
diff --git a/src/core/lombok/ConfigurationKeys.java b/src/core/lombok/ConfigurationKeys.java index 7efe20bd..667e2dc7 100644 --- a/src/core/lombok/ConfigurationKeys.java +++ b/src/core/lombok/ConfigurationKeys.java @@ -126,6 +126,13 @@ public class ConfigurationKeys { public static final ConfigurationKey<FlagUsageType> NO_ARGS_CONSTRUCTOR_FLAG_USAGE = new ConfigurationKey<FlagUsageType>("lombok.noArgsConstructor.flagUsage", "Emit a warning or error if @NoArgsConstructor is used.") {}; /** + * lombok configuration: {@code lombok.noArgsConstructor.extraPrivate} = {@code true} | {@code false}. + * + * If {@code true} (default), @Data and @Value will also generate a private no-args constructor, if there isn't already one, setting all fields to their default values. + */ + public static final ConfigurationKey<Boolean> NO_ARGS_CONSTRUCTOR_EXTRA_PRIVATE = new ConfigurationKey<Boolean>("lombok.noArgsConstructor.extraPrivate", "Generate a private no-ars constructor for @Data and @Value (default: true).") {}; + + /** * lombok configuration: {@code lombok.requiredArgsConstructor.flagUsage} = {@code WARNING} | {@code ERROR}. * * If set, <em>any</em> usage of {@code @RequiredArgsConstructor} results in a warning / error. diff --git a/src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java b/src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java index 1758a220..340e233c 100644 --- a/src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java +++ b/src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java @@ -1198,6 +1198,12 @@ public class EclipseHandlerUtil { return AnnotationValues.of(Accessors.class, field); } + + public static EclipseNode upToTypeNode(EclipseNode node) { + if (node == null) throw new NullPointerException("node"); + while (node != null && !(node.get() instanceof TypeDeclaration)) node = node.up(); + return node; + } /** * Checks if there is a field with the provided name. @@ -1206,10 +1212,7 @@ public class EclipseHandlerUtil { * @param node Any node that represents the Type (TypeDeclaration) to look in, or any child node thereof. */ public static MemberExistsResult fieldExists(String fieldName, EclipseNode node) { - while (node != null && !(node.get() instanceof TypeDeclaration)) { - node = node.up(); - } - + node = upToTypeNode(node); if (node != null && node.get() instanceof TypeDeclaration) { TypeDeclaration typeDecl = (TypeDeclaration)node.get(); if (typeDecl.fields != null) for (FieldDeclaration def : typeDecl.fields) { @@ -1295,10 +1298,7 @@ public class EclipseHandlerUtil { * @param node Any node that represents the Type (TypeDeclaration) to look in, or any child node thereof. */ public static MemberExistsResult constructorExists(EclipseNode node) { - while (node != null && !(node.get() instanceof TypeDeclaration)) { - node = node.up(); - } - + node = upToTypeNode(node); if (node != null && node.get() instanceof TypeDeclaration) { TypeDeclaration typeDecl = (TypeDeclaration)node.get(); if (typeDecl.methods != null) for (AbstractMethodDeclaration def : typeDecl.methods) { diff --git a/src/core/lombok/eclipse/handlers/HandleConstructor.java b/src/core/lombok/eclipse/handlers/HandleConstructor.java index 62e2c18c..295c89ca 100644 --- a/src/core/lombok/eclipse/handlers/HandleConstructor.java +++ b/src/core/lombok/eclipse/handlers/HandleConstructor.java @@ -42,8 +42,10 @@ import lombok.core.AST.Kind; import lombok.core.AnnotationValues; import lombok.eclipse.EclipseAnnotationHandler; import lombok.eclipse.EclipseNode; +import lombok.eclipse.handlers.EclipseHandlerUtil.MemberExistsResult; import org.eclipse.jdt.internal.compiler.ast.ASTNode; +import org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration; import org.eclipse.jdt.internal.compiler.ast.AllocationExpression; import org.eclipse.jdt.internal.compiler.ast.Annotation; import org.eclipse.jdt.internal.compiler.ast.Argument; @@ -204,6 +206,18 @@ public class HandleConstructor { return true; } + public enum SkipIfConstructorExists { + YES, NO, I_AM_BUILDER; + } + + public void generateExtraNoArgsConstructor(EclipseNode typeNode, EclipseNode sourceNode) { + Boolean v = typeNode.getAst().readConfiguration(ConfigurationKeys.NO_ARGS_CONSTRUCTOR_EXTRA_PRIVATE); + if (v != null && !v) return; + + List<EclipseNode> fields = findFinalFields(typeNode); + generate(typeNode, AccessLevel.PRIVATE, fields, true, null, SkipIfConstructorExists.NO, Collections.<Annotation>emptyList(), sourceNode, true); + } + public void generateRequiredArgsConstructor( EclipseNode typeNode, AccessLevel level, String staticName, SkipIfConstructorExists skipIfConstructorExists, List<Annotation> onConstructor, EclipseNode sourceNode) { @@ -218,14 +232,17 @@ public class HandleConstructor { generateConstructor(typeNode, level, findAllFields(typeNode), false, staticName, skipIfConstructorExists, onConstructor, sourceNode); } - public enum SkipIfConstructorExists { - YES, NO, I_AM_BUILDER; - } - public void generateConstructor( EclipseNode typeNode, AccessLevel level, List<EclipseNode> fields, boolean allToDefault, String staticName, SkipIfConstructorExists skipIfConstructorExists, List<Annotation> onConstructor, EclipseNode sourceNode) { + generate(typeNode, level, fields, allToDefault, staticName, skipIfConstructorExists, onConstructor, sourceNode, false); + } + + public void generate( + EclipseNode typeNode, AccessLevel level, List<EclipseNode> fields, boolean allToDefault, String staticName, SkipIfConstructorExists skipIfConstructorExists, + List<Annotation> onConstructor, EclipseNode sourceNode, boolean noArgs) { + ASTNode source = sourceNode.get(); boolean staticConstrRequired = staticName != null && !staticName.equals(""); @@ -257,6 +274,8 @@ public class HandleConstructor { } } + if (noArgs && noArgsConstructorExists(typeNode)) return; + ConstructorDeclaration constr = createConstructor( staticConstrRequired ? AccessLevel.PRIVATE : level, typeNode, fields, allToDefault, sourceNode, onConstructor); @@ -267,6 +286,22 @@ public class HandleConstructor { } } + private static boolean noArgsConstructorExists(EclipseNode node) { + node = EclipseHandlerUtil.upToTypeNode(node); + + if (node != null && node.get() instanceof TypeDeclaration) { + TypeDeclaration typeDecl = (TypeDeclaration)node.get(); + if (typeDecl.methods != null) for (AbstractMethodDeclaration def : typeDecl.methods) { + if (def instanceof ConstructorDeclaration) { + Argument[] arguments = ((ConstructorDeclaration) def).arguments; + if (arguments == null || arguments.length == 0) return true; + } + } + } + return false; + } + + private static final char[][] JAVA_BEANS_CONSTRUCTORPROPERTIES = new char[][] { "java".toCharArray(), "beans".toCharArray(), "ConstructorProperties".toCharArray() }; public static Annotation[] createConstructorProperties(ASTNode source, Collection<EclipseNode> fields) { if (fields.isEmpty()) return null; diff --git a/src/core/lombok/eclipse/handlers/HandleData.java b/src/core/lombok/eclipse/handlers/HandleData.java index 5d92cd36..4011890d 100644 --- a/src/core/lombok/eclipse/handlers/HandleData.java +++ b/src/core/lombok/eclipse/handlers/HandleData.java @@ -79,5 +79,6 @@ public class HandleData extends EclipseAnnotationHandler<Data> { handleConstructor.generateRequiredArgsConstructor( typeNode, AccessLevel.PUBLIC, ann.staticConstructor(), SkipIfConstructorExists.YES, Collections.<Annotation>emptyList(), annotationNode); + handleConstructor.generateExtraNoArgsConstructor(typeNode, annotationNode); } } diff --git a/src/core/lombok/eclipse/handlers/HandleValue.java b/src/core/lombok/eclipse/handlers/HandleValue.java index bd93a547..2e0338a8 100644 --- a/src/core/lombok/eclipse/handlers/HandleValue.java +++ b/src/core/lombok/eclipse/handlers/HandleValue.java @@ -91,5 +91,6 @@ public class HandleValue extends EclipseAnnotationHandler<Value> { handleToString.generateToStringForType(typeNode, annotationNode); handleConstructor.generateAllArgsConstructor(typeNode, AccessLevel.PUBLIC, ann.staticConstructor(), SkipIfConstructorExists.YES, Collections.<Annotation>emptyList(), annotationNode); + handleConstructor.generateExtraNoArgsConstructor(typeNode, annotationNode); } } diff --git a/src/core/lombok/javac/handlers/HandleConstructor.java b/src/core/lombok/javac/handlers/HandleConstructor.java index dca25ee7..2314a5e4 100644 --- a/src/core/lombok/javac/handlers/HandleConstructor.java +++ b/src/core/lombok/javac/handlers/HandleConstructor.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2010-2014 The Project Lombok Authors. + * Copyright (C) 2010-2018 The Project Lombok Authors. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -38,6 +38,7 @@ import lombok.javac.Javac; import lombok.javac.JavacAnnotationHandler; import lombok.javac.JavacNode; import lombok.javac.JavacTreeMaker; +import lombok.javac.handlers.JavacHandlerUtil.MemberExistsResult; import org.mangosdk.spi.ProviderFor; @@ -191,19 +192,31 @@ public class HandleConstructor { return true; } - public void generateRequiredArgsConstructor(JavacNode typeNode, AccessLevel level, String staticName, SkipIfConstructorExists skipIfConstructorExists, JavacNode source) { - generateConstructor(typeNode, level, List.<JCAnnotation>nil(), findRequiredFields(typeNode), false, staticName, skipIfConstructorExists, source); - } - public enum SkipIfConstructorExists { YES, NO, I_AM_BUILDER; } + public void generateExtraNoArgsConstructor(JavacNode typeNode, JavacNode source) { + Boolean v = typeNode.getAst().readConfiguration(ConfigurationKeys.NO_ARGS_CONSTRUCTOR_EXTRA_PRIVATE); + if (v != null && !v) return; + + List<JavacNode> fields = findFinalFields(typeNode); + generate(typeNode, AccessLevel.PRIVATE, List.<JCAnnotation>nil(), fields, true, null, SkipIfConstructorExists.NO, source, true); + } + + public void generateRequiredArgsConstructor(JavacNode typeNode, AccessLevel level, String staticName, SkipIfConstructorExists skipIfConstructorExists, JavacNode source) { + generateConstructor(typeNode, level, List.<JCAnnotation>nil(), findRequiredFields(typeNode), false, staticName, skipIfConstructorExists, source); + } + public void generateAllArgsConstructor(JavacNode typeNode, AccessLevel level, String staticName, SkipIfConstructorExists skipIfConstructorExists, JavacNode source) { generateConstructor(typeNode, level, List.<JCAnnotation>nil(), findAllFields(typeNode), false, staticName, skipIfConstructorExists, source); } public void generateConstructor(JavacNode typeNode, AccessLevel level, List<JCAnnotation> onConstructor, List<JavacNode> fields, boolean allToDefault, String staticName, SkipIfConstructorExists skipIfConstructorExists, JavacNode source) { + generate(typeNode, level, onConstructor, fields, allToDefault, staticName, skipIfConstructorExists, source, false); + } + + private void generate(JavacNode typeNode, AccessLevel level, List<JCAnnotation> onConstructor, List<JavacNode> fields, boolean allToDefault, String staticName, SkipIfConstructorExists skipIfConstructorExists, JavacNode source, boolean noArgs) { boolean staticConstrRequired = staticName != null && !staticName.equals(""); if (skipIfConstructorExists != SkipIfConstructorExists.NO && constructorExists(typeNode) != MemberExistsResult.NOT_EXISTS) return; @@ -232,6 +245,8 @@ public class HandleConstructor { } } + if (noArgs && noArgsConstructorExists(typeNode)) return; + JCMethodDecl constr = createConstructor(staticConstrRequired ? AccessLevel.PRIVATE : level, onConstructor, typeNode, fields, allToDefault, source); ListBuffer<Type> argTypes = new ListBuffer<Type>(); for (JavacNode fieldNode : fields) { @@ -252,6 +267,20 @@ public class HandleConstructor { } } + private static boolean noArgsConstructorExists(JavacNode node) { + node = upToTypeNode(node); + + if (node != null && node.get() instanceof JCClassDecl) { + for (JCTree def : ((JCClassDecl) node.get()).defs) { + if (def instanceof JCMethodDecl) { + JCMethodDecl md = (JCMethodDecl) def; + if (md.name.contentEquals("<init>") && md.params.size() == 0) return true; + } + } + } + return false; + } + public static void addConstructorProperties(JCModifiers mods, JavacNode node, List<JavacNode> fields) { if (fields.isEmpty()) return; JavacTreeMaker maker = node.getTreeMaker(); diff --git a/src/core/lombok/javac/handlers/HandleData.java b/src/core/lombok/javac/handlers/HandleData.java index 94b6c3e1..15c9c9e7 100644 --- a/src/core/lombok/javac/handlers/HandleData.java +++ b/src/core/lombok/javac/handlers/HandleData.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009-2014 The Project Lombok Authors. + * Copyright (C) 2009-2018 The Project Lombok Authors. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -61,7 +61,9 @@ public class HandleData extends JavacAnnotationHandler<Data> { String staticConstructorName = annotation.getInstance().staticConstructor(); + // TODO move this to the end OR move it to the top in eclipse. handleConstructor.generateRequiredArgsConstructor(typeNode, AccessLevel.PUBLIC, staticConstructorName, SkipIfConstructorExists.YES, annotationNode); + handleConstructor.generateExtraNoArgsConstructor(typeNode, annotationNode); handleGetter.generateGetterForType(typeNode, annotationNode, AccessLevel.PUBLIC, true, List.<JCAnnotation>nil()); handleSetter.generateSetterForType(typeNode, annotationNode, AccessLevel.PUBLIC, true, List.<JCAnnotation>nil(), List.<JCAnnotation>nil()); handleEqualsAndHashCode.generateEqualsAndHashCodeForType(typeNode, annotationNode); diff --git a/src/core/lombok/javac/handlers/HandleValue.java b/src/core/lombok/javac/handlers/HandleValue.java index f85e058e..abc5a5ca 100644 --- a/src/core/lombok/javac/handlers/HandleValue.java +++ b/src/core/lombok/javac/handlers/HandleValue.java @@ -77,6 +77,7 @@ public class HandleValue extends JavacAnnotationHandler<Value> { } handleFieldDefaults.generateFieldDefaultsForType(typeNode, annotationNode, AccessLevel.PRIVATE, true, true); handleConstructor.generateAllArgsConstructor(typeNode, AccessLevel.PUBLIC, staticConstructorName, SkipIfConstructorExists.YES, annotationNode); + handleConstructor.generateExtraNoArgsConstructor(typeNode, annotationNode); handleGetter.generateGetterForType(typeNode, annotationNode, AccessLevel.PUBLIC, true, List.<JCAnnotation>nil()); handleEqualsAndHashCode.generateEqualsAndHashCodeForType(typeNode, annotationNode); handleToString.generateToStringForType(typeNode, annotationNode); diff --git a/test/transform/resource/after-delombok/BuilderDefaults.java b/test/transform/resource/after-delombok/BuilderDefaults.java index b916b725..e92197ad 100644 --- a/test/transform/resource/after-delombok/BuilderDefaults.java +++ b/test/transform/resource/after-delombok/BuilderDefaults.java @@ -67,6 +67,12 @@ public final class BuilderDefaults { return new BuilderDefaultsBuilder(); } @java.lang.SuppressWarnings("all") + private BuilderDefaults() { + this.x = 0; + this.name = null; + this.z = 0L; + } + @java.lang.SuppressWarnings("all") public int getX() { return this.x; } diff --git a/test/transform/resource/after-delombok/BuilderWithRecursiveGenerics.java b/test/transform/resource/after-delombok/BuilderWithRecursiveGenerics.java index 7fb300e4..91674ea9 100644 --- a/test/transform/resource/after-delombok/BuilderWithRecursiveGenerics.java +++ b/test/transform/resource/after-delombok/BuilderWithRecursiveGenerics.java @@ -44,6 +44,11 @@ public class BuilderWithRecursiveGenerics { return new TestBuilder<Foo, Bar, Quz>(); } @java.lang.SuppressWarnings("all") + private Test() { + this.foo = null; + this.bar = null; + } + @java.lang.SuppressWarnings("all") public Foo getFoo() { return this.foo; } diff --git a/test/transform/resource/after-delombok/DataConfiguration.java b/test/transform/resource/after-delombok/DataConfiguration.java index b71e1c81..6771a6a7 100644 --- a/test/transform/resource/after-delombok/DataConfiguration.java +++ b/test/transform/resource/after-delombok/DataConfiguration.java @@ -5,6 +5,10 @@ class DataConfiguration { this.x = x; } @java.lang.SuppressWarnings("all") + private DataConfiguration() { + this.x = 0; + } + @java.lang.SuppressWarnings("all") public int getX() { return this.x; } diff --git a/test/transform/resource/after-delombok/DataIgnore.java b/test/transform/resource/after-delombok/DataIgnore.java index 309d8150..02a0107f 100644 --- a/test/transform/resource/after-delombok/DataIgnore.java +++ b/test/transform/resource/after-delombok/DataIgnore.java @@ -6,6 +6,10 @@ class DataIgnore { this.x = x; } @java.lang.SuppressWarnings("all") + private DataIgnore() { + this.x = 0; + } + @java.lang.SuppressWarnings("all") public int getX() { return this.x; } diff --git a/test/transform/resource/after-delombok/DataOnLocalClass.java b/test/transform/resource/after-delombok/DataOnLocalClass.java index 84817897..c178f1f3 100644 --- a/test/transform/resource/after-delombok/DataOnLocalClass.java +++ b/test/transform/resource/after-delombok/DataOnLocalClass.java @@ -8,6 +8,10 @@ class DataOnLocalClass1 { this.x = x; } @java.lang.SuppressWarnings("all") + private Local() { + this.x = 0; + } + @java.lang.SuppressWarnings("all") public int getX() { return this.x; } @@ -68,6 +72,9 @@ class DataOnLocalClass2 { } this.name = name; } + @java.lang.SuppressWarnings("all") + private InnerLocal() { + } @lombok.NonNull @java.lang.SuppressWarnings("all") public String getName() { @@ -116,6 +123,10 @@ class DataOnLocalClass2 { this.x = x; } @java.lang.SuppressWarnings("all") + private Local() { + this.x = 0; + } + @java.lang.SuppressWarnings("all") public int getX() { return this.x; } diff --git a/test/transform/resource/after-delombok/DataPlain.java b/test/transform/resource/after-delombok/DataPlain.java index d54baef1..7b3d8f11 100644 --- a/test/transform/resource/after-delombok/DataPlain.java +++ b/test/transform/resource/after-delombok/DataPlain.java @@ -6,6 +6,10 @@ class Data1 { this.x = x; } @java.lang.SuppressWarnings("all") + private Data1() { + this.x = 0; + } + @java.lang.SuppressWarnings("all") public int getX() { return this.x; } @@ -58,6 +62,10 @@ class Data2 { this.x = x; } @java.lang.SuppressWarnings("all") + private Data2() { + this.x = 0; + } + @java.lang.SuppressWarnings("all") public int getX() { return this.x; } @@ -110,6 +118,10 @@ final class Data3 { this.x = x; } @java.lang.SuppressWarnings("all") + private Data3() { + this.x = 0; + } + @java.lang.SuppressWarnings("all") public int getX() { return this.x; } diff --git a/test/transform/resource/after-delombok/DataWithGetter.java b/test/transform/resource/after-delombok/DataWithGetter.java index b4107bb3..6d3036f4 100644 --- a/test/transform/resource/after-delombok/DataWithGetter.java +++ b/test/transform/resource/after-delombok/DataWithGetter.java @@ -7,6 +7,10 @@ class DataWithGetter { this.z = z; } @java.lang.SuppressWarnings("all") + private DataWithGetter() { + this.z = null; + } + @java.lang.SuppressWarnings("all") public void setX(final int x) { this.x = x; } diff --git a/test/transform/resource/after-delombok/DataWithGetterNone.java b/test/transform/resource/after-delombok/DataWithGetterNone.java index 4467e407..692ee9a0 100644 --- a/test/transform/resource/after-delombok/DataWithGetterNone.java +++ b/test/transform/resource/after-delombok/DataWithGetterNone.java @@ -7,6 +7,10 @@ class DataWithGetterNone { this.z = z; } @java.lang.SuppressWarnings("all") + private DataWithGetterNone() { + this.z = null; + } + @java.lang.SuppressWarnings("all") public void setX(final int x) { this.x = x; } diff --git a/test/transform/resource/after-delombok/InnerClass.java b/test/transform/resource/after-delombok/InnerClass.java index 2e49b9ad..8040d9ff 100644 --- a/test/transform/resource/after-delombok/InnerClass.java +++ b/test/transform/resource/after-delombok/InnerClass.java @@ -20,6 +20,10 @@ class C { this.a = a; } @java.lang.SuppressWarnings("all") + private D() { + this.a = null; + } + @java.lang.SuppressWarnings("all") public A getA() { return this.a; } diff --git a/test/transform/resource/after-delombok/NoPrivateNoArgsConstructor.java b/test/transform/resource/after-delombok/NoPrivateNoArgsConstructor.java new file mode 100644 index 00000000..b354a85d --- /dev/null +++ b/test/transform/resource/after-delombok/NoPrivateNoArgsConstructor.java @@ -0,0 +1,73 @@ +public class NoPrivateNoArgsConstructor { + public static class NoPrivateNoArgsConstructorData { + private final int i; + @java.lang.SuppressWarnings("all") + public NoPrivateNoArgsConstructorData(final int i) { + this.i = i; + } + @java.lang.SuppressWarnings("all") + public int getI() { + return this.i; + } + @java.lang.Override + @java.lang.SuppressWarnings("all") + public boolean equals(final java.lang.Object o) { + if (o == this) return true; + if (!(o instanceof NoPrivateNoArgsConstructor.NoPrivateNoArgsConstructorData)) return false; + final NoPrivateNoArgsConstructor.NoPrivateNoArgsConstructorData other = (NoPrivateNoArgsConstructor.NoPrivateNoArgsConstructorData) o; + if (!other.canEqual((java.lang.Object) this)) return false; + if (this.getI() != other.getI()) return false; + return true; + } + @java.lang.SuppressWarnings("all") + protected boolean canEqual(final java.lang.Object other) { + return other instanceof NoPrivateNoArgsConstructor.NoPrivateNoArgsConstructorData; + } + @java.lang.Override + @java.lang.SuppressWarnings("all") + public int hashCode() { + final int PRIME = 59; + int result = 1; + result = result * PRIME + this.getI(); + return result; + } + @java.lang.Override + @java.lang.SuppressWarnings("all") + public java.lang.String toString() { + return "NoPrivateNoArgsConstructor.NoPrivateNoArgsConstructorData(i=" + this.getI() + ")"; + } + } + public static final class NoPrivateNoArgsConstructorValue { + private final int i; + @java.lang.SuppressWarnings("all") + public NoPrivateNoArgsConstructorValue(final int i) { + this.i = i; + } + @java.lang.SuppressWarnings("all") + public int getI() { + return this.i; + } + @java.lang.Override + @java.lang.SuppressWarnings("all") + public boolean equals(final java.lang.Object o) { + if (o == this) return true; + if (!(o instanceof NoPrivateNoArgsConstructor.NoPrivateNoArgsConstructorValue)) return false; + final NoPrivateNoArgsConstructor.NoPrivateNoArgsConstructorValue other = (NoPrivateNoArgsConstructor.NoPrivateNoArgsConstructorValue) o; + if (this.getI() != other.getI()) return false; + return true; + } + @java.lang.Override + @java.lang.SuppressWarnings("all") + public int hashCode() { + final int PRIME = 59; + int result = 1; + result = result * PRIME + this.getI(); + return result; + } + @java.lang.Override + @java.lang.SuppressWarnings("all") + public java.lang.String toString() { + return "NoPrivateNoArgsConstructor.NoPrivateNoArgsConstructorValue(i=" + this.getI() + ")"; + } + } +}
\ No newline at end of file diff --git a/test/transform/resource/after-delombok/ValuePlain.java b/test/transform/resource/after-delombok/ValuePlain.java index cf2c1142..0cbd8621 100644 --- a/test/transform/resource/after-delombok/ValuePlain.java +++ b/test/transform/resource/after-delombok/ValuePlain.java @@ -7,6 +7,11 @@ final class Value1 { this.name = name; } @java.lang.SuppressWarnings("all") + private Value1() { + this.x = 0; + this.name = null; + } + @java.lang.SuppressWarnings("all") public int getX() { return this.x; } @@ -51,6 +56,11 @@ class Value2 { this.name = name; } @java.lang.SuppressWarnings("all") + private Value2() { + this.x = 0; + this.name = null; + } + @java.lang.SuppressWarnings("all") public int getX() { return this.x; } @@ -100,6 +110,10 @@ final class Value3 { this.y = y; } @java.lang.SuppressWarnings("all") + private Value3() { + this.y = 0; + } + @java.lang.SuppressWarnings("all") public int getX() { return this.x; } diff --git a/test/transform/resource/after-ecj/BuilderDefaults.java b/test/transform/resource/after-ecj/BuilderDefaults.java index 1a0f1168..1b9cd0ac 100644 --- a/test/transform/resource/after-ecj/BuilderDefaults.java +++ b/test/transform/resource/after-ecj/BuilderDefaults.java @@ -87,4 +87,10 @@ public final @Value @Builder class BuilderDefaults { public @java.lang.Override @java.lang.SuppressWarnings("all") java.lang.String toString() { return (((((("BuilderDefaults(x=" + this.getX()) + ", name=") + this.getName()) + ", z=") + this.getZ()) + ")"); } + private @java.lang.SuppressWarnings("all") BuilderDefaults() { + super(); + this.x = 0; + this.name = null; + this.z = 0L; + } } diff --git a/test/transform/resource/after-ecj/BuilderWithRecursiveGenerics.java b/test/transform/resource/after-ecj/BuilderWithRecursiveGenerics.java index 8246ca2c..1db5a914 100644 --- a/test/transform/resource/after-ecj/BuilderWithRecursiveGenerics.java +++ b/test/transform/resource/after-ecj/BuilderWithRecursiveGenerics.java @@ -70,6 +70,11 @@ public class BuilderWithRecursiveGenerics { public @java.lang.Override @java.lang.SuppressWarnings("all") java.lang.String toString() { return (((("BuilderWithRecursiveGenerics.Test(foo=" + this.getFoo()) + ", bar=") + this.getBar()) + ")"); } + private @java.lang.SuppressWarnings("all") Test() { + super(); + this.foo = null; + this.bar = null; + } } public BuilderWithRecursiveGenerics() { super(); diff --git a/test/transform/resource/after-ecj/DataConfiguration.java b/test/transform/resource/after-ecj/DataConfiguration.java index 1e7adfbf..25f7620e 100644 --- a/test/transform/resource/after-ecj/DataConfiguration.java +++ b/test/transform/resource/after-ecj/DataConfiguration.java @@ -31,4 +31,8 @@ super(); this.x = x; } + private @java.lang.SuppressWarnings("all") DataConfiguration() { + super(); + this.x = 0; + } } diff --git a/test/transform/resource/after-ecj/DataIgnore.java b/test/transform/resource/after-ecj/DataIgnore.java index d3ac8aa3..d0fd1b1b 100644 --- a/test/transform/resource/after-ecj/DataIgnore.java +++ b/test/transform/resource/after-ecj/DataIgnore.java @@ -32,4 +32,8 @@ super(); this.x = x; } + private @java.lang.SuppressWarnings("all") DataIgnore() { + super(); + this.x = 0; + } } diff --git a/test/transform/resource/after-ecj/DataOnLocalClass.java b/test/transform/resource/after-ecj/DataOnLocalClass.java index 341df49b..03f0caaf 100644 --- a/test/transform/resource/after-ecj/DataOnLocalClass.java +++ b/test/transform/resource/after-ecj/DataOnLocalClass.java @@ -50,6 +50,10 @@ class DataOnLocalClass1 { super(); this.x = x; } + private @java.lang.SuppressWarnings("all") Local() { + super(); + this.x = 0; + } } } } @@ -103,6 +107,9 @@ class DataOnLocalClass2 { } this.name = name; } + private @java.lang.SuppressWarnings("all") InnerLocal() { + super(); + } } final int x; public @java.lang.SuppressWarnings("all") int getX() { @@ -136,6 +143,10 @@ class DataOnLocalClass2 { super(); this.x = x; } + private @java.lang.SuppressWarnings("all") Local() { + super(); + this.x = 0; + } } } DataOnLocalClass2() { diff --git a/test/transform/resource/after-ecj/DataPlain.java b/test/transform/resource/after-ecj/DataPlain.java index eaeef509..be46cd24 100644 --- a/test/transform/resource/after-ecj/DataPlain.java +++ b/test/transform/resource/after-ecj/DataPlain.java @@ -45,6 +45,10 @@ import lombok.Data; super(); this.x = x; } + private @java.lang.SuppressWarnings("all") Data1() { + super(); + this.x = 0; + } } @Data class Data2 { final int x; @@ -92,6 +96,10 @@ import lombok.Data; super(); this.x = x; } + private @java.lang.SuppressWarnings("all") Data2() { + super(); + this.x = 0; + } } final @Data class Data3 { final int x; @@ -134,6 +142,10 @@ final @Data class Data3 { super(); this.x = x; } + private @java.lang.SuppressWarnings("all") Data3() { + super(); + this.x = 0; + } } final @Data @lombok.EqualsAndHashCode(callSuper = true) class Data4 extends java.util.Timer { int x; diff --git a/test/transform/resource/after-ecj/DataWithGetter.java b/test/transform/resource/after-ecj/DataWithGetter.java index fa291eca..0fec7684 100644 --- a/test/transform/resource/after-ecj/DataWithGetter.java +++ b/test/transform/resource/after-ecj/DataWithGetter.java @@ -45,6 +45,10 @@ super(); this.z = z; } + private @java.lang.SuppressWarnings("all") DataWithGetter() { + super(); + this.z = null; + } public @java.lang.SuppressWarnings("all") int getX() { return this.x; } diff --git a/test/transform/resource/after-ecj/DataWithGetterNone.java b/test/transform/resource/after-ecj/DataWithGetterNone.java index 4545dc46..fb4a7c2e 100644 --- a/test/transform/resource/after-ecj/DataWithGetterNone.java +++ b/test/transform/resource/after-ecj/DataWithGetterNone.java @@ -45,4 +45,8 @@ super(); this.z = z; } + private @java.lang.SuppressWarnings("all") DataWithGetterNone() { + super(); + this.z = null; + } } diff --git a/test/transform/resource/after-ecj/InnerClass.java b/test/transform/resource/after-ecj/InnerClass.java index 32004225..05c6dc94 100644 --- a/test/transform/resource/after-ecj/InnerClass.java +++ b/test/transform/resource/after-ecj/InnerClass.java @@ -49,6 +49,10 @@ class C { super(); this.a = a; } + private @java.lang.SuppressWarnings("all") D() { + super(); + this.a = null; + } } C() { super(); diff --git a/test/transform/resource/after-ecj/NoPrivateNoArgsConstructor.java b/test/transform/resource/after-ecj/NoPrivateNoArgsConstructor.java new file mode 100644 index 00000000..a2bfe3bd --- /dev/null +++ b/test/transform/resource/after-ecj/NoPrivateNoArgsConstructor.java @@ -0,0 +1,68 @@ +public class NoPrivateNoArgsConstructor { + public static @lombok.Data class NoPrivateNoArgsConstructorData { + private final int i; + public @java.lang.SuppressWarnings("all") int getI() { + return this.i; + } + public @java.lang.Override @java.lang.SuppressWarnings("all") boolean equals(final java.lang.Object o) { + if ((o == this)) + return true; + if ((! (o instanceof NoPrivateNoArgsConstructor.NoPrivateNoArgsConstructorData))) + return false; + final NoPrivateNoArgsConstructor.NoPrivateNoArgsConstructorData other = (NoPrivateNoArgsConstructor.NoPrivateNoArgsConstructorData) o; + if ((! other.canEqual((java.lang.Object) this))) + return false; + if ((this.getI() != other.getI())) + return false; + return true; + } + protected @java.lang.SuppressWarnings("all") boolean canEqual(final java.lang.Object other) { + return (other instanceof NoPrivateNoArgsConstructor.NoPrivateNoArgsConstructorData); + } + public @java.lang.Override @java.lang.SuppressWarnings("all") int hashCode() { + final int PRIME = 59; + int result = 1; + result = ((result * PRIME) + this.getI()); + return result; + } + public @java.lang.Override @java.lang.SuppressWarnings("all") java.lang.String toString() { + return (("NoPrivateNoArgsConstructor.NoPrivateNoArgsConstructorData(i=" + this.getI()) + ")"); + } + public @java.lang.SuppressWarnings("all") NoPrivateNoArgsConstructorData(final int i) { + super(); + this.i = i; + } + } + public static final @lombok.Value class NoPrivateNoArgsConstructorValue { + private final int i; + public @java.lang.SuppressWarnings("all") int getI() { + return this.i; + } + public @java.lang.Override @java.lang.SuppressWarnings("all") boolean equals(final java.lang.Object o) { + if ((o == this)) + return true; + if ((! (o instanceof NoPrivateNoArgsConstructor.NoPrivateNoArgsConstructorValue))) + return false; + final NoPrivateNoArgsConstructor.NoPrivateNoArgsConstructorValue other = (NoPrivateNoArgsConstructor.NoPrivateNoArgsConstructorValue) o; + if ((this.getI() != other.getI())) + return false; + return true; + } + public @java.lang.Override @java.lang.SuppressWarnings("all") int hashCode() { + final int PRIME = 59; + int result = 1; + result = ((result * PRIME) + this.getI()); + return result; + } + public @java.lang.Override @java.lang.SuppressWarnings("all") java.lang.String toString() { + return (("NoPrivateNoArgsConstructor.NoPrivateNoArgsConstructorValue(i=" + this.getI()) + ")"); + } + public @java.lang.SuppressWarnings("all") NoPrivateNoArgsConstructorValue(final int i) { + super(); + this.i = i; + } + } + public NoPrivateNoArgsConstructor() { + super(); + } +}
\ No newline at end of file diff --git a/test/transform/resource/after-ecj/ValuePlain.java b/test/transform/resource/after-ecj/ValuePlain.java index 442a63ac..0ff7369e 100644 --- a/test/transform/resource/after-ecj/ValuePlain.java +++ b/test/transform/resource/after-ecj/ValuePlain.java @@ -38,6 +38,11 @@ final @lombok.Value class Value1 { this.x = x; this.name = name; } + private @java.lang.SuppressWarnings("all") Value1() { + super(); + this.x = 0; + this.name = null; + } } @Value @lombok.experimental.NonFinal class Value2 { public final int x; @@ -83,6 +88,11 @@ final @lombok.Value class Value1 { this.x = x; this.name = name; } + private @java.lang.SuppressWarnings("all") Value2() { + super(); + this.x = 0; + this.name = null; + } } final @Value class Value3 { private @lombok.experimental.NonFinal int x; @@ -120,4 +130,8 @@ final @Value class Value3 { this.x = x; this.y = y; } + private @java.lang.SuppressWarnings("all") Value3() { + super(); + this.y = 0; + } } diff --git a/test/transform/resource/before/NoPrivateNoArgsConstructor.java b/test/transform/resource/before/NoPrivateNoArgsConstructor.java new file mode 100644 index 00000000..b7c2a616 --- /dev/null +++ b/test/transform/resource/before/NoPrivateNoArgsConstructor.java @@ -0,0 +1,12 @@ +//CONF: lombok.noArgsConstructor.extraPrivate = false +public class NoPrivateNoArgsConstructor { + @lombok.Data + public static class NoPrivateNoArgsConstructorData { + private final int i; + } + + @lombok.Value + public static class NoPrivateNoArgsConstructorValue { + int i; + } +} |