Class HashCodeBuilder
Object.hashCode() methods. The code is based on
HashCodeBuilder from commons-lang 2.1.- Since:
- 3.0
-
Constructor Summary
ConstructorsConstructorDescriptionDeprecated, for removal: This API element is subject to removal in a future version.Uses two hard coded choices for the constants needed to build ahashCode.HashCodeBuilder(int initialNonZeroOddNumber, int multiplierNonZeroOddNumber) Deprecated, for removal: This API element is subject to removal in a future version.Two randomly chosen, non-zero, odd numbers must be passed in. -
Method Summary
Modifier and TypeMethodDescriptionappend(boolean value) Deprecated, for removal: This API element is subject to removal in a future version.Append ahashCodefor aboolean.append(boolean[] array) Deprecated, for removal: This API element is subject to removal in a future version.Append ahashCodefor abooleanarray.append(byte value) Deprecated, for removal: This API element is subject to removal in a future version.Append ahashCodefor abyte.append(byte[] array) Deprecated, for removal: This API element is subject to removal in a future version.Append ahashCodefor abytearray.append(char value) Deprecated, for removal: This API element is subject to removal in a future version.Append ahashCodefor achar.append(char[] array) Deprecated, for removal: This API element is subject to removal in a future version.Append ahashCodefor achararray.append(double value) Deprecated, for removal: This API element is subject to removal in a future version.Append ahashCodefor adouble.append(double[] array) Deprecated, for removal: This API element is subject to removal in a future version.Append ahashCodefor adoublearray.append(float value) Deprecated, for removal: This API element is subject to removal in a future version.Append ahashCodefor afloat.append(float[] array) Deprecated, for removal: This API element is subject to removal in a future version.Append ahashCodefor afloatarray.append(int value) Deprecated, for removal: This API element is subject to removal in a future version.Append ahashCodefor anint.append(int[] array) Deprecated, for removal: This API element is subject to removal in a future version.Append ahashCodefor anintarray.append(long value) Deprecated, for removal: This API element is subject to removal in a future version.Append ahashCodefor along.append(long[] array) Deprecated, for removal: This API element is subject to removal in a future version.Append ahashCodefor alongarray.append(short value) Deprecated, for removal: This API element is subject to removal in a future version.Append ahashCodefor ashort.append(short[] array) Deprecated, for removal: This API element is subject to removal in a future version.Append ahashCodefor ashortarray.Deprecated, for removal: This API element is subject to removal in a future version.Append ahashCodefor anObject.Deprecated, for removal: This API element is subject to removal in a future version.Append ahashCodefor anObjectarray.appendSuper(int superHashCode) Deprecated, for removal: This API element is subject to removal in a future version.Adds the result of super.hashCode() to this builder.intDeprecated, for removal: This API element is subject to removal in a future version.Return the computedhashCode.
-
Constructor Details
-
HashCodeBuilder
public HashCodeBuilder()Deprecated, for removal: This API element is subject to removal in a future version.Uses two hard coded choices for the constants needed to build a
hashCode. -
HashCodeBuilder
public HashCodeBuilder(int initialNonZeroOddNumber, int multiplierNonZeroOddNumber) Deprecated, for removal: This API element is subject to removal in a future version.Two randomly chosen, non-zero, odd numbers must be passed in. Ideally these should be different for each class, however this is not vital.
Prime numbers are preferred, especially for the multiplier.
- Parameters:
initialNonZeroOddNumber- a non-zero, odd number used as the initial valuemultiplierNonZeroOddNumber- a non-zero, odd number used as the multiplier- Throws:
IllegalArgumentException- if the number is zero or even
-
-
Method Details
-
appendSuper
Deprecated, for removal: This API element is subject to removal in a future version.Adds the result of super.hashCode() to this builder.
- Parameters:
superHashCode- the result of callingsuper.hashCode()- Returns:
- this HashCodeBuilder, used to chain calls.
- Since:
- 2.0
-
append
Deprecated, for removal: This API element is subject to removal in a future version.Append a
hashCodefor anObject.- Parameters:
object- the Object to add to thehashCode- Returns:
- this
-
append
Deprecated, for removal: This API element is subject to removal in a future version.Append a
hashCodefor along.- Parameters:
value- the long to add to thehashCode- Returns:
- this
-
append
Deprecated, for removal: This API element is subject to removal in a future version.Append a
hashCodefor anint.- Parameters:
value- the int to add to thehashCode- Returns:
- this
-
append
Deprecated, for removal: This API element is subject to removal in a future version.Append a
hashCodefor ashort.- Parameters:
value- the short to add to thehashCode- Returns:
- this
-
append
Deprecated, for removal: This API element is subject to removal in a future version.Append a
hashCodefor achar.- Parameters:
value- the char to add to thehashCode- Returns:
- this
-
append
Deprecated, for removal: This API element is subject to removal in a future version.Append a
hashCodefor abyte.- Parameters:
value- the byte to add to thehashCode- Returns:
- this
-
append
Deprecated, for removal: This API element is subject to removal in a future version.Append a
hashCodefor adouble.- Parameters:
value- the double to add to thehashCode- Returns:
- this
-
append
Deprecated, for removal: This API element is subject to removal in a future version.Append a
hashCodefor afloat.- Parameters:
value- the float to add to thehashCode- Returns:
- this
-
append
Deprecated, for removal: This API element is subject to removal in a future version.Append a
hashCodefor aboolean.This adds
iConstant * 1to thehashCodeand not a1231or1237as done in java.lang.Boolean. This is in accordance with the Effective Java design.- Parameters:
value- the boolean to add to thehashCode- Returns:
- this
-
append
Deprecated, for removal: This API element is subject to removal in a future version.Append a
hashCodefor anObjectarray.- Parameters:
array- the array to add to thehashCode- Returns:
- this
-
append
Deprecated, for removal: This API element is subject to removal in a future version.Append a
hashCodefor alongarray.- Parameters:
array- the array to add to thehashCode- Returns:
- this
-
append
Deprecated, for removal: This API element is subject to removal in a future version.Append a
hashCodefor anintarray.- Parameters:
array- the array to add to thehashCode- Returns:
- this
-
append
Deprecated, for removal: This API element is subject to removal in a future version.Append a
hashCodefor ashortarray.- Parameters:
array- the array to add to thehashCode- Returns:
- this
-
append
Deprecated, for removal: This API element is subject to removal in a future version.Append a
hashCodefor achararray.- Parameters:
array- the array to add to thehashCode- Returns:
- this
-
append
Deprecated, for removal: This API element is subject to removal in a future version.Append a
hashCodefor abytearray.- Parameters:
array- the array to add to thehashCode- Returns:
- this
-
append
Deprecated, for removal: This API element is subject to removal in a future version.Append a
hashCodefor adoublearray.- Parameters:
array- the array to add to thehashCode- Returns:
- this
-
append
Deprecated, for removal: This API element is subject to removal in a future version.Append a
hashCodefor afloatarray.- Parameters:
array- the array to add to thehashCode- Returns:
- this
-
append
Deprecated, for removal: This API element is subject to removal in a future version.Append a
hashCodefor abooleanarray.- Parameters:
array- the array to add to thehashCode- Returns:
- this
-
toHashCode
public int toHashCode()Deprecated, for removal: This API element is subject to removal in a future version.Return the computed
hashCode.- Returns:
hashCodebased on the fields appended
-
Objects.hash(Object...)or a manual31 * h + Objects.hashCode(x)loop