From 3f00e7c90548cc00fca75ad1975a2ecc05521871 Mon Sep 17 00:00:00 2001 From: Roel Spilker Date: Thu, 11 Nov 2010 05:55:15 +0100 Subject: @Getter(lazy=true) now also works in Eclipse --- test/transform/resource/after-ecj/GetterLazy.java | 27 ++++ .../resource/after-ecj/GetterLazyEahcToString.java | 53 +++++++ .../resource/after-ecj/GetterLazyInvalid.java | 40 ++++++ .../resource/after-ecj/GetterLazyNative.java | 158 +++++++++++++++++++++ 4 files changed, 278 insertions(+) create mode 100644 test/transform/resource/after-ecj/GetterLazy.java create mode 100644 test/transform/resource/after-ecj/GetterLazyEahcToString.java create mode 100644 test/transform/resource/after-ecj/GetterLazyInvalid.java create mode 100644 test/transform/resource/after-ecj/GetterLazyNative.java (limited to 'test/transform/resource/after-ecj') diff --git a/test/transform/resource/after-ecj/GetterLazy.java b/test/transform/resource/after-ecj/GetterLazy.java new file mode 100644 index 00000000..669a9a81 --- /dev/null +++ b/test/transform/resource/after-ecj/GetterLazy.java @@ -0,0 +1,27 @@ +class GetterLazy { + static class ValueType { + ValueType() { + super(); + } + } + private final @lombok.Getter(lazy = true) java.util.concurrent.atomic.AtomicReference> fieldName = new java.util.concurrent.atomic.AtomicReference>(); + public @java.lang.SuppressWarnings("all") ValueType getFieldName() { + java.util.concurrent.atomic.AtomicReference value = this.fieldName.get(); + if ((value == null)) + { + synchronized (this.fieldName) + { + value = this.fieldName.get(); + if ((value == null)) + { + value = new java.util.concurrent.atomic.AtomicReference(new ValueType()); + this.fieldName.set(value); + } + } + } + return value.get(); + } + GetterLazy() { + super(); + } +} diff --git a/test/transform/resource/after-ecj/GetterLazyEahcToString.java b/test/transform/resource/after-ecj/GetterLazyEahcToString.java new file mode 100644 index 00000000..6261ce38 --- /dev/null +++ b/test/transform/resource/after-ecj/GetterLazyEahcToString.java @@ -0,0 +1,53 @@ +@lombok.EqualsAndHashCode(doNotUseGetters = true) @lombok.ToString(doNotUseGetters = true) class GetterLazyEahcToString { + private final @lombok.Getter(lazy = true) java.util.concurrent.atomic.AtomicReference> value = new java.util.concurrent.atomic.AtomicReference>(); + private final @lombok.Getter String value2 = ""; + public @java.lang.SuppressWarnings("all") String getValue() { + java.util.concurrent.atomic.AtomicReference value = this.value.get(); + if ((value == null)) + { + synchronized (this.value) + { + value = this.value.get(); + if ((value == null)) + { + value = new java.util.concurrent.atomic.AtomicReference(""); + this.value.set(value); + } + } + } + return value.get(); + } + public @java.lang.SuppressWarnings("all") String getValue2() { + return this.value2; + } + public @java.lang.Override @java.lang.SuppressWarnings("all") boolean equals(final java.lang.Object o) { + if ((o == this)) + return true; + if ((! (o instanceof GetterLazyEahcToString))) + return false; + final GetterLazyEahcToString other = (GetterLazyEahcToString) o; + if ((! other.canEqual(this))) + return false; + if (((this.getValue() == null) ? (other.getValue() != null) : (! this.getValue().equals(other.getValue())))) + return false; + if (((this.value2 == null) ? (other.value2 != null) : (! this.value2.equals(other.value2)))) + return false; + return true; + } + public @java.lang.SuppressWarnings("all") boolean canEqual(final java.lang.Object other) { + return (other instanceof GetterLazyEahcToString); + } + public @java.lang.Override @java.lang.SuppressWarnings("all") int hashCode() { + final int PRIME = 31; + int result = 1; + result = ((result * PRIME) + ((this.getValue() == null) ? 0 : this.getValue().hashCode())); + result = ((result * PRIME) + ((this.value2 == null) ? 0 : this.value2.hashCode())); + return result; + } + public @java.lang.Override @java.lang.SuppressWarnings("all") java.lang.String toString() { + return (((("GetterLazyEahcToString(value=" + this.getValue()) + ", value2=") + this.value2) + ")"); + } + GetterLazyEahcToString() { + super(); + } +} \ No newline at end of file diff --git a/test/transform/resource/after-ecj/GetterLazyInvalid.java b/test/transform/resource/after-ecj/GetterLazyInvalid.java new file mode 100644 index 00000000..eaa22d71 --- /dev/null +++ b/test/transform/resource/after-ecj/GetterLazyInvalid.java @@ -0,0 +1,40 @@ +class GetterLazyInvalidNotFinal { + private @lombok.Getter(lazy = true) String fieldName = ""; + GetterLazyInvalidNotFinal() { + super(); + } +} +class GetterLazyInvalidNotPrivate { + final @lombok.Getter(lazy = true) String fieldName = ""; + GetterLazyInvalidNotPrivate() { + super(); + } +} +class GetterLazyInvalidNotPrivateFinal { + @lombok.Getter(lazy = true) String fieldName = ""; + GetterLazyInvalidNotPrivateFinal() { + super(); + } +} +class GetterLazyInvalidNone { + private final @lombok.Getter(lazy = true,value = lombok.AccessLevel.NONE) String fieldName = ""; + GetterLazyInvalidNone() { + super(); + } +} +@lombok.Getter(lazy = true) class GetterLazyInvalidClass { + private final String fieldName = ""; + public @java.lang.SuppressWarnings("all") String getFieldName() { + return this.fieldName; + } + GetterLazyInvalidClass() { + super(); + } +} +class GetterLazyInvalidNoInit { + private final @lombok.Getter(lazy = true) String fieldName; + GetterLazyInvalidNoInit() { + super(); + this.fieldName = "foo"; + } +} \ No newline at end of file diff --git a/test/transform/resource/after-ecj/GetterLazyNative.java b/test/transform/resource/after-ecj/GetterLazyNative.java new file mode 100644 index 00000000..6c90a101 --- /dev/null +++ b/test/transform/resource/after-ecj/GetterLazyNative.java @@ -0,0 +1,158 @@ +class GetterLazyNative { + private final @lombok.Getter(lazy = true) java.util.concurrent.atomic.AtomicReference> booleanField = new java.util.concurrent.atomic.AtomicReference>(); + private final @lombok.Getter(lazy = true) java.util.concurrent.atomic.AtomicReference> byteField = new java.util.concurrent.atomic.AtomicReference>(); + private final @lombok.Getter(lazy = true) java.util.concurrent.atomic.AtomicReference> shortField = new java.util.concurrent.atomic.AtomicReference>(); + private final @lombok.Getter(lazy = true) java.util.concurrent.atomic.AtomicReference> intField = new java.util.concurrent.atomic.AtomicReference>(); + private final @lombok.Getter(lazy = true) java.util.concurrent.atomic.AtomicReference> longField = new java.util.concurrent.atomic.AtomicReference>(); + private final @lombok.Getter(lazy = true) java.util.concurrent.atomic.AtomicReference> floatField = new java.util.concurrent.atomic.AtomicReference>(); + private final @lombok.Getter(lazy = true) java.util.concurrent.atomic.AtomicReference> doubleField = new java.util.concurrent.atomic.AtomicReference>(); + private final @lombok.Getter(lazy = true) java.util.concurrent.atomic.AtomicReference> charField = new java.util.concurrent.atomic.AtomicReference>(); + private final @lombok.Getter(lazy = true) java.util.concurrent.atomic.AtomicReference> intArrayField = new java.util.concurrent.atomic.AtomicReference>(); + public @java.lang.SuppressWarnings("all") boolean isBooleanField() { + java.util.concurrent.atomic.AtomicReference value = this.booleanField.get(); + if ((value == null)) + { + synchronized (this.booleanField) + { + value = this.booleanField.get(); + if ((value == null)) + { + value = new java.util.concurrent.atomic.AtomicReference(true); + this.booleanField.set(value); + } + } + } + return value.get(); + } + public @java.lang.SuppressWarnings("all") byte getByteField() { + java.util.concurrent.atomic.AtomicReference value = this.byteField.get(); + if ((value == null)) + { + synchronized (this.byteField) + { + value = this.byteField.get(); + if ((value == null)) + { + value = new java.util.concurrent.atomic.AtomicReference(1); + this.byteField.set(value); + } + } + } + return value.get(); + } + public @java.lang.SuppressWarnings("all") short getShortField() { + java.util.concurrent.atomic.AtomicReference value = this.shortField.get(); + if ((value == null)) + { + synchronized (this.shortField) + { + value = this.shortField.get(); + if ((value == null)) + { + value = new java.util.concurrent.atomic.AtomicReference(1); + this.shortField.set(value); + } + } + } + return value.get(); + } + public @java.lang.SuppressWarnings("all") int getIntField() { + java.util.concurrent.atomic.AtomicReference value = this.intField.get(); + if ((value == null)) + { + synchronized (this.intField) + { + value = this.intField.get(); + if ((value == null)) + { + value = new java.util.concurrent.atomic.AtomicReference(1); + this.intField.set(value); + } + } + } + return value.get(); + } + public @java.lang.SuppressWarnings("all") long getLongField() { + java.util.concurrent.atomic.AtomicReference value = this.longField.get(); + if ((value == null)) + { + synchronized (this.longField) + { + value = this.longField.get(); + if ((value == null)) + { + value = new java.util.concurrent.atomic.AtomicReference(1); + this.longField.set(value); + } + } + } + return value.get(); + } + public @java.lang.SuppressWarnings("all") float getFloatField() { + java.util.concurrent.atomic.AtomicReference value = this.floatField.get(); + if ((value == null)) + { + synchronized (this.floatField) + { + value = this.floatField.get(); + if ((value == null)) + { + value = new java.util.concurrent.atomic.AtomicReference(1.0f); + this.floatField.set(value); + } + } + } + return value.get(); + } + public @java.lang.SuppressWarnings("all") double getDoubleField() { + java.util.concurrent.atomic.AtomicReference value = this.doubleField.get(); + if ((value == null)) + { + synchronized (this.doubleField) + { + value = this.doubleField.get(); + if ((value == null)) + { + value = new java.util.concurrent.atomic.AtomicReference(1.0); + this.doubleField.set(value); + } + } + } + return value.get(); + } + public @java.lang.SuppressWarnings("all") char getCharField() { + java.util.concurrent.atomic.AtomicReference value = this.charField.get(); + if ((value == null)) + { + synchronized (this.charField) + { + value = this.charField.get(); + if ((value == null)) + { + value = new java.util.concurrent.atomic.AtomicReference('1'); + this.charField.set(value); + } + } + } + return value.get(); + } + public @java.lang.SuppressWarnings("all") int[] getIntArrayField() { + java.util.concurrent.atomic.AtomicReference value = this.intArrayField.get(); + if ((value == null)) + { + synchronized (this.intArrayField) + { + value = this.intArrayField.get(); + if ((value == null)) + { + value = new java.util.concurrent.atomic.AtomicReference(new int[]{1}); + this.intArrayField.set(value); + } + } + } + return value.get(); + } + GetterLazyNative() { + super(); + } +} \ No newline at end of file -- cgit