aboutsummaryrefslogtreecommitdiff
path: root/usage_examples/ValueExample_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/ValueExample_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/ValueExample_post.jpage')
-rw-r--r--usage_examples/ValueExample_post.jpage6
1 files changed, 3 insertions, 3 deletions
diff --git a/usage_examples/ValueExample_post.jpage b/usage_examples/ValueExample_post.jpage
index 4ac8654e..8a5d4836 100644
--- a/usage_examples/ValueExample_post.jpage
+++ b/usage_examples/ValueExample_post.jpage
@@ -49,7 +49,7 @@ public final class ValueExample {
final int PRIME = 59;
int result = 1;
final Object $name = this.getName();
- result = result * PRIME + ($name == null ? 0 : $name.hashCode());
+ result = result * PRIME + ($name == null ? 43 : $name.hashCode());
result = result * PRIME + this.getAge();
final long $score = Double.doubleToLongBits(this.getScore());
result = result * PRIME + (int)($score >>> 32 ^ $score);
@@ -106,9 +106,9 @@ public final class ValueExample {
final int PRIME = 59;
int result = 1;
final Object $name = this.getName();
- result = result * PRIME + ($name == null ? 0 : $name.hashCode());
+ result = result * PRIME + ($name == null ? 43 : $name.hashCode());
final Object $value = this.getValue();
- result = result * PRIME + ($value == null ? 0 : $value.hashCode());
+ result = result * PRIME + ($value == null ? 43 : $value.hashCode());
return result;
}