From 4d24542dac058fcd7c341f9d17c4e8170a8d83a2 Mon Sep 17 00:00:00 2001 From: Roel Spilker Date: Wed, 26 Mar 2014 21:11:30 +0100 Subject: [i660] canEqual is now protected instead of public. Also fixed the total lack of canEqual in the usage examples. --- test/transform/resource/after-ecj/Accessors.java | 2 +- .../ConflictingStaticConstructorNames.java | 2 +- .../transform/resource/after-ecj/DataExtended.java | 2 +- test/transform/resource/after-ecj/DataIgnore.java | 2 +- .../resource/after-ecj/DataOnLocalClass.java | 6 +++--- test/transform/resource/after-ecj/DataPlain.java | 8 ++++---- .../resource/after-ecj/DataWithGetter.java | 2 +- .../resource/after-ecj/DataWithGetterNone.java | 2 +- .../resource/after-ecj/EqualsAndHashCode.java | 6 +++--- .../EqualsAndHashCodeWithExistingMethods.java | 23 +++++++++++++++++++++- .../EqualsAndHashCodeWithSomeExistingMethods.java | 22 +++++++++++++++++++-- .../resource/after-ecj/GetterLazyBoolean.java | 2 +- .../resource/after-ecj/GetterLazyEahcToString.java | 2 +- .../resource/after-ecj/GetterSetterJavadoc.java | 2 +- test/transform/resource/after-ecj/ValuePlain.java | 2 +- 15 files changed, 62 insertions(+), 23 deletions(-) (limited to 'test/transform/resource/after-ecj') diff --git a/test/transform/resource/after-ecj/Accessors.java b/test/transform/resource/after-ecj/Accessors.java index c8fdc3bf..6b8976d0 100644 --- a/test/transform/resource/after-ecj/Accessors.java +++ b/test/transform/resource/after-ecj/Accessors.java @@ -86,7 +86,7 @@ class AccessorsChain { return false; return true; } - public @java.lang.SuppressWarnings("all") boolean canEqual(final java.lang.Object other) { + protected @java.lang.SuppressWarnings("all") boolean canEqual(final java.lang.Object other) { return (other instanceof AccessorsPrefix3); } public @java.lang.Override @java.lang.SuppressWarnings("all") int hashCode() { diff --git a/test/transform/resource/after-ecj/ConflictingStaticConstructorNames.java b/test/transform/resource/after-ecj/ConflictingStaticConstructorNames.java index 8da11258..f8aff69c 100644 --- a/test/transform/resource/after-ecj/ConflictingStaticConstructorNames.java +++ b/test/transform/resource/after-ecj/ConflictingStaticConstructorNames.java @@ -9,7 +9,7 @@ return false; return true; } - public @java.lang.SuppressWarnings("all") boolean canEqual(final java.lang.Object other) { + protected @java.lang.SuppressWarnings("all") boolean canEqual(final java.lang.Object other) { return (other instanceof ConflictingStaticConstructorNames); } public @java.lang.Override @java.lang.SuppressWarnings("all") int hashCode() { diff --git a/test/transform/resource/after-ecj/DataExtended.java b/test/transform/resource/after-ecj/DataExtended.java index bcfd26e3..c2652ba4 100644 --- a/test/transform/resource/after-ecj/DataExtended.java +++ b/test/transform/resource/after-ecj/DataExtended.java @@ -18,7 +18,7 @@ return false; return true; } - public @java.lang.SuppressWarnings("all") boolean canEqual(final java.lang.Object other) { + protected @java.lang.SuppressWarnings("all") boolean canEqual(final java.lang.Object other) { return (other instanceof DataExtended); } public @java.lang.Override @java.lang.SuppressWarnings("all") int hashCode() { diff --git a/test/transform/resource/after-ecj/DataIgnore.java b/test/transform/resource/after-ecj/DataIgnore.java index d0e72e15..d077a5db 100644 --- a/test/transform/resource/after-ecj/DataIgnore.java +++ b/test/transform/resource/after-ecj/DataIgnore.java @@ -16,7 +16,7 @@ return false; return true; } - public @java.lang.SuppressWarnings("all") boolean canEqual(final java.lang.Object other) { + protected @java.lang.SuppressWarnings("all") boolean canEqual(final java.lang.Object other) { return (other instanceof DataIgnore); } public @java.lang.Override @java.lang.SuppressWarnings("all") int hashCode() { diff --git a/test/transform/resource/after-ecj/DataOnLocalClass.java b/test/transform/resource/after-ecj/DataOnLocalClass.java index 511291c2..3f4832ff 100644 --- a/test/transform/resource/after-ecj/DataOnLocalClass.java +++ b/test/transform/resource/after-ecj/DataOnLocalClass.java @@ -32,7 +32,7 @@ class DataOnLocalClass1 { return false; return true; } - public @java.lang.SuppressWarnings("all") boolean canEqual(final java.lang.Object other) { + protected @java.lang.SuppressWarnings("all") boolean canEqual(final java.lang.Object other) { return (other instanceof Local); } public @java.lang.Override @java.lang.SuppressWarnings("all") int hashCode() { @@ -82,7 +82,7 @@ class DataOnLocalClass2 { return false; return true; } - public @java.lang.SuppressWarnings("all") boolean canEqual(final java.lang.Object other) { + protected @java.lang.SuppressWarnings("all") boolean canEqual(final java.lang.Object other) { return (other instanceof Local.InnerLocal); } public @java.lang.Override @java.lang.SuppressWarnings("all") int hashCode() { @@ -120,7 +120,7 @@ class DataOnLocalClass2 { return false; return true; } - public @java.lang.SuppressWarnings("all") boolean canEqual(final java.lang.Object other) { + protected @java.lang.SuppressWarnings("all") boolean canEqual(final java.lang.Object other) { return (other instanceof Local); } public @java.lang.Override @java.lang.SuppressWarnings("all") int hashCode() { diff --git a/test/transform/resource/after-ecj/DataPlain.java b/test/transform/resource/after-ecj/DataPlain.java index aa47fdaa..858f46dd 100644 --- a/test/transform/resource/after-ecj/DataPlain.java +++ b/test/transform/resource/after-ecj/DataPlain.java @@ -27,7 +27,7 @@ import lombok.Data; return false; return true; } - public @java.lang.SuppressWarnings("all") boolean canEqual(final java.lang.Object other) { + protected @java.lang.SuppressWarnings("all") boolean canEqual(final java.lang.Object other) { return (other instanceof Data1); } public @java.lang.Override @java.lang.SuppressWarnings("all") int hashCode() { @@ -74,7 +74,7 @@ import lombok.Data; return false; return true; } - public @java.lang.SuppressWarnings("all") boolean canEqual(final java.lang.Object other) { + protected @java.lang.SuppressWarnings("all") boolean canEqual(final java.lang.Object other) { return (other instanceof Data2); } public @java.lang.Override @java.lang.SuppressWarnings("all") int hashCode() { @@ -163,7 +163,7 @@ final @Data @lombok.EqualsAndHashCode(callSuper = true) class Data4 extends java return false; return true; } - public @java.lang.SuppressWarnings("all") boolean canEqual(final java.lang.Object other) { + protected @java.lang.SuppressWarnings("all") boolean canEqual(final java.lang.Object other) { return (other instanceof Data4); } public @java.lang.Override @java.lang.SuppressWarnings("all") int hashCode() { @@ -185,7 +185,7 @@ final @Data @lombok.EqualsAndHashCode(callSuper = true) class Data4 extends java return false; return true; } - public @java.lang.SuppressWarnings("all") boolean canEqual(final java.lang.Object other) { + protected @java.lang.SuppressWarnings("all") boolean canEqual(final java.lang.Object other) { return (other instanceof Data5); } public @java.lang.Override @java.lang.SuppressWarnings("all") int hashCode() { diff --git a/test/transform/resource/after-ecj/DataWithGetter.java b/test/transform/resource/after-ecj/DataWithGetter.java index 2ce74ceb..ee74ed4e 100644 --- a/test/transform/resource/after-ecj/DataWithGetter.java +++ b/test/transform/resource/after-ecj/DataWithGetter.java @@ -26,7 +26,7 @@ return false; return true; } - public @java.lang.SuppressWarnings("all") boolean canEqual(final java.lang.Object other) { + protected @java.lang.SuppressWarnings("all") boolean canEqual(final java.lang.Object other) { return (other instanceof DataWithGetter); } public @java.lang.Override @java.lang.SuppressWarnings("all") int hashCode() { diff --git a/test/transform/resource/after-ecj/DataWithGetterNone.java b/test/transform/resource/after-ecj/DataWithGetterNone.java index 087d0762..056e071d 100644 --- a/test/transform/resource/after-ecj/DataWithGetterNone.java +++ b/test/transform/resource/after-ecj/DataWithGetterNone.java @@ -26,7 +26,7 @@ return false; return true; } - public @java.lang.SuppressWarnings("all") boolean canEqual(final java.lang.Object other) { + protected @java.lang.SuppressWarnings("all") boolean canEqual(final java.lang.Object other) { return (other instanceof DataWithGetterNone); } public @java.lang.Override @java.lang.SuppressWarnings("all") int hashCode() { diff --git a/test/transform/resource/after-ecj/EqualsAndHashCode.java b/test/transform/resource/after-ecj/EqualsAndHashCode.java index 625a0f87..05cbf2a3 100644 --- a/test/transform/resource/after-ecj/EqualsAndHashCode.java +++ b/test/transform/resource/after-ecj/EqualsAndHashCode.java @@ -31,7 +31,7 @@ return false; return true; } - public @java.lang.SuppressWarnings("all") boolean canEqual(final java.lang.Object other) { + protected @java.lang.SuppressWarnings("all") boolean canEqual(final java.lang.Object other) { return (other instanceof EqualsAndHashCode); } public @java.lang.Override @java.lang.SuppressWarnings("all") int hashCode() { @@ -101,7 +101,7 @@ final @lombok.EqualsAndHashCode(callSuper = false) class EqualsAndHashCode3 exte return false; return true; } - public @java.lang.SuppressWarnings("all") boolean canEqual(final java.lang.Object other) { + protected @java.lang.SuppressWarnings("all") boolean canEqual(final java.lang.Object other) { return (other instanceof EqualsAndHashCode3); } public @java.lang.Override @java.lang.SuppressWarnings("all") int hashCode() { @@ -125,7 +125,7 @@ final @lombok.EqualsAndHashCode(callSuper = false) class EqualsAndHashCode3 exte return false; return true; } - public @java.lang.SuppressWarnings("all") boolean canEqual(final java.lang.Object other) { + protected @java.lang.SuppressWarnings("all") boolean canEqual(final java.lang.Object other) { return (other instanceof EqualsAndHashCode4); } public @java.lang.Override @java.lang.SuppressWarnings("all") int hashCode() { diff --git a/test/transform/resource/after-ecj/EqualsAndHashCodeWithExistingMethods.java b/test/transform/resource/after-ecj/EqualsAndHashCodeWithExistingMethods.java index 50b219f1..feda33ce 100644 --- a/test/transform/resource/after-ecj/EqualsAndHashCodeWithExistingMethods.java +++ b/test/transform/resource/after-ecj/EqualsAndHashCodeWithExistingMethods.java @@ -21,7 +21,28 @@ final @lombok.EqualsAndHashCode(callSuper = true) class EqualsAndHashCodeWithExi EqualsAndHashCodeWithExistingMethods3() { super(); } - public boolean canEqual(Object other) { + private boolean canEqual(Object other) { return true; } + public @java.lang.Override @java.lang.SuppressWarnings("all") boolean equals(final java.lang.Object o) { + if ((o == this)) + return true; + if ((! (o instanceof EqualsAndHashCodeWithExistingMethods3))) + return false; + final @java.lang.SuppressWarnings("all") EqualsAndHashCodeWithExistingMethods3 other = (EqualsAndHashCodeWithExistingMethods3) o; + if ((! other.canEqual((java.lang.Object) this))) + return false; + if ((! super.equals(o))) + return false; + if ((this.x != other.x)) + return false; + return true; + } + public @java.lang.Override @java.lang.SuppressWarnings("all") int hashCode() { + final int PRIME = 59; + int result = 1; + result = ((result * PRIME) + super.hashCode()); + result = ((result * PRIME) + this.x); + return result; + } } \ No newline at end of file diff --git a/test/transform/resource/after-ecj/EqualsAndHashCodeWithSomeExistingMethods.java b/test/transform/resource/after-ecj/EqualsAndHashCodeWithSomeExistingMethods.java index 05f7ad97..ee846c64 100644 --- a/test/transform/resource/after-ecj/EqualsAndHashCodeWithSomeExistingMethods.java +++ b/test/transform/resource/after-ecj/EqualsAndHashCodeWithSomeExistingMethods.java @@ -14,9 +14,27 @@ import static lombok.AccessLevel.NONE; } @Data @Getter(NONE) @Setter(NONE) class EqualsAndHashCodeWithSomeExistingMethods2 { int x; - public boolean canEqual(Object other) { + protected boolean canEqual(Object other) { return false; } + public @java.lang.Override @java.lang.SuppressWarnings("all") boolean equals(final java.lang.Object o) { + if ((o == this)) + return true; + if ((! (o instanceof EqualsAndHashCodeWithSomeExistingMethods2))) + return false; + final @java.lang.SuppressWarnings("all") EqualsAndHashCodeWithSomeExistingMethods2 other = (EqualsAndHashCodeWithSomeExistingMethods2) o; + if ((! other.canEqual((java.lang.Object) this))) + return false; + if ((this.x != other.x)) + 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.x); + return result; + } public @java.lang.Override @java.lang.SuppressWarnings("all") java.lang.String toString() { return (("EqualsAndHashCodeWithSomeExistingMethods2(x=" + this.x) + ")"); } @@ -53,7 +71,7 @@ import static lombok.AccessLevel.NONE; return false; return true; } - public @java.lang.SuppressWarnings("all") boolean canEqual(final java.lang.Object other) { + protected @java.lang.SuppressWarnings("all") boolean canEqual(final java.lang.Object other) { return (other instanceof EqualsAndHashCodeWithNoExistingMethods); } public @java.lang.Override @java.lang.SuppressWarnings("all") int hashCode() { diff --git a/test/transform/resource/after-ecj/GetterLazyBoolean.java b/test/transform/resource/after-ecj/GetterLazyBoolean.java index c37eece2..cd5bac20 100644 --- a/test/transform/resource/after-ecj/GetterLazyBoolean.java +++ b/test/transform/resource/after-ecj/GetterLazyBoolean.java @@ -53,7 +53,7 @@ return false; return true; } - public @java.lang.SuppressWarnings("all") boolean canEqual(final java.lang.Object other) { + protected @java.lang.SuppressWarnings("all") boolean canEqual(final java.lang.Object other) { return (other instanceof GetterLazyBoolean); } public @java.lang.Override @java.lang.SuppressWarnings("all") int hashCode() { diff --git a/test/transform/resource/after-ecj/GetterLazyEahcToString.java b/test/transform/resource/after-ecj/GetterLazyEahcToString.java index da9f6a83..df26f912 100644 --- a/test/transform/resource/after-ecj/GetterLazyEahcToString.java +++ b/test/transform/resource/after-ecj/GetterLazyEahcToString.java @@ -42,7 +42,7 @@ return false; return true; } - public @java.lang.SuppressWarnings("all") boolean canEqual(final java.lang.Object other) { + protected @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() { diff --git a/test/transform/resource/after-ecj/GetterSetterJavadoc.java b/test/transform/resource/after-ecj/GetterSetterJavadoc.java index b7fc15b8..9f3bb9bd 100644 --- a/test/transform/resource/after-ecj/GetterSetterJavadoc.java +++ b/test/transform/resource/after-ecj/GetterSetterJavadoc.java @@ -18,7 +18,7 @@ return false; return true; } - public @java.lang.SuppressWarnings("all") boolean canEqual(final java.lang.Object other) { + protected @java.lang.SuppressWarnings("all") boolean canEqual(final java.lang.Object other) { return (other instanceof GetterSetterJavadoc1); } public @java.lang.Override @java.lang.SuppressWarnings("all") int hashCode() { diff --git a/test/transform/resource/after-ecj/ValuePlain.java b/test/transform/resource/after-ecj/ValuePlain.java index 5ca32af8..8162ab93 100644 --- a/test/transform/resource/after-ecj/ValuePlain.java +++ b/test/transform/resource/after-ecj/ValuePlain.java @@ -64,7 +64,7 @@ final @lombok.Value class Value1 { return false; return true; } - public @java.lang.SuppressWarnings("all") boolean canEqual(final java.lang.Object other) { + protected @java.lang.SuppressWarnings("all") boolean canEqual(final java.lang.Object other) { return (other instanceof Value2); } public @java.lang.Override @java.lang.SuppressWarnings("all") int hashCode() { -- cgit