Java Utililty Methods Object Hash

List of utility methods to do Object Hash

Description

The list of methods to do Object Hash are organized into topic(s).

Method

inthashCode(Object o)

Return a proper hashCode for the given object.

if (o instanceof boolean[]) {
    return Arrays.hashCode((boolean[]) o);
} else if (o instanceof byte[]) {
    return Arrays.hashCode((byte[]) o);
} else if (o instanceof short[]) {
    return Arrays.hashCode((short[]) o);
} else if (o instanceof char[]) {
    return Arrays.hashCode((char[]) o);
...
inthashCode(Object obj)
Returns a hash code for an object handling null.
if (obj == null) {
    return 0;
if (obj.getClass().isArray()) {
    if (obj instanceof Object[]) {
        return Arrays.deepHashCode((Object[]) obj);
    } else if (obj instanceof int[]) {
        return Arrays.hashCode((int[]) obj);
...
inthashCode(Object obj)
Returns a hash code for obj .
if (obj == null) {
    return 0;
final Class<?> clazz = obj.getClass();
if (!clazz.isArray()) {
    return obj.hashCode();
final Class<?> componentType = clazz.getComponentType();
...
inthashCode(Object object)
hash Code
if (object == null) {
    return 0;
} else if (object instanceof Object[]) {
    return Arrays.deepHashCode((Object[]) object);
} else if (object instanceof int[]) {
    return Arrays.hashCode((int[]) object);
} else if (object instanceof long[]) {
    return Arrays.hashCode((long[]) object);
...
inthashCode(Object... args)
Returns the hash code of 'args'.
return java.util.Arrays.hashCode(args);
inthashCode(Object... objects)
Returns the hash code value for the given objects , or 0 if it's null .
if (objects == null) {
    return 0;
} else if (objects.length == 1) {
    Object object = objects[0];
    return object == null ? 0 : object.hashCode();
} else {
    return Arrays.hashCode(objects);
intmakeHashCode(Object... objects)
This belongs in a utility class.
return makeHashCode(Arrays.asList(objects));
intsafeHashCode(Object o)
Returns the hash-code of the specified object.
int hash = 1;
if (o != null) {
    if (o.getClass().isArray())
        return Arrays.deepHashCode((Object[]) o);
    else
        hash = o.hashCode();
return hash;
...
intsafeHashCode(Object... objects)
safe Hash Code
return Arrays.hashCode(objects);