net.sf.eos.util
Class EqualsAndHashUtil

java.lang.Object
  extended by net.sf.eos.util.EqualsAndHashUtil

public final class EqualsAndHashUtil
extends Object

Utility class to support Object.equals(Object) and Object.hashCode() method implementation.

Since:
0.1.0
Version:
1.0.0
Author:
Sascha Kohlmann

Method Summary
static int hash(boolean bool)
          Creates a hash code for the given boolean according to the rules stated in "Effective Java" by Joshua Bloch.
static int hash(boolean[] arr)
          Creates a hash code for the given array of booleans according to the rules stated in "Effective Java" by Joshua Bloch.
static int hash(byte b)
          Creates a hash code for the given byte according to the rules stated in "Effective Java" by Joshua Bloch.
static int hash(byte[] arr)
          Creates a hash code for the given array of bytes according to the rules stated in "Effective Java" by Joshua Bloch.
static int hash(char c)
          Creates a hash code for the given char according to the rules stated in "Effective Java" by Joshua Bloch.
static int hash(char[] arr)
          Creates a hash code for the given array of chars according to the rules stated in "Effective Java" by Joshua Bloch.
static int hash(double d)
          Creates a hash code for the given double according to the rules stated in "Effective Java" by Joshua Bloch.
static int hash(double[] arr)
          Creates a hash code for the given array of doubles according to the rules stated in "Effective Java" by Joshua Bloch.
static int hash(float f)
          Creates a hash code for the given float according to the rules stated in "Effective Java" by Joshua Bloch.
static int hash(float[] arr)
          Creates a hash code for the given array of floats according to the rules stated in "Effective Java" by Joshua Bloch.
static int hash(int i)
          Creates a hash code for the given int according to the rules stated in "Effective Java" by Joshua Bloch.
static int hash(int[] arr)
          Creates a hash code for the given array of ints according to the rules stated in "Effective Java" by Joshua Bloch.
static int hash(long l)
          Creates a hash code for the given long according to the rules stated in "Effective Java" by Joshua Bloch.
static int hash(long[] arr)
          Creates a hash code for the given array of longs according to the rules stated in "Effective Java" by Joshua Bloch.
static int hash(Object obj)
          Creates a hash code for the given Object according to the rules stated in "Effective Java" by Joshua Bloch.
static int hash(Object[] arr)
          Creates a hash code for the given array of Objects according to the rules stated in "Effective Java" by Joshua Bloch.
static int hash(short s)
          Creates a hash code for the given short according to the rules stated in "Effective Java" by Joshua Bloch.
static int hash(short[] arr)
          Creates a hash code for the given array of shorts according to the rules stated in "Effective Java" by Joshua Bloch.
static boolean isEqual(boolean[] own, boolean[] other)
          boolean array equality check.
static boolean isEqual(boolean own, boolean other)
          boolean equality check.
static boolean isEqual(byte[] own, byte[] other)
          byte array equality check.
static boolean isEqual(byte own, byte other)
          byte equality check.
static boolean isEqual(char[] own, char[] other)
          char array equality check.
static boolean isEqual(char own, char other)
          char equality check.
static boolean isEqual(double[] own, double[] other)
          double array equality check.
static boolean isEqual(double own, double other)
          double equality check.
static boolean isEqual(float[] own, float[] other)
          float array equality check.
static boolean isEqual(float own, float other)
          float equality check.
static boolean isEqual(int[] own, int[] other)
          int array equality check.
static boolean isEqual(int own, int other)
          int equality check.
static boolean isEqual(long[] own, long[] other)
          long array equality check.
static boolean isEqual(long own, long other)
          long equality check.
static boolean isEqual(Object[] own, Object[] other)
          Object array equality check.
static boolean isEqual(Object own, Object other)
          Object equality check.
static boolean isEqual(short[] own, short[] other)
          short array equality check.
static boolean isEqual(short own, short other)
          short equality check.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

isEqual

public static boolean isEqual(boolean own,
                              boolean other)
boolean equality check.

