public final class

HashCodeUtil

extends Object
java.lang.Object
   ↳ org.mybatis.generator.internal.util.HashCodeUtil

Class Overview

This class is from javapractices.com: http://www.javapractices.com/Topic28.cjp Collected methods which allow easy implementation of hashCode. Example use case:

 public int hashCode() {
     int result = HashCodeUtil.SEED;
     //collect the contributions of various fields
     result = HashCodeUtil.hash(result, fPrimitive);
     result = HashCodeUtil.hash(result, fObject);
     result = HashCodeUtil.hash(result, fArray);
     return result;
 }
 

Summary

Constants
int SEED An initial value for a hashCode, to which is added contributions from fields.
Public Constructors
HashCodeUtil()
Public Methods
static int hash(int aSeed, boolean aBoolean)
booleans.
static int hash(int aSeed, char aChar)
chars.
static int hash(int aSeed, double aDouble)
doubles.
static int hash(int aSeed, float aFloat)
floats.
static int hash(int aSeed, int aInt)
ints.
static int hash(int aSeed, Object aObject)
aObject is a possibly-null object field, and possibly an array.
static int hash(int aSeed, long aLong)
longs.
[Expand]
Inherited Methods
From class java.lang.Object

Constants

public static final int SEED

An initial value for a hashCode, to which is added contributions from fields. Using a non-zero value decreases collisons of hashCode values.

Constant Value: 23 (0x00000017)

Public Constructors

public HashCodeUtil ()

Public Methods

public static int hash (int aSeed, boolean aBoolean)

booleans.

public static int hash (int aSeed, char aChar)

chars.

public static int hash (int aSeed, double aDouble)

doubles.

public static int hash (int aSeed, float aFloat)

floats.

public static int hash (int aSeed, int aInt)

ints.

public static int hash (int aSeed, Object aObject)

aObject is a possibly-null object field, and possibly an array. If aObject is an array, then each element may be a primitive or a possibly-null object.

public static int hash (int aSeed, long aLong)

longs.