diff options
author | Reinier Zwitserloot <reinier@zwitserloot.com> | 2014-01-09 21:00:44 +0100 |
---|---|---|
committer | Reinier Zwitserloot <reinier@zwitserloot.com> | 2014-01-09 21:24:04 +0100 |
commit | a40a86ad532881acd311200a665b5f55790c55cc (patch) | |
tree | 653880e9aa8078c42a86cf0a7a184bd040e87308 /usage_examples | |
parent | 685ddfd52ebba4ca85ff93e08de14f38ecd8714b (diff) | |
download | lombok-a40a86ad532881acd311200a665b5f55790c55cc.tar.gz lombok-a40a86ad532881acd311200a665b5f55790c55cc.tar.bz2 lombok-a40a86ad532881acd311200a665b5f55790c55cc.zip |
[#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.
Diffstat (limited to 'usage_examples')
-rw-r--r-- | usage_examples/DataExample_post.jpage | 4 | ||||
-rw-r--r-- | usage_examples/EqualsAndHashCodeExample_post.jpage | 4 | ||||
-rw-r--r-- | usage_examples/ValueExample_post.jpage | 4 |
3 files changed, 6 insertions, 6 deletions
diff --git a/usage_examples/DataExample_post.jpage b/usage_examples/DataExample_post.jpage index 3dc675e9..896839de 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 = 31; + final int PRIME = 277; 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 = 31; + final int PRIME = 277; 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 4a90e7dc..57191f55 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 = 31; + final int PRIME = 277; 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 = 31; + final int PRIME = 277; 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 ac9b64d1..c5971262 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 = 31; + final int PRIME = 277; 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 = 31; + final int PRIME = 277; int result = 1; final Object $name = this.getName(); result = result * PRIME + ($name == null ? 0 : $name.hashCode()); |