Generate default no-args constructor

This commit is contained in:
Roel Spilker committed 2018-05-28 21:54:12 +02:00
1 parent 4fb9c6f7f8
commit 6045c1b8f5
31 files changed
+383 -18

No files matched your search

+7
View File
@@ -125,6 +125,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}.
*
@@ -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) {
@@ -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;
@@ -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);
}
}
@@ -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);
}
}
@@ -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();
@@ -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);
@@ -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);
@@ -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;
}
@@ -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;
}
@@ -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;
}
@@ -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;
}
@@ -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;
}
@@ -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;
}
@@ -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;
}
@@ -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;
}
@@ -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;
}
@@ -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() + ")";
}
}
}
@@ -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;
}
@@ -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;
}
}
@@ -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();
@@ -31,4 +31,8 @@
super();
this.x = x;
}
private @java.lang.SuppressWarnings("all") DataConfiguration() {
super();
this.x = 0;
}
}
@@ -32,4 +32,8 @@
super();
this.x = x;
}
private @java.lang.SuppressWarnings("all") DataIgnore() {
super();
this.x = 0;
}
}
@@ -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() {
@@ -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;
@@ -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;
}
@@ -45,4 +45,8 @@
super();
this.z = z;
}
private @java.lang.SuppressWarnings("all") DataWithGetterNone() {
super();
this.z = null;
}
}
@@ -49,6 +49,10 @@ class C {
super();
this.a = a;
}
private @java.lang.SuppressWarnings("all") D() {
super();
this.a = null;
}
}
C() {
super();
@@ -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();
}
}
@@ -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;
}
}
@@ -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;
}
}