ch.bind.philib.lang
Class HashUtil

java.lang.Object
  extended by ch.bind.philib.lang.HashUtil

public abstract class HashUtil
extends Object

Provides helper methods for hash-code generation.
Hash methods for handling all primitive types as well as Objects are provided.
Usage:

 @Override
 public int hashCode() {
     int hash = HashUtil.startHash(field1);
     hash = HashUtil.nextHash(hash, field2);
     ...
     hash = HashUtil.nextHash(hash, fieldN);
     return hash;
 }
 
Note: fields may be null.

Author:
Philipp Meinen

Constructor Summary
protected HashUtil()
           
 
Method Summary
static long fromDouble(double value)
           
static int fromFloat(float value)
           
static int nextHash(int hash, boolean value)
           
static int nextHash(int hash, byte value)
           
static int nextHash(int hash, char value)
           
static int nextHash(int hash, double value)
           
static int nextHash(int hash, float value)
           
static int nextHash(int hash, int value)
           
static int nextHash(int hash, long value)
           
static int nextHash(int hash, Object obj)
           
static int nextHash(int hash, short value)
           
static int startHash(boolean value)
           
static int startHash(byte value)
           
static int startHash(char value)
           
static int startHash(double value)
           
static int startHash(float value)
           
static int startHash(int value)
           
static int startHash(long value)
           
static int startHash(Object obj)
           
static int startHash(short value)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HashUtil

protected HashUtil()
Method Detail

startHash

public static final int startHash(boolean value)

startHash

public static final int startHash(byte value)

startHash

public static final int startHash(char value)

startHash

public static final int startHash(short value)

startHash

public static final int startHash(int value)

startHash

public static final int startHash(long value)

startHash

public static final int startHash(float value)

startHash

public static final int startHash(double value)

startHash

public static final int startHash(Object obj)

nextHash

public static final int nextHash(int hash,
                                 boolean value)

nextHash

public static final int nextHash(int hash,
                                 byte value)

nextHash

public static final int nextHash(int hash,
                                 char value)

nextHash

public static final int nextHash(int hash,
                                 short value)

nextHash

public static final int nextHash(int hash,
                                 int value)

nextHash

public static final int nextHash(int hash,
                                 long value)

nextHash

public static final int nextHash(int hash,
                                 float value)

nextHash

public static final int nextHash(int hash,
                                 double value)

nextHash

public static final int nextHash(int hash,
                                 Object obj)

fromFloat

public static final int fromFloat(float value)

fromDouble

public static final long fromDouble(double value)


Copyright © 2013. All Rights Reserved.