From a40a86ad532881acd311200a665b5f55790c55cc Mon Sep 17 00:00:00 2001 From: Reinier Zwitserloot Date: Thu, 9 Jan 2014 21:00:44 +0100 Subject: [#625] Instead of '31' as a prime number for hashCode(), use something else. 31, probably owing to its inclusion in Effective Java, is overused, as proven by Maaartinus in issue 625. Switching to 277 instead. Also, 1231/1237 pair used for booleans has been replaced by 2591/2609. --- test/transform/resource/after-ecj/Accessors.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test/transform/resource/after-ecj/Accessors.java') diff --git a/test/transform/resource/after-ecj/Accessors.java b/test/transform/resource/after-ecj/Accessors.java index 292db928..52a72d52 100644 --- a/test/transform/resource/after-ecj/Accessors.java +++ b/test/transform/resource/after-ecj/Accessors.java @@ -90,7 +90,7 @@ class AccessorsChain { return (other instanceof AccessorsPrefix3); } public @java.lang.Override @java.lang.SuppressWarnings("all") int hashCode() { - final int PRIME = 31; + final int PRIME = 277; int result = 1; final java.lang.Object $fName = this.getName(); result = ((result * PRIME) + (($fName == null) ? 0 : $fName.hashCode())); -- cgit From 14cc54527663018cdf7343eefffc8c37fbce93bb Mon Sep 17 00:00:00 2001 From: Roel Spilker Date: Sun, 19 Jan 2014 21:49:35 +0100 Subject: Issue 625: use (even) better primes for hashcodes --- doc/changelog.markdown | 1 + src/core/lombok/core/handlers/HandlerUtil.java | 14 +++++++++++--- .../lombok/eclipse/handlers/HandleEqualsAndHashCode.java | 12 ++++++------ .../lombok/javac/handlers/HandleEqualsAndHashCode.java | 8 ++++---- test/transform/resource/after-delombok/Accessors.java | 2 +- test/transform/resource/after-delombok/DataExtended.java | 2 +- test/transform/resource/after-delombok/DataIgnore.java | 2 +- .../resource/after-delombok/DataOnLocalClass.java | 6 +++--- test/transform/resource/after-delombok/DataPlain.java | 8 ++++---- test/transform/resource/after-delombok/DataWithGetter.java | 2 +- .../resource/after-delombok/DataWithGetterNone.java | 2 +- .../resource/after-delombok/EqualsAndHashCode.java | 9 ++++++--- .../EqualsAndHashCodeWithSomeExistingMethods.java | 2 +- .../resource/after-delombok/GetterLazyBoolean.java | 4 ++-- .../resource/after-delombok/GetterLazyEahcToString.java | 2 +- .../resource/after-delombok/GetterSetterJavadoc.java | 2 +- test/transform/resource/after-delombok/ValuePlain.java | 6 +++--- test/transform/resource/after-ecj/Accessors.java | 2 +- test/transform/resource/after-ecj/DataExtended.java | 2 +- test/transform/resource/after-ecj/DataIgnore.java | 2 +- test/transform/resource/after-ecj/DataOnLocalClass.java | 6 +++--- test/transform/resource/after-ecj/DataPlain.java | 8 ++++---- test/transform/resource/after-ecj/DataWithGetter.java | 2 +- test/transform/resource/after-ecj/DataWithGetterNone.java | 2 +- test/transform/resource/after-ecj/EqualsAndHashCode.java | 10 +++++++--- .../EqualsAndHashCodeWithSomeExistingMethods.java | 2 +- test/transform/resource/after-ecj/GetterLazyBoolean.java | 4 ++-- .../resource/after-ecj/GetterLazyEahcToString.java | 2 +- test/transform/resource/after-ecj/GetterSetterJavadoc.java | 2 +- test/transform/resource/after-ecj/ValuePlain.java | 6 +++--- test/transform/resource/before/EqualsAndHashCode.java | 1 + usage_examples/DataExample_post.jpage | 4 ++-- usage_examples/EqualsAndHashCodeExample_post.jpage | 4 ++-- usage_examples/ValueExample_post.jpage | 4 ++-- 34 files changed, 82 insertions(+), 65 deletions(-) (limited to 'test/transform/resource/after-ecj/Accessors.java') diff --git a/doc/changelog.markdown b/doc/changelog.markdown index d4a29177..72291c5b 100644 --- a/doc/changelog.markdown +++ b/doc/changelog.markdown @@ -3,6 +3,7 @@ Lombok Changelog ### v1.12.5 "Edgy Guinea Pig" * DETAIL: {Delombok} Inside enum bodies the delombok formatter didn't respect the emptyLines directive [Issue #529](https://code.google.com/p/projectlombok/issues/detail?id=629). +* DETAIL: Use smaller primes (<127) for generating hashcodes [Issue #625](https://code.google.com/p/projectlombok/issues/detail?id=625) ### v1.12.4 (January 15th, 2014) * BUGFIX: v1.12.2's delombok turns all operator+assignments into just assignment. Fixed. [Issue #598](https://code.google.com/p/projectlombok/issues/detail?id=598) diff --git a/src/core/lombok/core/handlers/HandlerUtil.java b/src/core/lombok/core/handlers/HandlerUtil.java index c8076ab6..23b8ccc7 100644 --- a/src/core/lombok/core/handlers/HandlerUtil.java +++ b/src/core/lombok/core/handlers/HandlerUtil.java @@ -27,9 +27,17 @@ import lombok.core.LombokNode; public class HandlerUtil { private HandlerUtil() {} - public static final int PRIME_FOR_HASHCODE = 277; - public static final int PRIME_FOR_TRUE = 2591; - public static final int PRIME_FOR_FALSE = 2609; + public static int primeForHashcode() { + return 59; + } + + public static int primeForTrue() { + return 79; + } + + public static int primeForFalse() { + return 97; + } /** Checks if the given name is a valid identifier. * diff --git a/src/core/lombok/eclipse/handlers/HandleEqualsAndHashCode.java b/src/core/lombok/eclipse/handlers/HandleEqualsAndHashCode.java index 8d95ca64..0cc0836e 100644 --- a/src/core/lombok/eclipse/handlers/HandleEqualsAndHashCode.java +++ b/src/core/lombok/eclipse/handlers/HandleEqualsAndHashCode.java @@ -272,7 +272,7 @@ public class HandleEqualsAndHashCode extends EclipseAnnotationHandler>> 32 ^ $d); + result = result * PRIME + (this.b ? 79 : 97); return result; } } @@ -111,7 +114,7 @@ class EqualsAndHashCode4 extends EqualsAndHashCode { @java.lang.Override @java.lang.SuppressWarnings("all") public int hashCode() { - final int PRIME = 277; + final int PRIME = 59; int result = 1; result = result * PRIME + super.hashCode(); return result; diff --git a/test/transform/resource/after-delombok/EqualsAndHashCodeWithSomeExistingMethods.java b/test/transform/resource/after-delombok/EqualsAndHashCodeWithSomeExistingMethods.java index e1bdc7f7..aa9b984f 100644 --- a/test/transform/resource/after-delombok/EqualsAndHashCodeWithSomeExistingMethods.java +++ b/test/transform/resource/after-delombok/EqualsAndHashCodeWithSomeExistingMethods.java @@ -69,7 +69,7 @@ class EqualsAndHashCodeWithNoExistingMethods { @java.lang.Override @java.lang.SuppressWarnings("all") public int hashCode() { - final int PRIME = 277; + final int PRIME = 59; int result = 1; result = result * PRIME + this.x; return result; diff --git a/test/transform/resource/after-delombok/GetterLazyBoolean.java b/test/transform/resource/after-delombok/GetterLazyBoolean.java index ba26e7b7..eb6662e2 100644 --- a/test/transform/resource/after-delombok/GetterLazyBoolean.java +++ b/test/transform/resource/after-delombok/GetterLazyBoolean.java @@ -21,9 +21,9 @@ class GetterLazyBoolean { @java.lang.Override @java.lang.SuppressWarnings("all") public int hashCode() { - final int PRIME = 277; + final int PRIME = 59; int result = 1; - result = result * PRIME + (this.isBooleanValue() ? 2609 : 2591); + result = result * PRIME + (this.isBooleanValue() ? 79 : 97); return result; } @java.lang.Override diff --git a/test/transform/resource/after-delombok/GetterLazyEahcToString.java b/test/transform/resource/after-delombok/GetterLazyEahcToString.java index 29e2f51c..3e98a25e 100644 --- a/test/transform/resource/after-delombok/GetterLazyEahcToString.java +++ b/test/transform/resource/after-delombok/GetterLazyEahcToString.java @@ -27,7 +27,7 @@ class GetterLazyEahcToString { @java.lang.Override @java.lang.SuppressWarnings("all") public int hashCode() { - final int PRIME = 277; + final int PRIME = 59; int result = 1; final java.lang.Object $value = this.getValue(); result = result * PRIME + ($value == null ? 0 : $value.hashCode()); diff --git a/test/transform/resource/after-delombok/GetterSetterJavadoc.java b/test/transform/resource/after-delombok/GetterSetterJavadoc.java index 5b12a395..743a3aac 100644 --- a/test/transform/resource/after-delombok/GetterSetterJavadoc.java +++ b/test/transform/resource/after-delombok/GetterSetterJavadoc.java @@ -41,7 +41,7 @@ class GetterSetterJavadoc1 { @java.lang.Override @java.lang.SuppressWarnings("all") public int hashCode() { - final int PRIME = 277; + final int PRIME = 59; int result = 1; result = result * PRIME + this.getFieldName(); return result; diff --git a/test/transform/resource/after-delombok/ValuePlain.java b/test/transform/resource/after-delombok/ValuePlain.java index af87d1ba..e880454b 100644 --- a/test/transform/resource/after-delombok/ValuePlain.java +++ b/test/transform/resource/after-delombok/ValuePlain.java @@ -30,7 +30,7 @@ final class Value1 { @java.lang.Override @java.lang.SuppressWarnings("all") public int hashCode() { - final int PRIME = 277; + final int PRIME = 59; int result = 1; result = result * PRIME + this.getX(); final java.lang.Object $name = this.getName(); @@ -80,7 +80,7 @@ class Value2 { @java.lang.Override @java.lang.SuppressWarnings("all") public int hashCode() { - final int PRIME = 277; + final int PRIME = 59; int result = 1; result = result * PRIME + this.getX(); final java.lang.Object $name = this.getName(); @@ -123,7 +123,7 @@ final class Value3 { @java.lang.Override @java.lang.SuppressWarnings("all") public int hashCode() { - final int PRIME = 277; + final int PRIME = 59; int result = 1; result = result * PRIME + this.getX(); result = result * PRIME + this.getY(); diff --git a/test/transform/resource/after-ecj/Accessors.java b/test/transform/resource/after-ecj/Accessors.java index 52a72d52..c8fdc3bf 100644 --- a/test/transform/resource/after-ecj/Accessors.java +++ b/test/transform/resource/after-ecj/Accessors.java @@ -90,7 +90,7 @@ class AccessorsChain { return (other instanceof AccessorsPrefix3); } public @java.lang.Override @java.lang.SuppressWarnings("all") int hashCode() { - final int PRIME = 277; + final int PRIME = 59; int result = 1; final java.lang.Object $fName = this.getName(); result = ((result * PRIME) + (($fName == null) ? 0 : $fName.hashCode())); diff --git a/test/transform/resource/after-ecj/DataExtended.java b/test/transform/resource/after-ecj/DataExtended.java index 35a7ca34..bcfd26e3 100644 --- a/test/transform/resource/after-ecj/DataExtended.java +++ b/test/transform/resource/after-ecj/DataExtended.java @@ -22,7 +22,7 @@ return (other instanceof DataExtended); } public @java.lang.Override @java.lang.SuppressWarnings("all") int hashCode() { - final int PRIME = 277; + final int PRIME = 59; int result = 1; result = ((result * PRIME) + this.getX()); return result; diff --git a/test/transform/resource/after-ecj/DataIgnore.java b/test/transform/resource/after-ecj/DataIgnore.java index 4a3c051b..d0e72e15 100644 --- a/test/transform/resource/after-ecj/DataIgnore.java +++ b/test/transform/resource/after-ecj/DataIgnore.java @@ -20,7 +20,7 @@ return (other instanceof DataIgnore); } public @java.lang.Override @java.lang.SuppressWarnings("all") int hashCode() { - final int PRIME = 277; + final int PRIME = 59; int result = 1; result = ((result * PRIME) + this.getX()); return result; diff --git a/test/transform/resource/after-ecj/DataOnLocalClass.java b/test/transform/resource/after-ecj/DataOnLocalClass.java index 4a247542..511291c2 100644 --- a/test/transform/resource/after-ecj/DataOnLocalClass.java +++ b/test/transform/resource/after-ecj/DataOnLocalClass.java @@ -36,7 +36,7 @@ class DataOnLocalClass1 { return (other instanceof Local); } public @java.lang.Override @java.lang.SuppressWarnings("all") int hashCode() { - final int PRIME = 277; + final int PRIME = 59; int result = 1; result = ((result * PRIME) + this.getX()); final java.lang.Object $name = this.getName(); @@ -86,7 +86,7 @@ class DataOnLocalClass2 { return (other instanceof Local.InnerLocal); } public @java.lang.Override @java.lang.SuppressWarnings("all") int hashCode() { - final int PRIME = 277; + final int PRIME = 59; int result = 1; final java.lang.Object $name = this.getName(); result = ((result * PRIME) + (($name == null) ? 0 : $name.hashCode())); @@ -124,7 +124,7 @@ class DataOnLocalClass2 { return (other instanceof Local); } public @java.lang.Override @java.lang.SuppressWarnings("all") int hashCode() { - final int PRIME = 277; + final int PRIME = 59; int result = 1; result = ((result * PRIME) + this.getX()); return result; diff --git a/test/transform/resource/after-ecj/DataPlain.java b/test/transform/resource/after-ecj/DataPlain.java index 2105c6f2..aa47fdaa 100644 --- a/test/transform/resource/after-ecj/DataPlain.java +++ b/test/transform/resource/after-ecj/DataPlain.java @@ -31,7 +31,7 @@ import lombok.Data; return (other instanceof Data1); } public @java.lang.Override @java.lang.SuppressWarnings("all") int hashCode() { - final int PRIME = 277; + final int PRIME = 59; int result = 1; result = ((result * PRIME) + this.getX()); final java.lang.Object $name = this.getName(); @@ -78,7 +78,7 @@ import lombok.Data; return (other instanceof Data2); } public @java.lang.Override @java.lang.SuppressWarnings("all") int hashCode() { - final int PRIME = 277; + final int PRIME = 59; int result = 1; result = ((result * PRIME) + this.getX()); final java.lang.Object $name = this.getName(); @@ -120,7 +120,7 @@ final @Data class Data3 { return true; } public @java.lang.Override @java.lang.SuppressWarnings("all") int hashCode() { - final int PRIME = 277; + final int PRIME = 59; int result = 1; result = ((result * PRIME) + this.getX()); final java.lang.Object $name = this.getName(); @@ -167,7 +167,7 @@ final @Data @lombok.EqualsAndHashCode(callSuper = true) class Data4 extends java return (other instanceof Data4); } public @java.lang.Override @java.lang.SuppressWarnings("all") int hashCode() { - final int PRIME = 277; + final int PRIME = 59; int result = 1; result = ((result * PRIME) + super.hashCode()); result = ((result * PRIME) + this.getX()); diff --git a/test/transform/resource/after-ecj/DataWithGetter.java b/test/transform/resource/after-ecj/DataWithGetter.java index 9676e851..2ce74ceb 100644 --- a/test/transform/resource/after-ecj/DataWithGetter.java +++ b/test/transform/resource/after-ecj/DataWithGetter.java @@ -30,7 +30,7 @@ return (other instanceof DataWithGetter); } public @java.lang.Override @java.lang.SuppressWarnings("all") int hashCode() { - final int PRIME = 277; + final int PRIME = 59; int result = 1; result = ((result * PRIME) + this.getX()); result = ((result * PRIME) + this.getY()); diff --git a/test/transform/resource/after-ecj/DataWithGetterNone.java b/test/transform/resource/after-ecj/DataWithGetterNone.java index d5e190d8..087d0762 100644 --- a/test/transform/resource/after-ecj/DataWithGetterNone.java +++ b/test/transform/resource/after-ecj/DataWithGetterNone.java @@ -30,7 +30,7 @@ return (other instanceof DataWithGetterNone); } public @java.lang.Override @java.lang.SuppressWarnings("all") int hashCode() { - final int PRIME = 277; + final int PRIME = 59; int result = 1; result = ((result * PRIME) + this.x); result = ((result * PRIME) + this.y); diff --git a/test/transform/resource/after-ecj/EqualsAndHashCode.java b/test/transform/resource/after-ecj/EqualsAndHashCode.java index 492f9344..625a0f87 100644 --- a/test/transform/resource/after-ecj/EqualsAndHashCode.java +++ b/test/transform/resource/after-ecj/EqualsAndHashCode.java @@ -35,7 +35,7 @@ return (other instanceof EqualsAndHashCode); } public @java.lang.Override @java.lang.SuppressWarnings("all") int hashCode() { - final int PRIME = 277; + final int PRIME = 59; int result = 1; result = ((result * PRIME) + this.x); result = ((result * PRIME) + java.util.Arrays.hashCode(this.y)); @@ -52,6 +52,7 @@ final @lombok.EqualsAndHashCode class EqualsAndHashCode2 { long y; float f; double d; + boolean b; EqualsAndHashCode2() { super(); } @@ -69,10 +70,12 @@ final @lombok.EqualsAndHashCode class EqualsAndHashCode2 { return false; if ((java.lang.Double.compare(this.d, other.d) != 0)) return false; + if ((this.b != other.b)) + return false; return true; } public @java.lang.Override @java.lang.SuppressWarnings("all") int hashCode() { - final int PRIME = 277; + final int PRIME = 59; int result = 1; result = ((result * PRIME) + this.x); final long $y = this.y; @@ -80,6 +83,7 @@ final @lombok.EqualsAndHashCode class EqualsAndHashCode2 { result = ((result * PRIME) + java.lang.Float.floatToIntBits(this.f)); final long $d = java.lang.Double.doubleToLongBits(this.d); result = ((result * PRIME) + (int) ($d ^ ($d >>> 32))); + result = ((result * PRIME) + (this.b ? 79 : 97)); return result; } } @@ -125,7 +129,7 @@ final @lombok.EqualsAndHashCode(callSuper = false) class EqualsAndHashCode3 exte return (other instanceof EqualsAndHashCode4); } public @java.lang.Override @java.lang.SuppressWarnings("all") int hashCode() { - final int PRIME = 277; + final int PRIME = 59; int result = 1; result = ((result * PRIME) + super.hashCode()); return result; diff --git a/test/transform/resource/after-ecj/EqualsAndHashCodeWithSomeExistingMethods.java b/test/transform/resource/after-ecj/EqualsAndHashCodeWithSomeExistingMethods.java index 83878675..05f7ad97 100644 --- a/test/transform/resource/after-ecj/EqualsAndHashCodeWithSomeExistingMethods.java +++ b/test/transform/resource/after-ecj/EqualsAndHashCodeWithSomeExistingMethods.java @@ -57,7 +57,7 @@ import static lombok.AccessLevel.NONE; return (other instanceof EqualsAndHashCodeWithNoExistingMethods); } public @java.lang.Override @java.lang.SuppressWarnings("all") int hashCode() { - final int PRIME = 277; + final int PRIME = 59; int result = 1; result = ((result * PRIME) + this.x); return result; diff --git a/test/transform/resource/after-ecj/GetterLazyBoolean.java b/test/transform/resource/after-ecj/GetterLazyBoolean.java index d3b257a7..c37eece2 100644 --- a/test/transform/resource/after-ecj/GetterLazyBoolean.java +++ b/test/transform/resource/after-ecj/GetterLazyBoolean.java @@ -57,9 +57,9 @@ return (other instanceof GetterLazyBoolean); } public @java.lang.Override @java.lang.SuppressWarnings("all") int hashCode() { - final int PRIME = 277; + final int PRIME = 59; int result = 1; - result = ((result * PRIME) + (this.isBooleanValue() ? 2609 : 2591)); + result = ((result * PRIME) + (this.isBooleanValue() ? 79 : 97)); return result; } public @java.lang.Override @java.lang.SuppressWarnings("all") java.lang.String toString() { diff --git a/test/transform/resource/after-ecj/GetterLazyEahcToString.java b/test/transform/resource/after-ecj/GetterLazyEahcToString.java index d8a90350..da9f6a83 100644 --- a/test/transform/resource/after-ecj/GetterLazyEahcToString.java +++ b/test/transform/resource/after-ecj/GetterLazyEahcToString.java @@ -46,7 +46,7 @@ return (other instanceof GetterLazyEahcToString); } public @java.lang.Override @java.lang.SuppressWarnings("all") int hashCode() { - final int PRIME = 277; + final int PRIME = 59; int result = 1; final java.lang.Object $value = this.getValue(); result = ((result * PRIME) + (($value == null) ? 0 : $value.hashCode())); diff --git a/test/transform/resource/after-ecj/GetterSetterJavadoc.java b/test/transform/resource/after-ecj/GetterSetterJavadoc.java index 10d9a0be..b7fc15b8 100644 --- a/test/transform/resource/after-ecj/GetterSetterJavadoc.java +++ b/test/transform/resource/after-ecj/GetterSetterJavadoc.java @@ -22,7 +22,7 @@ return (other instanceof GetterSetterJavadoc1); } public @java.lang.Override @java.lang.SuppressWarnings("all") int hashCode() { - final int PRIME = 277; + final int PRIME = 59; int result = 1; result = ((result * PRIME) + this.getFieldName()); return result; diff --git a/test/transform/resource/after-ecj/ValuePlain.java b/test/transform/resource/after-ecj/ValuePlain.java index a23944de..5ca32af8 100644 --- a/test/transform/resource/after-ecj/ValuePlain.java +++ b/test/transform/resource/after-ecj/ValuePlain.java @@ -23,7 +23,7 @@ final @lombok.Value class Value1 { return true; } public @java.lang.Override @java.lang.SuppressWarnings("all") int hashCode() { - final int PRIME = 277; + final int PRIME = 59; int result = 1; result = ((result * PRIME) + this.getX()); final java.lang.Object $name = this.getName(); @@ -68,7 +68,7 @@ final @lombok.Value class Value1 { return (other instanceof Value2); } public @java.lang.Override @java.lang.SuppressWarnings("all") int hashCode() { - final int PRIME = 277; + final int PRIME = 59; int result = 1; result = ((result * PRIME) + this.getX()); final java.lang.Object $name = this.getName(); @@ -106,7 +106,7 @@ final @Value class Value3 { return true; } public @java.lang.Override @java.lang.SuppressWarnings("all") int hashCode() { - final int PRIME = 277; + final int PRIME = 59; int result = 1; result = ((result * PRIME) + this.getX()); result = ((result * PRIME) + this.getY()); diff --git a/test/transform/resource/before/EqualsAndHashCode.java b/test/transform/resource/before/EqualsAndHashCode.java index 0a1e3290..660f923a 100644 --- a/test/transform/resource/before/EqualsAndHashCode.java +++ b/test/transform/resource/before/EqualsAndHashCode.java @@ -13,6 +13,7 @@ final class EqualsAndHashCode2 { long y; float f; double d; + boolean b; } @lombok.EqualsAndHashCode(callSuper=false) diff --git a/usage_examples/DataExample_post.jpage b/usage_examples/DataExample_post.jpage index 896839de..29e7e328 100644 --- a/usage_examples/DataExample_post.jpage +++ b/usage_examples/DataExample_post.jpage @@ -55,7 +55,7 @@ public class DataExample { } @Override public int hashCode() { - final int PRIME = 277; + final int PRIME = 59; int result = 1; final long temp1 = Double.doubleToLongBits(this.getScore()); result = (result*PRIME) + (this.getName() == null ? 0 : this.getName().hashCode()); @@ -101,7 +101,7 @@ public class DataExample { } @Override public int hashCode() { - final int PRIME = 277; + final int PRIME = 59; int result = 1; result = (result*PRIME) + (this.getName() == null ? 0 : this.getName().hashCode()); result = (result*PRIME) + (this.getValue() == null ? 0 : this.getValue().hashCode()); diff --git a/usage_examples/EqualsAndHashCodeExample_post.jpage b/usage_examples/EqualsAndHashCodeExample_post.jpage index 57191f55..aa6a44ba 100644 --- a/usage_examples/EqualsAndHashCodeExample_post.jpage +++ b/usage_examples/EqualsAndHashCodeExample_post.jpage @@ -24,7 +24,7 @@ public class EqualsAndHashCodeExample { } @Override public int hashCode() { - final int PRIME = 277; + final int PRIME = 59; int result = 1; final long temp1 = Double.doubleToLongBits(this.score); result = (result*PRIME) + (this.name == null ? 0 : this.name.hashCode()); @@ -57,7 +57,7 @@ public class EqualsAndHashCodeExample { } @Override public int hashCode() { - final int PRIME = 277; + final int PRIME = 59; int result = 1; result = (result*PRIME) + super.hashCode(); result = (result*PRIME) + this.width; diff --git a/usage_examples/ValueExample_post.jpage b/usage_examples/ValueExample_post.jpage index c5971262..4ac8654e 100644 --- a/usage_examples/ValueExample_post.jpage +++ b/usage_examples/ValueExample_post.jpage @@ -46,7 +46,7 @@ public final class ValueExample { @java.lang.Override public int hashCode() { - final int PRIME = 277; + final int PRIME = 59; int result = 1; final Object $name = this.getName(); result = result * PRIME + ($name == null ? 0 : $name.hashCode()); @@ -103,7 +103,7 @@ public final class ValueExample { @java.lang.Override public int hashCode() { - final int PRIME = 277; + final int PRIME = 59; int result = 1; final Object $name = this.getName(); result = result * PRIME + ($name == null ? 0 : $name.hashCode()); -- cgit