Parameters:
own - the first boolean
other - the second <boolean
Returns:
true if the booleans are equal, <false otherwise

isEqual

public static boolean isEqual(char own,
                              char other)
char equality check.

Parameters:
own - the first char
other - the second char
Returns:
true if the chars are equal, false otherwise

isEqual

public static boolean isEqual(byte own,
                              byte other)
byte equality check.

Parameters:
own - the first byte
other - the second byte
Returns:
true if the bytes are equal, false otherwise

isEqual

public static boolean isEqual(short own,
                              short other)
short equality check.

Parameters:
own - the first short
other - the second short
Returns:
true if the shorts are equal, false otherwise

isEqual

public static boolean isEqual(int own,
                              int other)
int equality check.

Parameters:
own - the first int
other - the second int
Returns:
true if the ints are equal, false otherwise

isEqual

public static boolean isEqual(long own,
                              long other)
long equality check.

Parameters:
own - the first long
other - the second long
Returns:
true if the longs are equal, false otherwise

isEqual

public static boolean isEqual(float own,
                              float other)
float equality check.

Parameters:
own - the first float
other - the second float
Returns:
true if the floats are equal, false otherwise

isEqual

public static boolean isEqual(double own,
                              double other)
double equality check.

Parameters:
own - the first double
other - the second double
Returns:
true if the doubles are equal, false otherwise

isEqual

public static boolean isEqual(@Nullable
                              Object own,
                              @Nullable
                              Object other)
Object equality check.

Parameters:
own - the first Object
other - the second Object
Returns:
true if the Objects are equal, false otherwise

isEqual

public static boolean isEqual(@Nullable
                              boolean[] own,
                              @Nullable
                              boolean[] other)
boolean array equality check.

Parameters:
own - the first array of booleans
other - the second array of booleans
Returns:
true if the two boolean arrays are equal, false otherwise

isEqual

public static boolean isEqual(@Nullable
                              char[] own,
                              @Nullable
                              char[] other)
char array equality check.

Parameters:
own - the first array of chars
other - the second array of chars
Returns:
true if the two char arrays are equal, false otherwise

isEqual

public static boolean isEqual(@Nullable
                              byte[] own,
                              @Nullable
                              byte[] other)
byte array equality check.

Parameters:
own - the first array of bytes
other - the second array of bytes
Returns:
true if the two byte arrays are equal, false otherwise

isEqual

public static boolean isEqual(@Nullable
                              short[] own,
                              @Nullable
                              short[] other)
short array equality check.

Parameters:
own - the first array of shorts
other - the second array of shorts
Returns:
true if the two short arrays are equal, false otherwise

isEqual

public static boolean isEqual(@Nullable
                              int[] own,
                              @Nullable
                              int[] other)
int array equality check.

Parameters:
own - the first array of ints
other - the second array of ints
Returns:
true if the two int arrays are equal, false otherwise

isEqual

public static boolean isEqual(@Nullable
                              long[] own,
                              @Nullable
                              long[] other)
long array equality check.

Parameters:
own - the first array of longs
other - the second array of longs
Returns:
true if the two long arrays are equal, false otherwise

isEqual

public static boolean isEqual(@Nullable
                              float[] own,
                              @Nullable
                              float[] other)
float array equality check.

Parameters:
own - the first array of floats
other - the second array of floats
Returns:
true if the two float arrays are equal, false otherwise

isEqual

public static boolean isEqual(@Nullable
                              double[] own,
                              @Nullable
                              double[] other)
double array equality check.

Parameters:
own - the first array of doubles
other - the second array of doubles
Returns:
true if the two double arrays are equal, false otherwise

isEqual

public static boolean isEqual(@Nullable
                              Object[] own,
                              @Nullable
                              Object[] other)
Object array equality check.

Parameters:
own - the first array of Objects
other - the second array of Objects
Returns:
true if the two Object arrays are equal, false otherwise

hash

public static int hash(@Nullable
                       Object obj)
Creates a hash code for the given Object according to the rules stated in "Effective Java" by Joshua Bloch.

