org.metasyntactic.core
Class HashCode

java.lang.Object
  |
  +--org.metasyntactic.core.HashCode

public class HashCode
extends java.lang.Object

Convenience class to return the hashcode of any object (including null), or primitive. This is useful when you end up having to write code looking like


	return object == null ? 0 : object.hashCode();
 

Or when you have to have code that needs to get the hash codes for primitives


Method Summary
static int valueOf(boolean value)
          Returns the hashcode for the value passed in
static int valueOf(byte value)
          Returns the hashcode for the value passed in
static int valueOf(char value)
          Returns the hashcode for the value passed in
static int valueOf(double value)
          Returns the hashcode for the value passed in
static int valueOf(float value)
          Returns the hashcode for the value passed in
static int valueOf(int value)
          Returns the hashcode for the value passed in
static int valueOf(long value)
          Equivalent to return (int)(value ^ (value >> 32))
static int valueOf(java.lang.Object o)
          Returns the hashcode for the value passed in
static int valueOf(short value)
          Returns the hashcode for the value passed in
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

valueOf

public static int valueOf(java.lang.Object o)
Returns the hashcode for the value passed in

Parameters:
o - The object to get the hashcode for
Returns:
The hashcode of the object passed in, or 0 if it equal to null

valueOf

public static int valueOf(boolean value)
Returns the hashcode for the value passed in

Parameters:
value - true or false
Returns:
1231 if value is true, else 1237

valueOf

public static int valueOf(byte value)
Returns the hashcode for the value passed in

Parameters:
value - The value to get the hash code for
Returns:
The hash code

valueOf

public static int valueOf(char value)
Returns the hashcode for the value passed in

Parameters:
value - The value to get the hash code for
Returns:
The hash code

valueOf

public static int valueOf(short value)
Returns the hashcode for the value passed in

Parameters:
value - The value to get the hash code for
Returns:
The hash code

valueOf

public static int valueOf(int value)
Returns the hashcode for the value passed in

Parameters:
value - The value to get the hash code for
Returns:
The hash code

valueOf

public static int valueOf(long value)
Equivalent to return (int)(value ^ (value >> 32))

Parameters:
value - The value to get the hash code for
Returns:
The hash code

valueOf

public static int valueOf(float value)
Returns the hashcode for the value passed in

Parameters:
value - The value to get the hash code for
Returns:
The hash code

valueOf

public static int valueOf(double value)
Returns the hashcode for the value passed in

Parameters:
value - The value to get the hash code for
Returns:
The hash code