aboutsummaryrefslogtreecommitdiff
path: root/test/transform
diff options
context:
space:
mode:
authorRoel Spilker <r.spilker@gmail.com>2018-06-04 22:32:44 +0200
committerRoel Spilker <r.spilker@gmail.com>2018-06-04 22:40:24 +0200
commitfb5a5530148614e8d0c423077d9043e2d58f453b (patch)
treed008d4eb56aefc817f4c96c3fd4ab08c5a463e6f /test/transform
parent370705e7e154309a6678b83322e243b7a32e2575 (diff)
downloadlombok-fb5a5530148614e8d0c423077d9043e2d58f453b.tar.gz
lombok-fb5a5530148614e8d0c423077d9043e2d58f453b.tar.bz2
lombok-fb5a5530148614e8d0c423077d9043e2d58f453b.zip
Do not generate a private no-args constructor if:
- The class has a parent class - There is an explicit XxxArgsConstructor annotation that would generate a no-args constructor Fixes #1703, fixes #1704, fixes #1712
Diffstat (limited to 'test/transform')
-rw-r--r--test/transform/resource/after-delombok/PrivateNoArgsConstructor.java236
-rw-r--r--test/transform/resource/after-ecj/PrivateNoArgsConstructor.java219
-rw-r--r--test/transform/resource/before/PrivateNoArgsConstructor.java40
3 files changed, 495 insertions, 0 deletions
diff --git a/test/transform/resource/after-delombok/PrivateNoArgsConstructor.java b/test/transform/resource/after-delombok/PrivateNoArgsConstructor.java
new file mode 100644
index 00000000..18e6f211
--- /dev/null
+++ b/test/transform/resource/after-delombok/PrivateNoArgsConstructor.java
@@ -0,0 +1,236 @@
+public class PrivateNoArgsConstructor {
+ private static class Base {
+ }
+ public static class PrivateNoArgsConstructorNotOnExtends extends Base {
+ private final int a;
+ @java.lang.SuppressWarnings("all")
+ public PrivateNoArgsConstructorNotOnExtends(final int a) {
+ this.a = a;
+ }
+ @java.lang.SuppressWarnings("all")
+ public int getA() {
+ return this.a;
+ }
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ public boolean equals(final java.lang.Object o) {
+ if (o == this) return true;
+ if (!(o instanceof PrivateNoArgsConstructor.PrivateNoArgsConstructorNotOnExtends)) return false;
+ final PrivateNoArgsConstructor.PrivateNoArgsConstructorNotOnExtends other = (PrivateNoArgsConstructor.PrivateNoArgsConstructorNotOnExtends) o;
+ if (!other.canEqual((java.lang.Object) this)) return false;
+ if (!super.equals(o)) return false;
+ if (this.getA() != other.getA()) return false;
+ return true;
+ }
+ @java.lang.SuppressWarnings("all")
+ protected boolean canEqual(final java.lang.Object other) {
+ return other instanceof PrivateNoArgsConstructor.PrivateNoArgsConstructorNotOnExtends;
+ }
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ public int hashCode() {
+ final int PRIME = 59;
+ int result = super.hashCode();
+ result = result * PRIME + this.getA();
+ return result;
+ }
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ public java.lang.String toString() {
+ return "PrivateNoArgsConstructor.PrivateNoArgsConstructorNotOnExtends(a=" + this.getA() + ")";
+ }
+ }
+ public static class PrivateNoArgsConstructorOnExtendsObject extends Object {
+ private final int b;
+ @java.lang.SuppressWarnings("all")
+ public PrivateNoArgsConstructorOnExtendsObject(final int b) {
+ this.b = b;
+ }
+ @java.lang.SuppressWarnings("all")
+ private PrivateNoArgsConstructorOnExtendsObject() {
+ this.b = 0;
+ }
+ @java.lang.SuppressWarnings("all")
+ public int getB() {
+ return this.b;
+ }
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ public boolean equals(final java.lang.Object o) {
+ if (o == this) return true;
+ if (!(o instanceof PrivateNoArgsConstructor.PrivateNoArgsConstructorOnExtendsObject)) return false;
+ final PrivateNoArgsConstructor.PrivateNoArgsConstructorOnExtendsObject other = (PrivateNoArgsConstructor.PrivateNoArgsConstructorOnExtendsObject) o;
+ if (!other.canEqual((java.lang.Object) this)) return false;
+ if (this.getB() != other.getB()) return false;
+ return true;
+ }
+ @java.lang.SuppressWarnings("all")
+ protected boolean canEqual(final java.lang.Object other) {
+ return other instanceof PrivateNoArgsConstructor.PrivateNoArgsConstructorOnExtendsObject;
+ }
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ public int hashCode() {
+ final int PRIME = 59;
+ int result = 1;
+ result = result * PRIME + this.getB();
+ return result;
+ }
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ public java.lang.String toString() {
+ return "PrivateNoArgsConstructor.PrivateNoArgsConstructorOnExtendsObject(b=" + this.getB() + ")";
+ }
+ }
+ public static class PrivateNoArgsConstructorExplicitBefore {
+ private final int c;
+ @java.lang.SuppressWarnings("all")
+ public PrivateNoArgsConstructorExplicitBefore() {
+ this.c = 0;
+ }
+ @java.lang.SuppressWarnings("all")
+ public int getC() {
+ return this.c;
+ }
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ public boolean equals(final java.lang.Object o) {
+ if (o == this) return true;
+ if (!(o instanceof PrivateNoArgsConstructor.PrivateNoArgsConstructorExplicitBefore)) return false;
+ final PrivateNoArgsConstructor.PrivateNoArgsConstructorExplicitBefore other = (PrivateNoArgsConstructor.PrivateNoArgsConstructorExplicitBefore) o;
+ if (!other.canEqual((java.lang.Object) this)) return false;
+ if (this.getC() != other.getC()) return false;
+ return true;
+ }
+ @java.lang.SuppressWarnings("all")
+ protected boolean canEqual(final java.lang.Object other) {
+ return other instanceof PrivateNoArgsConstructor.PrivateNoArgsConstructorExplicitBefore;
+ }
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ public int hashCode() {
+ final int PRIME = 59;
+ int result = 1;
+ result = result * PRIME + this.getC();
+ return result;
+ }
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ public java.lang.String toString() {
+ return "PrivateNoArgsConstructor.PrivateNoArgsConstructorExplicitBefore(c=" + this.getC() + ")";
+ }
+ @java.lang.SuppressWarnings("all")
+ public PrivateNoArgsConstructorExplicitBefore(final int c) {
+ this.c = c;
+ }
+ }
+ public static class PrivateNoArgsConstructorExplicitAfter {
+ private final int d;
+ @java.lang.SuppressWarnings("all")
+ public int getD() {
+ return this.d;
+ }
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ public boolean equals(final java.lang.Object o) {
+ if (o == this) return true;
+ if (!(o instanceof PrivateNoArgsConstructor.PrivateNoArgsConstructorExplicitAfter)) return false;
+ final PrivateNoArgsConstructor.PrivateNoArgsConstructorExplicitAfter other = (PrivateNoArgsConstructor.PrivateNoArgsConstructorExplicitAfter) o;
+ if (!other.canEqual((java.lang.Object) this)) return false;
+ if (this.getD() != other.getD()) return false;
+ return true;
+ }
+ @java.lang.SuppressWarnings("all")
+ protected boolean canEqual(final java.lang.Object other) {
+ return other instanceof PrivateNoArgsConstructor.PrivateNoArgsConstructorExplicitAfter;
+ }
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ public int hashCode() {
+ final int PRIME = 59;
+ int result = 1;
+ result = result * PRIME + this.getD();
+ return result;
+ }
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ public java.lang.String toString() {
+ return "PrivateNoArgsConstructor.PrivateNoArgsConstructorExplicitAfter(d=" + this.getD() + ")";
+ }
+ @java.lang.SuppressWarnings("all")
+ public PrivateNoArgsConstructorExplicitAfter() {
+ this.d = 0;
+ }
+ @java.lang.SuppressWarnings("all")
+ public PrivateNoArgsConstructorExplicitAfter(final int d) {
+ this.d = d;
+ }
+ }
+ public static class PrivateNoArgsConstructorExplicitNone {
+ private final int e;
+ @java.lang.SuppressWarnings("all")
+ public int getE() {
+ return this.e;
+ }
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ public boolean equals(final java.lang.Object o) {
+ if (o == this) return true;
+ if (!(o instanceof PrivateNoArgsConstructor.PrivateNoArgsConstructorExplicitNone)) return false;
+ final PrivateNoArgsConstructor.PrivateNoArgsConstructorExplicitNone other = (PrivateNoArgsConstructor.PrivateNoArgsConstructorExplicitNone) o;
+ if (!other.canEqual((java.lang.Object) this)) return false;
+ if (this.getE() != other.getE()) return false;
+ return true;
+ }
+ @java.lang.SuppressWarnings("all")
+ protected boolean canEqual(final java.lang.Object other) {
+ return other instanceof PrivateNoArgsConstructor.PrivateNoArgsConstructorExplicitNone;
+ }
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ public int hashCode() {
+ final int PRIME = 59;
+ int result = 1;
+ result = result * PRIME + this.getE();
+ return result;
+ }
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ public java.lang.String toString() {
+ return "PrivateNoArgsConstructor.PrivateNoArgsConstructorExplicitNone(e=" + this.getE() + ")";
+ }
+ @java.lang.SuppressWarnings("all")
+ public PrivateNoArgsConstructorExplicitNone(final int e) {
+ this.e = e;
+ }
+ }
+ public static class PrivateNoArgsConstructorNoFields {
+ @java.lang.SuppressWarnings("all")
+ public PrivateNoArgsConstructorNoFields() {
+ }
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ public boolean equals(final java.lang.Object o) {
+ if (o == this) return true;
+ if (!(o instanceof PrivateNoArgsConstructor.PrivateNoArgsConstructorNoFields)) return false;
+ final PrivateNoArgsConstructor.PrivateNoArgsConstructorNoFields other = (PrivateNoArgsConstructor.PrivateNoArgsConstructorNoFields) o;
+ if (!other.canEqual((java.lang.Object) this)) return false;
+ return true;
+ }
+ @java.lang.SuppressWarnings("all")
+ protected boolean canEqual(final java.lang.Object other) {
+ return other instanceof PrivateNoArgsConstructor.PrivateNoArgsConstructorNoFields;
+ }
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ public int hashCode() {
+ int result = 1;
+ return result;
+ }
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ public java.lang.String toString() {
+ return "PrivateNoArgsConstructor.PrivateNoArgsConstructorNoFields()";
+ }
+ }
+}
diff --git a/test/transform/resource/after-ecj/PrivateNoArgsConstructor.java b/test/transform/resource/after-ecj/PrivateNoArgsConstructor.java
new file mode 100644
index 00000000..f746ec9a
--- /dev/null
+++ b/test/transform/resource/after-ecj/PrivateNoArgsConstructor.java
@@ -0,0 +1,219 @@
+public class PrivateNoArgsConstructor {
+ private static class Base {
+ private Base() {
+ super();
+ }
+ }
+ public static @lombok.Data class PrivateNoArgsConstructorNotOnExtends extends Base {
+ private final int a;
+ public @java.lang.SuppressWarnings("all") int getA() {
+ return this.a;
+ }
+ public @java.lang.Override @java.lang.SuppressWarnings("all") boolean equals(final java.lang.Object o) {
+ if ((o == this))
+ return true;
+ if ((! (o instanceof PrivateNoArgsConstructor.PrivateNoArgsConstructorNotOnExtends)))
+ return false;
+ final PrivateNoArgsConstructor.PrivateNoArgsConstructorNotOnExtends other = (PrivateNoArgsConstructor.PrivateNoArgsConstructorNotOnExtends) o;
+ if ((! other.canEqual((java.lang.Object) this)))
+ return false;
+ if ((! super.equals(o)))
+ return false;
+ if ((this.getA() != other.getA()))
+ return false;
+ return true;
+ }
+ protected @java.lang.SuppressWarnings("all") boolean canEqual(final java.lang.Object other) {
+ return (other instanceof PrivateNoArgsConstructor.PrivateNoArgsConstructorNotOnExtends);
+ }
+ public @java.lang.Override @java.lang.SuppressWarnings("all") int hashCode() {
+ final int PRIME = 59;
+ int result = super.hashCode();
+ result = ((result * PRIME) + this.getA());
+ return result;
+ }
+ public @java.lang.Override @java.lang.SuppressWarnings("all") java.lang.String toString() {
+ return (("PrivateNoArgsConstructor.PrivateNoArgsConstructorNotOnExtends(a=" + this.getA()) + ")");
+ }
+ public @java.lang.SuppressWarnings("all") PrivateNoArgsConstructorNotOnExtends(final int a) {
+ super();
+ this.a = a;
+ }
+ }
+ public static @lombok.Data class PrivateNoArgsConstructorOnExtendsObject extends Object {
+ private final int b;
+ public @java.lang.SuppressWarnings("all") int getB() {
+ return this.b;
+ }
+ public @java.lang.Override @java.lang.SuppressWarnings("all") boolean equals(final java.lang.Object o) {
+ if ((o == this))
+ return true;
+ if ((! (o instanceof PrivateNoArgsConstructor.PrivateNoArgsConstructorOnExtendsObject)))
+ return false;
+ final PrivateNoArgsConstructor.PrivateNoArgsConstructorOnExtendsObject other = (PrivateNoArgsConstructor.PrivateNoArgsConstructorOnExtendsObject) o;
+ if ((! other.canEqual((java.lang.Object) this)))
+ return false;
+ if ((this.getB() != other.getB()))
+ return false;
+ return true;
+ }
+ protected @java.lang.SuppressWarnings("all") boolean canEqual(final java.lang.Object other) {
+ return (other instanceof PrivateNoArgsConstructor.PrivateNoArgsConstructorOnExtendsObject);
+ }
+ public @java.lang.Override @java.lang.SuppressWarnings("all") int hashCode() {
+ final int PRIME = 59;
+ int result = 1;
+ result = ((result * PRIME) + this.getB());
+ return result;
+ }
+ public @java.lang.Override @java.lang.SuppressWarnings("all") java.lang.String toString() {
+ return (("PrivateNoArgsConstructor.PrivateNoArgsConstructorOnExtendsObject(b=" + this.getB()) + ")");
+ }
+ public @java.lang.SuppressWarnings("all") PrivateNoArgsConstructorOnExtendsObject(final int b) {
+ super();
+ this.b = b;
+ }
+ private @java.lang.SuppressWarnings("all") PrivateNoArgsConstructorOnExtendsObject() {
+ super();
+ this.b = 0;
+ }
+ }
+ public static @lombok.NoArgsConstructor(force = true) @lombok.Data @lombok.RequiredArgsConstructor class PrivateNoArgsConstructorExplicitBefore {
+ private final int c;
+ public @java.lang.SuppressWarnings("all") PrivateNoArgsConstructorExplicitBefore() {
+ super();
+ this.c = 0;
+ }
+ public @java.lang.SuppressWarnings("all") int getC() {
+ return this.c;
+ }
+ public @java.lang.Override @java.lang.SuppressWarnings("all") boolean equals(final java.lang.Object o) {
+ if ((o == this))
+ return true;
+ if ((! (o instanceof PrivateNoArgsConstructor.PrivateNoArgsConstructorExplicitBefore)))
+ return false;
+ final PrivateNoArgsConstructor.PrivateNoArgsConstructorExplicitBefore other = (PrivateNoArgsConstructor.PrivateNoArgsConstructorExplicitBefore) o;
+ if ((! other.canEqual((java.lang.Object) this)))
+ return false;
+ if ((this.getC() != other.getC()))
+ return false;
+ return true;
+ }
+ protected @java.lang.SuppressWarnings("all") boolean canEqual(final java.lang.Object other) {
+ return (other instanceof PrivateNoArgsConstructor.PrivateNoArgsConstructorExplicitBefore);
+ }
+ public @java.lang.Override @java.lang.SuppressWarnings("all") int hashCode() {
+ final int PRIME = 59;
+ int result = 1;
+ result = ((result * PRIME) + this.getC());
+ return result;
+ }
+ public @java.lang.Override @java.lang.SuppressWarnings("all") java.lang.String toString() {
+ return (("PrivateNoArgsConstructor.PrivateNoArgsConstructorExplicitBefore(c=" + this.getC()) + ")");
+ }
+ public @java.lang.SuppressWarnings("all") PrivateNoArgsConstructorExplicitBefore(final int c) {
+ super();
+ this.c = c;
+ }
+ }
+ public static @lombok.Data @lombok.NoArgsConstructor(force = true) @lombok.RequiredArgsConstructor class PrivateNoArgsConstructorExplicitAfter {
+ private final int d;
+ public @java.lang.SuppressWarnings("all") int getD() {
+ return this.d;
+ }
+ public @java.lang.Override @java.lang.SuppressWarnings("all") boolean equals(final java.lang.Object o) {
+ if ((o == this))
+ return true;
+ if ((! (o instanceof PrivateNoArgsConstructor.PrivateNoArgsConstructorExplicitAfter)))
+ return false;
+ final PrivateNoArgsConstructor.PrivateNoArgsConstructorExplicitAfter other = (PrivateNoArgsConstructor.PrivateNoArgsConstructorExplicitAfter) o;
+ if ((! other.canEqual((java.lang.Object) this)))
+ return false;
+ if ((this.getD() != other.getD()))
+ return false;
+ return true;
+ }
+ protected @java.lang.SuppressWarnings("all") boolean canEqual(final java.lang.Object other) {
+ return (other instanceof PrivateNoArgsConstructor.PrivateNoArgsConstructorExplicitAfter);
+ }
+ public @java.lang.Override @java.lang.SuppressWarnings("all") int hashCode() {
+ final int PRIME = 59;
+ int result = 1;
+ result = ((result * PRIME) + this.getD());
+ return result;
+ }
+ public @java.lang.Override @java.lang.SuppressWarnings("all") java.lang.String toString() {
+ return (("PrivateNoArgsConstructor.PrivateNoArgsConstructorExplicitAfter(d=" + this.getD()) + ")");
+ }
+ public @java.lang.SuppressWarnings("all") PrivateNoArgsConstructorExplicitAfter() {
+ super();
+ this.d = 0;
+ }
+ public @java.lang.SuppressWarnings("all") PrivateNoArgsConstructorExplicitAfter(final int d) {
+ super();
+ this.d = d;
+ }
+ }
+ public static @lombok.Data @lombok.NoArgsConstructor(access = lombok.AccessLevel.NONE) @lombok.RequiredArgsConstructor class PrivateNoArgsConstructorExplicitNone {
+ private final int e;
+ public @java.lang.SuppressWarnings("all") int getE() {
+ return this.e;
+ }
+ public @java.lang.Override @java.lang.SuppressWarnings("all") boolean equals(final java.lang.Object o) {
+ if ((o == this))
+ return true;
+ if ((! (o instanceof PrivateNoArgsConstructor.PrivateNoArgsConstructorExplicitNone)))
+ return false;
+ final PrivateNoArgsConstructor.PrivateNoArgsConstructorExplicitNone other = (PrivateNoArgsConstructor.PrivateNoArgsConstructorExplicitNone) o;
+ if ((! other.canEqual((java.lang.Object) this)))
+ return false;
+ if ((this.getE() != other.getE()))
+ return false;
+ return true;
+ }
+ protected @java.lang.SuppressWarnings("all") boolean canEqual(final java.lang.Object other) {
+ return (other instanceof PrivateNoArgsConstructor.PrivateNoArgsConstructorExplicitNone);
+ }
+ public @java.lang.Override @java.lang.SuppressWarnings("all") int hashCode() {
+ final int PRIME = 59;
+ int result = 1;
+ result = ((result * PRIME) + this.getE());
+ return result;
+ }
+ public @java.lang.Override @java.lang.SuppressWarnings("all") java.lang.String toString() {
+ return (("PrivateNoArgsConstructor.PrivateNoArgsConstructorExplicitNone(e=" + this.getE()) + ")");
+ }
+ public @java.lang.SuppressWarnings("all") PrivateNoArgsConstructorExplicitNone(final int e) {
+ super();
+ this.e = e;
+ }
+ }
+ public static @lombok.Data class PrivateNoArgsConstructorNoFields {
+ public @java.lang.Override @java.lang.SuppressWarnings("all") boolean equals(final java.lang.Object o) {
+ if ((o == this))
+ return true;
+ if ((! (o instanceof PrivateNoArgsConstructor.PrivateNoArgsConstructorNoFields)))
+ return false;
+ final PrivateNoArgsConstructor.PrivateNoArgsConstructorNoFields other = (PrivateNoArgsConstructor.PrivateNoArgsConstructorNoFields) o;
+ if ((! other.canEqual((java.lang.Object) this)))
+ return false;
+ return true;
+ }
+ protected @java.lang.SuppressWarnings("all") boolean canEqual(final java.lang.Object other) {
+ return (other instanceof PrivateNoArgsConstructor.PrivateNoArgsConstructorNoFields);
+ }
+ public @java.lang.Override @java.lang.SuppressWarnings("all") int hashCode() {
+ int result = 1;
+ return result;
+ }
+ public @java.lang.Override @java.lang.SuppressWarnings("all") java.lang.String toString() {
+ return "PrivateNoArgsConstructor.PrivateNoArgsConstructorNoFields()";
+ }
+ public @java.lang.SuppressWarnings("all") PrivateNoArgsConstructorNoFields() {
+ super();
+ }
+ }
+ public PrivateNoArgsConstructor() {
+ super();
+ }
+}
diff --git a/test/transform/resource/before/PrivateNoArgsConstructor.java b/test/transform/resource/before/PrivateNoArgsConstructor.java
new file mode 100644
index 00000000..911e430f
--- /dev/null
+++ b/test/transform/resource/before/PrivateNoArgsConstructor.java
@@ -0,0 +1,40 @@
+// CONF: lombok.equalsAndHashCode.callSuper = call
+public class PrivateNoArgsConstructor {
+ private static class Base {
+ }
+
+ @lombok.Data
+ public static class PrivateNoArgsConstructorNotOnExtends extends Base {
+ private final int a;
+ }
+
+ @lombok.Data
+ public static class PrivateNoArgsConstructorOnExtendsObject extends Object {
+ private final int b;
+ }
+
+ @lombok.NoArgsConstructor(force=true)
+ @lombok.Data
+ @lombok.RequiredArgsConstructor
+ public static class PrivateNoArgsConstructorExplicitBefore {
+ private final int c;
+ }
+
+ @lombok.Data
+ @lombok.NoArgsConstructor(force=true)
+ @lombok.RequiredArgsConstructor
+ public static class PrivateNoArgsConstructorExplicitAfter {
+ private final int d;
+ }
+
+ @lombok.Data
+ @lombok.NoArgsConstructor(access=lombok.AccessLevel.NONE)
+ @lombok.RequiredArgsConstructor
+ public static class PrivateNoArgsConstructorExplicitNone {
+ private final int e;
+ }
+
+ @lombok.Data
+ public static class PrivateNoArgsConstructorNoFields {
+ }
+}