diff options
| author | Roel Spilker <r.spilker@gmail.com> | 2020-09-25 00:13:50 +0200 |
|---|---|---|
| committer | Roel Spilker <r.spilker@gmail.com> | 2020-09-25 00:13:50 +0200 |
| commit | 2ba65d105ddfce54690a64f93cbc5c55480ef364 (patch) | |
| tree | c79158768703c8cc77ba9b031f30bc2d7d40db7f /test/transform/resource/after-delombok | |
| parent | ee6c0ca7f2274b24571afdc8586eff9052f5eda1 (diff) | |
| download | lombok-2ba65d105ddfce54690a64f93cbc5c55480ef364.tar.gz lombok-2ba65d105ddfce54690a64f93cbc5c55480ef364.tar.bz2 lombok-2ba65d105ddfce54690a64f93cbc5c55480ef364.zip | |
Cache hashCode:
- Fix bug where 0 would be returned once
- Fix Eclipse position error
- Don't initialize field with default value 0
Diffstat (limited to 'test/transform/resource/after-delombok')
| -rw-r--r-- | test/transform/resource/after-delombok/EqualsAndHashCodeCache.java | 31 |
1 files changed, 18 insertions, 13 deletions
diff --git a/test/transform/resource/after-delombok/EqualsAndHashCodeCache.java b/test/transform/resource/after-delombok/EqualsAndHashCodeCache.java index e76f74d5..4f3574b6 100644 --- a/test/transform/resource/after-delombok/EqualsAndHashCodeCache.java +++ b/test/transform/resource/after-delombok/EqualsAndHashCodeCache.java @@ -1,6 +1,6 @@ class EqualsAndHashCode { @java.lang.SuppressWarnings("all") - private transient int $hashCodeCache = 0; + private transient int $hashCodeCache; int x; boolean[] y; Object[] z; @@ -41,13 +41,14 @@ class EqualsAndHashCode { result = result * PRIME + ($a == null ? 43 : $a.hashCode()); final java.lang.Object $b = this.b; result = result * PRIME + ($b == null ? 43 : $b.hashCode()); - this.$hashCodeCache = result != 0 ? result : java.lang.Integer.MIN_VALUE; + if (result == 0) result = java.lang.Integer.MIN_VALUE; + this.$hashCodeCache = result; return result; } } final class EqualsAndHashCode2 { @java.lang.SuppressWarnings("all") - private transient int $hashCodeCache = 0; + private transient int $hashCodeCache; int x; long y; float f; @@ -79,13 +80,14 @@ final class EqualsAndHashCode2 { final long $d = java.lang.Double.doubleToLongBits(this.d); result = result * PRIME + (int) ($d >>> 32 ^ $d); result = result * PRIME + (this.b ? 79 : 97); - this.$hashCodeCache = result != 0 ? result : java.lang.Integer.MIN_VALUE; + if (result == 0) result = java.lang.Integer.MIN_VALUE; + this.$hashCodeCache = result; return result; } } final class EqualsAndHashCode3 extends EqualsAndHashCode { @java.lang.SuppressWarnings("all") - private transient int $hashCodeCache = 0; + private transient int $hashCodeCache; @java.lang.Override @java.lang.SuppressWarnings("all") public boolean equals(final java.lang.Object o) { @@ -103,14 +105,15 @@ final class EqualsAndHashCode3 extends EqualsAndHashCode { @java.lang.SuppressWarnings("all") public int hashCode() { if (this.$hashCodeCache != 0) return this.$hashCodeCache; - final int result = 1; - this.$hashCodeCache = result != 0 ? result : java.lang.Integer.MIN_VALUE; + int result = 1; + if (result == 0) result = java.lang.Integer.MIN_VALUE; + this.$hashCodeCache = result; return result; } } class EqualsAndHashCode4 extends EqualsAndHashCode { @java.lang.SuppressWarnings("all") - private transient int $hashCodeCache = 0; + private transient int $hashCodeCache; @java.lang.Override @java.lang.SuppressWarnings("all") public boolean equals(final java.lang.Object o) { @@ -129,14 +132,15 @@ class EqualsAndHashCode4 extends EqualsAndHashCode { @java.lang.SuppressWarnings("all") public int hashCode() { if (this.$hashCodeCache != 0) return this.$hashCodeCache; - final int result = super.hashCode(); - this.$hashCodeCache = result != 0 ? result : java.lang.Integer.MIN_VALUE; + int result = super.hashCode(); + if (result == 0) result = java.lang.Integer.MIN_VALUE; + this.$hashCodeCache = result; return result; } } final class EqualsAndHashCode5 extends EqualsAndHashCode { @java.lang.SuppressWarnings("all") - private transient int $hashCodeCache = 0; + private transient int $hashCodeCache; @java.lang.Override @java.lang.SuppressWarnings("all") public boolean equals(final java.lang.Object o) { @@ -155,8 +159,9 @@ final class EqualsAndHashCode5 extends EqualsAndHashCode { @java.lang.SuppressWarnings("all") public int hashCode() { if (this.$hashCodeCache != 0) return this.$hashCodeCache; - final int result = super.hashCode(); - this.$hashCodeCache = result != 0 ? result : java.lang.Integer.MIN_VALUE; + int result = super.hashCode(); + if (result == 0) result = java.lang.Integer.MIN_VALUE; + this.$hashCodeCache = result; return result; } } |
