Package org.cip4.jdflib.util
Class HashUtil
java.lang.Object
org.cip4.jdflib.util.HashUtil
This class provides some hashCode calculation utilities. Use the static methods of this class to generate
Hint: Start your hashCode calculation depending on the object your data object extends. If you extend Object initialize your hash value to 0. Otherwise initialize hash to super.hashCode(). See the example code.
hashCode()values in data objects. For example, to calculate the hashCode of a data object, use the methods of this class as follows:
int myIntField;
Object myObject;
public int hashCode()
{
// int hash = super.hashCode(); // use when not extending Object
int hash = 0; // use when extending Object
hash = HashUtil.hashCode(hash, myIntField);
hash = HashUtil.hashCode(hash, myObject);
return hash;
}
Hint: Start your hashCode calculation depending on the object your data object extends. If you extend Object initialize your hash value to 0. Otherwise initialize hash to super.hashCode(). See the example code.
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic final inthashCode(int source, boolean x) static final inthashCode(int source, double x) static final inthashCode(int source, float x) static final inthashCode(int source, int x) static final inthashCode(int source, long x) static final intstatic final intstatic final inthashCode(int source, Collection<?> c)
-
Field Details
-
PRIME
public static final int PRIME- See Also:
-
-
Method Details
-
hashCode
public static final int hashCode(int source, boolean x) - Parameters:
source-x-- Returns:
-
hashCode
public static final int hashCode(int source, int x) - Parameters:
source-x-- Returns:
-
hashCode
public static final int hashCode(int source, long x) - Parameters:
source-x-- Returns:
-
hashCode
public static final int hashCode(int source, float x) - Parameters:
source-x-- Returns:
-
hashCode
public static final int hashCode(int source, double x) - Parameters:
source-x-- Returns:
-
hashCode
- Parameters:
source-x-- Returns:
-
hashCode
- Parameters:
source-c-- Returns:
-
hashCode
- Parameters:
source-x-- Returns:
-