Overview | Package | Class | Tree | Deprecated | Index | Help
| Copyright © 2000, 2008, Oracle and/or its affiliates. All rights reserved.
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.bea.p13n.util
Class HashCodeUtil

    java.lang.Object
      com.bea.p13n.util.HashCodeUtil

    public final class HashCodeUtil

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

See Effective Java, by Joshua Bloch

Field Summary
`static int` | `SEED` An initial value for a `hashCode`, to which is added contributions from fields.

Constructor Summary
`HashCodeUtil()`

Method Summary
`static int` | `hash(int aSeed, boolean aBoolean)` booleans.
`static int` | `hash(int aSeed, char aChar)` chars.
`static int` | `hash(int aSeed, Collection aCollection)` `aCollection` is a possibly-null Collection field
`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, long aLong)` longs.
`static int` | `hash(int aSeed, 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 collisons of `hashCode` values.

  See Also
    Constants Summary

Constructor Detail

### HashCodeUtil

    public HashCodeUtil()

Method Detail

### hash

    public static int hash(int aSeed,
                           boolean aBoolean)

  booleans.

### hash

    public static int hash(int aSeed,
                           char aChar)

  chars.

### hash

    public static int hash(int aSeed,
                           int aInt)

  ints.

### hash

    public static int hash(int aSeed,
                           long aLong)

  longs.

### hash

    public static int hash(int aSeed,
                           float aFloat)

  floats.

### hash

    public static int hash(int aSeed,
                           double aDouble)

  doubles.

### hash

    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.

### hash

    public static int hash(int aSeed,
                           Collection aCollection)

  `aCollection` is a possibly-null Collection field

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2000, 2008, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its affiliates.
Other names may be trademarks of their respective owners.