net.sf.okapi.common

## Class HashCodeUtil

- java.lang.Object
- - net.sf.okapi.common.HashCodeUtil

-     public final class HashCodeUtil
      extends java.lang.Object

  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;
       }

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static int` | `SEED` An initial value for a `hashCode`, to which is added contributions from fields.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `HashCodeUtil()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `static int` | `hash(int aSeed, boolean aBoolean)`
    `static int` | `hash(int aSeed, char aChar)`
    `static int` | `hash(int aSeed, double aDouble)`
    `static int` | `hash(int aSeed, float aFloat)`
    `static int` | `hash(int aSeed, int aInt)`
    `static int` | `hash(int aSeed, long aLong)`
    `static int` | `hash(int aSeed, java.lang.Object aObject)` `aObject` is a possibly-null object field, and possibly an array.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### SEED

          public static final int SEED

      An initial value for a `hashCode`, to which is added contributions from fields. Using a non-zero value decreases collisions of `hashCode` values.
      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### HashCodeUtil

          public HashCodeUtil()

  - ### Method Detail

    - #### hash

          public static int hash(int aSeed,
                 boolean aBoolean)

      Parameters:
        `aSeed` - initial value of the `hashCode`
        `aBoolean` - value to contribute to the `hashCode`
      Returns:
        hash code for a boolean.

    - #### hash

          public static int hash(int aSeed,
                 char aChar)

      Parameters:
        `aSeed` - initial value of the `hashCode`
        `aChar` - value to contribute to the `hashCode`
      Returns:
        has code for a char value.

    - #### hash

          public static int hash(int aSeed,
                 int aInt)

      Parameters:
        `aSeed` - initial value of the `hashCode`
        `aInt` - value to contribute to the `hashCode`
      Returns:
        hash code for int.

    - #### hash

          public static int hash(int aSeed,
                 long aLong)

      Parameters:
        `aSeed` - initial value of the `hashCode`
        `aLong` - value to contribute to the `hashCode`
      Returns:
        hash code for a long value.

    - #### hash

          public static int hash(int aSeed,
                 float aFloat)

      Parameters:
        `aSeed` - initial value of the `hashCode`
        `aFloat` - value to contribute to the `hashCode`
      Returns:
        a hash code for a float value.

    - #### hash

          public static int hash(int aSeed,
                 double aDouble)

      Parameters:
        `aSeed` - initial value of the `hashCode`
        `aDouble` - value to contribute to the `hashCode`
      Returns:
        a hash code for a double value.

    - #### hash

          public static int hash(int aSeed,
                 java.lang.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.
      Parameters:
        `aSeed` - initial value of the `hashCode`
        `aObject` - value to contribute to the `hashCode`
      Returns:
        a hash code for an `Object` (`Array`-aware).