Parameters:
obj - the object to compute the hash code for
Returns:
a hash code

hash

public static int hash(boolean bool)
Creates a hash code for the given boolean according to the rules stated in "Effective Java" by Joshua Bloch.

Parameters:
bool - the object to compute the hash code for
Returns:
a hash code

hash

public static int hash(byte b)
Creates a hash code for the given byte according to the rules stated in "Effective Java" by Joshua Bloch.

Parameters:
b - the object to compute the hash code for
Returns:
a hash code

hash

public static int hash(char c)
Creates a hash code for the given char according to the rules stated in "Effective Java" by Joshua Bloch.

Parameters:
c - the object to compute the hash code for
Returns:
a hash code

hash

public static int hash(short s)
Creates a hash code for the given short according to the rules stated in "Effective Java" by Joshua Bloch.

Parameters:
s - the object to compute the hash code for
Returns:
a hash code

hash

public static int hash(int i)
Creates a hash code for the given int according to the rules stated in "Effective Java" by Joshua Bloch.

Parameters:
i - the object to compute the hash code for
Returns:
a hash code

hash

public static int hash(long l)
Creates a hash code for the given long according to the rules stated in "Effective Java" by Joshua Bloch.

Parameters:
l - the object to compute the hash code for
Returns:
a hash code

hash

public static int hash(float f)
Creates a hash code for the given float according to the rules stated in "Effective Java" by Joshua Bloch.

Parameters:
f - the object to compute the hash code for
Returns:
a hash code

hash

public static int hash(double d)
Creates a hash code for the given double according to the rules stated in "Effective Java" by Joshua Bloch.

Parameters:
d - the object to compute the hash code for
Returns:
a hash code

hash

public static int hash(@Nullable
                       Object[] arr)
Creates a hash code for the given array of Objects according to the rules stated in "Effective Java" by Joshua Bloch.

Parameters:
arr - the array of Objects to compute the hash code for
Returns:
a hash code

hash

public static int hash(@Nullable
                       boolean[] arr)
Creates a hash code for the given array of booleans according to the rules stated in "Effective Java" by Joshua Bloch.

Parameters:
arr - the array of booleans to compute the hash code
Returns:
a hash code

hash

public static int hash(@Nullable
                       byte[] arr)
Creates a hash code for the given array of bytes according to the rules stated in "Effective Java" by Joshua Bloch.

Parameters:
arr - the array of bytes to compute the hash code for
Returns:
a hash code

hash

public static int hash(@Nullable
                       char[] arr)
Creates a hash code for the given array of chars according to the rules stated in "Effective Java" by Joshua Bloch.

Parameters:
arr - the array of chars to compute the hash code for
Returns:
a hash code

hash

public static int hash(@Nullable
                       short[] arr)
Creates a hash code for the given array of shorts according to the rules stated in "Effective Java" by Joshua Bloch.

Parameters:
arr - the array of shorts to compute the hash code for
Returns:
a hash code

hash

public static int hash(@Nullable
                       int[] arr)
Creates a hash code for the given array of ints according to the rules stated in "Effective Java" by Joshua Bloch.

Parameters:
arr - the array of ints to compute the hash code for
Returns:
a hash code

hash

public static int hash(@Nullable
                       long[] arr)
Creates a hash code for the given array of longs according to the rules stated in "Effective Java" by Joshua Bloch.

Parameters:
arr - the array of longs to compute the hash code for
Returns:
a hash code

hash

public static int hash(@Nullable
                       float[] arr)
Creates a hash code for the given array of floats according to the rules stated in "Effective Java" by Joshua Bloch.

Parameters:
arr - the array of floats to compute the hash code for
Returns:
a hash code

hash

public static int hash(@Nullable
                       double[] arr)
Creates a hash code for the given array of doubles according to the rules stated in "Effective Java" by Joshua Bloch.

Parameters:
arr - the array of doubles to compute the hash code for
Returns:
a hash code


Copyright © 2008. All Rights Reserved.