aboutsummaryrefslogtreecommitdiff
path: root/test/transform/resource/after-delombok
diff options
context:
space:
mode:
authorRawi01 <Rawi01@users.noreply.github.com>2021-05-29 18:49:05 +0200
committerRawi01 <Rawi01@users.noreply.github.com>2021-06-03 19:23:19 +0200
commit60f575496b3184c2279e9dba470097ed164d5adf (patch)
tree61493259ec561b5d01a7a6e5361b4a7b16b5b106 /test/transform/resource/after-delombok
parent6758714ed564d72236564889157c4812eacb96fb (diff)
downloadlombok-60f575496b3184c2279e9dba470097ed164d5adf.tar.gz
lombok-60f575496b3184c2279e9dba470097ed164d5adf.tar.bz2
lombok-60f575496b3184c2279e9dba470097ed164d5adf.zip
[fixes #2838] Handle anonymous classes properly
Generated qualified names (e.g. Outer.Inner) now stop at anonymous classes instead of adding an empty part. All handlers that add static fields/methods/types now add error messages instead of generating invalid code.
Diffstat (limited to 'test/transform/resource/after-delombok')
-rw-r--r--test/transform/resource/after-delombok/AccessorsInAnonymousClass.java22
-rw-r--r--test/transform/resource/after-delombok/BuilderInAnonymousClass.java8
-rw-r--r--test/transform/resource/after-delombok/ConstructorsInAnonymousClass.java33
-rw-r--r--test/transform/resource/after-delombok/DataInAnonymousClass.java56
-rw-r--r--test/transform/resource/after-delombok/EqualsAndHashCodeInAnonymousClass.java36
-rw-r--r--test/transform/resource/after-delombok/FieldNameConstantsInAnonymousClass.java8
-rw-r--r--test/transform/resource/after-delombok/GetterInAnonymousClass.java13
-rw-r--r--test/transform/resource/after-delombok/GetterLazyInAnonymousClass.java24
-rw-r--r--test/transform/resource/after-delombok/LoggerSlf4jInAnonymousClass.java7
-rw-r--r--test/transform/resource/after-delombok/SetterInAnonymousClass.java13
-rw-r--r--test/transform/resource/after-delombok/SuperBuilderInAnonymousClass.java12
-rw-r--r--test/transform/resource/after-delombok/SynchronizedInAnonymousClass.java15
-rw-r--r--test/transform/resource/after-delombok/ToStringInAnonymousClass.java14
-rw-r--r--test/transform/resource/after-delombok/UtilityClassInAnonymousClass.java8
-rw-r--r--test/transform/resource/after-delombok/ValueInAnonymousClass.java46
-rw-r--r--test/transform/resource/after-delombok/WithByInAnonymousClass.java16
-rw-r--r--test/transform/resource/after-delombok/WithInAnonymousClass.java19
17 files changed, 350 insertions, 0 deletions
diff --git a/test/transform/resource/after-delombok/AccessorsInAnonymousClass.java b/test/transform/resource/after-delombok/AccessorsInAnonymousClass.java
new file mode 100644
index 00000000..27fab509
--- /dev/null
+++ b/test/transform/resource/after-delombok/AccessorsInAnonymousClass.java
@@ -0,0 +1,22 @@
+public class AccessorsInAnonymousClass {
+ Object annonymous = new Object() {
+
+ class Inner {
+ private String string;
+
+ @java.lang.SuppressWarnings("all")
+ public String string() {
+ return this.string;
+ }
+
+ /**
+ * @return {@code this}.
+ */
+ @java.lang.SuppressWarnings("all")
+ public Inner string(final String string) {
+ this.string = string;
+ return this;
+ }
+ }
+ };
+}
diff --git a/test/transform/resource/after-delombok/BuilderInAnonymousClass.java b/test/transform/resource/after-delombok/BuilderInAnonymousClass.java
new file mode 100644
index 00000000..4810a0a8
--- /dev/null
+++ b/test/transform/resource/after-delombok/BuilderInAnonymousClass.java
@@ -0,0 +1,8 @@
+public class BuilderInAnonymousClass {
+ Object annonymous = new Object() {
+
+ class Inner {
+ private String string;
+ }
+ };
+}
diff --git a/test/transform/resource/after-delombok/ConstructorsInAnonymousClass.java b/test/transform/resource/after-delombok/ConstructorsInAnonymousClass.java
new file mode 100644
index 00000000..56e96ae3
--- /dev/null
+++ b/test/transform/resource/after-delombok/ConstructorsInAnonymousClass.java
@@ -0,0 +1,33 @@
+import lombok.NonNull;
+
+public class ConstructorsInAnonymousClass {
+ Object annonymous = new Object() {
+
+ class Inner {
+ private String string;
+ @NonNull
+ private String string2;
+
+ @java.lang.SuppressWarnings("all")
+ public Inner(final String string, @NonNull final String string2) {
+ if (string2 == null) {
+ throw new java.lang.NullPointerException("string2 is marked non-null but is null");
+ }
+ this.string = string;
+ this.string2 = string2;
+ }
+
+ @java.lang.SuppressWarnings("all")
+ public Inner(@NonNull final String string2) {
+ if (string2 == null) {
+ throw new java.lang.NullPointerException("string2 is marked non-null but is null");
+ }
+ this.string2 = string2;
+ }
+
+ @java.lang.SuppressWarnings("all")
+ public Inner() {
+ }
+ }
+ };
+}
diff --git a/test/transform/resource/after-delombok/DataInAnonymousClass.java b/test/transform/resource/after-delombok/DataInAnonymousClass.java
new file mode 100644
index 00000000..788d7be5
--- /dev/null
+++ b/test/transform/resource/after-delombok/DataInAnonymousClass.java
@@ -0,0 +1,56 @@
+public class DataInAnonymousClass {
+ Object annonymous = new Object() {
+
+ class Inner {
+ private String string;
+
+ @java.lang.SuppressWarnings("all")
+ public Inner() {
+ }
+
+ @java.lang.SuppressWarnings("all")
+ public String getString() {
+ return this.string;
+ }
+
+ @java.lang.SuppressWarnings("all")
+ public void setString(final String string) {
+ this.string = string;
+ }
+
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ public boolean equals(final java.lang.Object o) {
+ if (o == this) return true;
+ if (!(o instanceof Inner)) return false;
+ final Inner other = (Inner) o;
+ if (!other.canEqual((java.lang.Object) this)) return false;
+ final java.lang.Object this$string = this.getString();
+ final java.lang.Object other$string = other.getString();
+ if (this$string == null ? other$string != null : !this$string.equals(other$string)) return false;
+ return true;
+ }
+
+ @java.lang.SuppressWarnings("all")
+ protected boolean canEqual(final java.lang.Object other) {
+ return other instanceof Inner;
+ }
+
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ public int hashCode() {
+ final int PRIME = 59;
+ int result = 1;
+ final java.lang.Object $string = this.getString();
+ result = result * PRIME + ($string == null ? 43 : $string.hashCode());
+ return result;
+ }
+
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ public java.lang.String toString() {
+ return "Inner(string=" + this.getString() + ")";
+ }
+ }
+ };
+}
diff --git a/test/transform/resource/after-delombok/EqualsAndHashCodeInAnonymousClass.java b/test/transform/resource/after-delombok/EqualsAndHashCodeInAnonymousClass.java
new file mode 100644
index 00000000..6f0b5738
--- /dev/null
+++ b/test/transform/resource/after-delombok/EqualsAndHashCodeInAnonymousClass.java
@@ -0,0 +1,36 @@
+public class EqualsAndHashCodeInAnonymousClass {
+ Object annonymous = new Object() {
+
+ class Inner {
+ private String string;
+
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ public boolean equals(final java.lang.Object o) {
+ if (o == this) return true;
+ if (!(o instanceof Inner)) return false;
+ final Inner other = (Inner) o;
+ if (!other.canEqual((java.lang.Object) this)) return false;
+ final java.lang.Object this$string = this.string;
+ final java.lang.Object other$string = other.string;
+ if (this$string == null ? other$string != null : !this$string.equals(other$string)) return false;
+ return true;
+ }
+
+ @java.lang.SuppressWarnings("all")
+ protected boolean canEqual(final java.lang.Object other) {
+ return other instanceof Inner;
+ }
+
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ public int hashCode() {
+ final int PRIME = 59;
+ int result = 1;
+ final java.lang.Object $string = this.string;
+ result = result * PRIME + ($string == null ? 43 : $string.hashCode());
+ return result;
+ }
+ }
+ };
+}
diff --git a/test/transform/resource/after-delombok/FieldNameConstantsInAnonymousClass.java b/test/transform/resource/after-delombok/FieldNameConstantsInAnonymousClass.java
new file mode 100644
index 00000000..1f7e7d7a
--- /dev/null
+++ b/test/transform/resource/after-delombok/FieldNameConstantsInAnonymousClass.java
@@ -0,0 +1,8 @@
+public class FieldNameConstantsInAnonymousClass {
+ Object annonymous = new Object() {
+
+ class Inner {
+ private String string;
+ }
+ };
+}
diff --git a/test/transform/resource/after-delombok/GetterInAnonymousClass.java b/test/transform/resource/after-delombok/GetterInAnonymousClass.java
new file mode 100644
index 00000000..3c990545
--- /dev/null
+++ b/test/transform/resource/after-delombok/GetterInAnonymousClass.java
@@ -0,0 +1,13 @@
+public class GetterInAnonymousClass {
+ Object annonymous = new Object() {
+
+ class Inner {
+ private String string;
+
+ @java.lang.SuppressWarnings("all")
+ public String getString() {
+ return this.string;
+ }
+ }
+ };
+}
diff --git a/test/transform/resource/after-delombok/GetterLazyInAnonymousClass.java b/test/transform/resource/after-delombok/GetterLazyInAnonymousClass.java
new file mode 100644
index 00000000..4476e463
--- /dev/null
+++ b/test/transform/resource/after-delombok/GetterLazyInAnonymousClass.java
@@ -0,0 +1,24 @@
+public class GetterLazyInAnonymousClass {
+ Object annonymous = new Object() {
+
+ class Inner {
+ private final java.util.concurrent.atomic.AtomicReference<java.lang.Object> string = new java.util.concurrent.atomic.AtomicReference<java.lang.Object>();
+
+ @java.lang.SuppressWarnings({"all", "unchecked"})
+ public String getString() {
+ java.lang.Object value = this.string.get();
+ if (value == null) {
+ synchronized (this.string) {
+ value = this.string.get();
+ if (value == null) {
+ final String actualValue = "test";
+ value = actualValue == null ? this.string : actualValue;
+ this.string.set(value);
+ }
+ }
+ }
+ return (String) (value == this.string ? null : value);
+ }
+ }
+ };
+}
diff --git a/test/transform/resource/after-delombok/LoggerSlf4jInAnonymousClass.java b/test/transform/resource/after-delombok/LoggerSlf4jInAnonymousClass.java
new file mode 100644
index 00000000..1ec25d92
--- /dev/null
+++ b/test/transform/resource/after-delombok/LoggerSlf4jInAnonymousClass.java
@@ -0,0 +1,7 @@
+public class LoggerSlf4jInAnonymousClass {
+ Object annonymous = new Object() {
+
+ class Inner {
+ }
+ };
+}
diff --git a/test/transform/resource/after-delombok/SetterInAnonymousClass.java b/test/transform/resource/after-delombok/SetterInAnonymousClass.java
new file mode 100644
index 00000000..ced2be52
--- /dev/null
+++ b/test/transform/resource/after-delombok/SetterInAnonymousClass.java
@@ -0,0 +1,13 @@
+public class SetterInAnonymousClass {
+ Object annonymous = new Object() {
+
+ class Inner {
+ private String string;
+
+ @java.lang.SuppressWarnings("all")
+ public void setString(final String string) {
+ this.string = string;
+ }
+ }
+ };
+}
diff --git a/test/transform/resource/after-delombok/SuperBuilderInAnonymousClass.java b/test/transform/resource/after-delombok/SuperBuilderInAnonymousClass.java
new file mode 100644
index 00000000..cc654919
--- /dev/null
+++ b/test/transform/resource/after-delombok/SuperBuilderInAnonymousClass.java
@@ -0,0 +1,12 @@
+public class SuperBuilderInAnonymousClass {
+ Object annonymous = new Object() {
+
+ class InnerParent {
+ private String string;
+ }
+
+ class InnerChild {
+ private String string;
+ }
+ };
+}
diff --git a/test/transform/resource/after-delombok/SynchronizedInAnonymousClass.java b/test/transform/resource/after-delombok/SynchronizedInAnonymousClass.java
new file mode 100644
index 00000000..904487a3
--- /dev/null
+++ b/test/transform/resource/after-delombok/SynchronizedInAnonymousClass.java
@@ -0,0 +1,15 @@
+public class SynchronizedInAnonymousClass {
+ Object annonymous = new Object() {
+
+ class Inner {
+ @java.lang.SuppressWarnings("all")
+ private final java.lang.Object $lock = new java.lang.Object[0];
+
+ public void foo() {
+ synchronized (this.$lock) {
+ String foo = "bar";
+ }
+ }
+ }
+ };
+}
diff --git a/test/transform/resource/after-delombok/ToStringInAnonymousClass.java b/test/transform/resource/after-delombok/ToStringInAnonymousClass.java
new file mode 100644
index 00000000..aa3651bb
--- /dev/null
+++ b/test/transform/resource/after-delombok/ToStringInAnonymousClass.java
@@ -0,0 +1,14 @@
+public class ToStringInAnonymousClass {
+ Object annonymous = new Object() {
+
+ class Inner {
+ private String string;
+
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ public java.lang.String toString() {
+ return "Inner(string=" + this.string + ")";
+ }
+ }
+ };
+}
diff --git a/test/transform/resource/after-delombok/UtilityClassInAnonymousClass.java b/test/transform/resource/after-delombok/UtilityClassInAnonymousClass.java
new file mode 100644
index 00000000..3df9b559
--- /dev/null
+++ b/test/transform/resource/after-delombok/UtilityClassInAnonymousClass.java
@@ -0,0 +1,8 @@
+public class UtilityClassInAnonymousClass {
+ Object annonymous = new Object() {
+
+ class Inner {
+ private String string;
+ }
+ };
+}
diff --git a/test/transform/resource/after-delombok/ValueInAnonymousClass.java b/test/transform/resource/after-delombok/ValueInAnonymousClass.java
new file mode 100644
index 00000000..5bab4093
--- /dev/null
+++ b/test/transform/resource/after-delombok/ValueInAnonymousClass.java
@@ -0,0 +1,46 @@
+public class ValueInAnonymousClass {
+ Object annonymous = new Object() {
+
+ final class Inner {
+ private final String string;
+
+ @java.lang.SuppressWarnings("all")
+ public Inner(final String string) {
+ this.string = string;
+ }
+
+ @java.lang.SuppressWarnings("all")
+ public String getString() {
+ return this.string;
+ }
+
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ public boolean equals(final java.lang.Object o) {
+ if (o == this) return true;
+ if (!(o instanceof Inner)) return false;
+ final Inner other = (Inner) o;
+ final java.lang.Object this$string = this.getString();
+ final java.lang.Object other$string = other.getString();
+ if (this$string == null ? other$string != null : !this$string.equals(other$string)) return false;
+ return true;
+ }
+
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ public int hashCode() {
+ final int PRIME = 59;
+ int result = 1;
+ final java.lang.Object $string = this.getString();
+ result = result * PRIME + ($string == null ? 43 : $string.hashCode());
+ return result;
+ }
+
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ public java.lang.String toString() {
+ return "Inner(string=" + this.getString() + ")";
+ }
+ }
+ };
+}
diff --git a/test/transform/resource/after-delombok/WithByInAnonymousClass.java b/test/transform/resource/after-delombok/WithByInAnonymousClass.java
new file mode 100644
index 00000000..e3c70763
--- /dev/null
+++ b/test/transform/resource/after-delombok/WithByInAnonymousClass.java
@@ -0,0 +1,16 @@
+public class WithByInAnonymousClass {
+ Object annonymous = new Object() {
+
+ class Inner {
+ private Inner(String string) {
+ }
+
+ private String string;
+
+ @java.lang.SuppressWarnings("all")
+ public Inner withStringBy(final java.util.function.Function<? super String, ? extends String> transformer) {
+ return new Inner(transformer.apply(this.string));
+ }
+ }
+ };
+}
diff --git a/test/transform/resource/after-delombok/WithInAnonymousClass.java b/test/transform/resource/after-delombok/WithInAnonymousClass.java
new file mode 100644
index 00000000..02490533
--- /dev/null
+++ b/test/transform/resource/after-delombok/WithInAnonymousClass.java
@@ -0,0 +1,19 @@
+public class WithInAnonymousClass {
+ Object annonymous = new Object() {
+
+ class Inner {
+ private Inner(String string) {
+ }
+
+ private String string;
+
+ /**
+ * @return a clone of this object, except with this updated property (returns {@code this} if an identical value is passed).
+ */
+ @java.lang.SuppressWarnings("all")
+ public Inner withString(final String string) {
+ return this.string == string ? this : new Inner(string);
+ }
+ }
+ };
+}