Package org.mule.metadata.internal.utils
Class EfficientHashCode
- java.lang.Object
-
- org.mule.metadata.internal.utils.EfficientHashCode
-
- All Implemented Interfaces:
org.apache.commons.lang3.builder.Builder<Integer>
public class EfficientHashCode extends Object implements org.apache.commons.lang3.builder.Builder<Integer>
A more efficient version ofHashCodeBuilder.reflectionHashCode(Object, boolean). Extracts the fields of the classes to hash via theFieldsComparableclass when possible.- Since:
- 1.3
-
-
Constructor Summary
Constructors Constructor Description EfficientHashCode()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description EfficientHashCodeappend(boolean value)Append ahashCodefor aboolean.EfficientHashCodeappend(byte value)Append ahashCodefor abyte.EfficientHashCodeappend(char value)Append ahashCodefor achar.EfficientHashCodeappend(double value)Append ahashCodefor adouble.EfficientHashCodeappend(float value)Append ahashCodefor afloat.EfficientHashCodeappend(int value)Append ahashCodefor anint.EfficientHashCodeappend(long value)Append ahashCodefor along.EfficientHashCodeappend(short value)Append ahashCodefor ashort.EfficientHashCodeappend(Object object)Append ahashCodefor anObject.Integerbuild()Returns the computedhashCode.static intefficientHashcode(FieldsComparable object)
-
-
-
Method Detail
-
efficientHashcode
public static int efficientHashcode(FieldsComparable object)
-
append
public EfficientHashCode append(boolean value)
Append a
hashCodefor aboolean.This adds
1when true, and0when false to thehashCode.This is in contrast to the standard
java.lang.Boolean.hashCodehandling, which computes ahashCodevalue of1231forjava.lang.Booleaninstances that representtrueor1237forjava.lang.Booleaninstances that representfalse.This is in accordance with the Effective Java design.
- Parameters:
value- the boolean to add to thehashCode- Returns:
- this
-
append
public EfficientHashCode append(byte value)
Append a
hashCodefor abyte.- Parameters:
value- the byte to add to thehashCode- Returns:
- this
-
append
public EfficientHashCode append(char value)
Append a
hashCodefor achar.- Parameters:
value- the char to add to thehashCode- Returns:
- this
-
append
public EfficientHashCode append(double value)
Append a
hashCodefor adouble.- Parameters:
value- the double to add to thehashCode- Returns:
- this
-
append
public EfficientHashCode append(float value)
Append a
hashCodefor afloat.- Parameters:
value- the float to add to thehashCode- Returns:
- this
-
append
public EfficientHashCode append(int value)
Append a
hashCodefor anint.- Parameters:
value- the int to add to thehashCode- Returns:
- this
-
append
public EfficientHashCode append(long value)
Append a
hashCodefor along.- Parameters:
value- the long to add to thehashCode- Returns:
- this
-
append
public EfficientHashCode append(Object object)
Append a
hashCodefor anObject.- Parameters:
object- the Object to add to thehashCode- Returns:
- this
-
append
public EfficientHashCode append(short value)
Append a
hashCodefor ashort.- Parameters:
value- the short to add to thehashCode- Returns:
- this
-
-