-
Notifications
You must be signed in to change notification settings - Fork 0
Home
Mohammad Badar Hashimi edited this page Jan 13, 2020
·
1 revision
This library provides HashCodeBuilder which is referred to build a good hashCode method for any class.
The following is the approach taken. When appending a data field, the current total is multiplied by the multiplier then a relevant value for that data type is added. For example, if the current hashCode is 17, and the multiplier is 37, then appending the integer 45 will create a hash code of 674, namely 17 * 37 + 45.
- append: Append a hashCode for a boolean. This adds 1 when true, and 0 when false to the hashCode. This is in contrast to the standard java.lang.Boolean.hashCode handling, which computes a hashCode value of 1231 for java.lang.Boolean instances that represent true or 1237 for java.lang.Boolean instances that represent false. This is in accordance with the Effective Java design.
- appendArray: Append a hashCode for an array.
- toHash: Return the computed hashCode.