aboutsummaryrefslogtreecommitdiff
path: root/usage_examples/DataExample_post.jpage
diff options
context:
space:
mode:
authorReinier Zwitserloot <reinier@zwitserloot.com>2015-06-25 00:13:12 +0200
committerReinier Zwitserloot <reinier@zwitserloot.com>2015-06-25 00:13:12 +0200
commit251fd03cd78ef6996d4252450bda596a5e8b11b9 (patch)
tree6cd9f4a8510ffabed01cd5eae60c0e1b6f2d2b35 /usage_examples/DataExample_post.jpage
parent23dcc9f5a5f3c24ccfb2f98ab556daed0dee3c89 (diff)
downloadlombok-251fd03cd78ef6996d4252450bda596a5e8b11b9.tar.gz
lombok-251fd03cd78ef6996d4252450bda596a5e8b11b9.tar.bz2
lombok-251fd03cd78ef6996d4252450bda596a5e8b11b9.zip
The hashCode() method now generates a magic prime instead of 0 for the hash of null values; this reduces collisions.
Diffstat (limited to 'usage_examples/DataExample_post.jpage')
-rw-r--r--usage_examples/DataExample_post.jpage6
1 files changed, 3 insertions, 3 deletions
diff --git a/usage_examples/DataExample_post.jpage b/usage_examples/DataExample_post.jpage
index e53e999c..bef0a0f1 100644
--- a/usage_examples/DataExample_post.jpage
+++ b/usage_examples/DataExample_post.jpage
@@ -62,7 +62,7 @@ public class DataExample {
final int PRIME = 59;
int result = 1;
final long temp1 = Double.doubleToLongBits(this.getScore());
- result = (result*PRIME) + (this.getName() == null ? 0 : this.getName().hashCode());
+ result = (result*PRIME) + (this.getName() == null ? 43 : this.getName().hashCode());
result = (result*PRIME) + this.getAge();
result = (result*PRIME) + (int)(temp1 ^ (temp1 >>> 32));
result = (result*PRIME) + Arrays.deepHashCode(this.getTags());
@@ -111,8 +111,8 @@ public class DataExample {
@Override public int hashCode() {
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());
+ result = (result*PRIME) + (this.getName() == null ? 43 : this.getName().hashCode());
+ result = (result*PRIME) + (this.getValue() == null ? 43 : this.getValue().hashCode());
return result;
}
}