fulmine.util.reference
Class is

java.lang.Object
  extended by fulmine.util.reference.is

public abstract class is
extends Object

A utility class for performing member comparisons within implementations of the Object.equals(Object) method. Instead of the usual

 if (this.name == null)
 {
     if (other.name != null)
     {
         return false;
     }
 }
 else
 {
     if (!name.equals(other.name))
     {
         return false;
     }
 }
 if (this.code != other.code)
     return false;
 
this class allows the following
 return is.eq(this.name, other.name) && is.eq(this.code, other.code);
 

Author:
Ramon Servadei

Constructor Summary
is()
           
 
Method Summary
static boolean deepEq(Object[] a1, Object[] a2)
          Performs a deep equality check for two Object[] arguments
static boolean differentClass(Object candidate, Object other)
          Test if the two objects are of the same Class.
static boolean eq(boolean[] a1, boolean[] a2)
          Performs an equality check for two boolean[] arguments
static boolean eq(boolean b1, boolean b2)
          Performs an equality check for two boolean arguments
static boolean eq(byte[] a1, byte[] a2)
          Performs an equality check for two byte[] arguments
static boolean eq(byte b1, byte b2)
          Performs an equality check for two byte arguments
static boolean eq(char[] a1, char[] a2)
          Performs an equality check for two char[] arguments
static boolean eq(char c1, char c2)
          Performs an equality check for two char arguments
static boolean eq(double[] a1, double[] a2)
          Performs an equality check for two double[] arguments
static boolean eq(double d1, double d2)
          Performs an equality check for two double arguments.
static boolean eq(float[] a1, float[] a2)
          Performs an equality check for two float[] arguments
static boolean eq(float f1, float f2)
          Performs an equality check for two float arguments
static boolean eq(int[] a1, int[] a2)
          Performs an equality check for two int[] arguments
static boolean eq(int i1, int i2)
          Performs an equality check for two integer arguments
static boolean eq(long[] a1, long[] a2)
          Performs an equality check for two long[] arguments
static boolean eq(long l1, long l2)
          Performs an equality check for two long arguments
static boolean eq(Object[] a1, Object[] a2)
          Performs an equality check for two Object[] arguments
static boolean eq(Object o1, Object o2)
          Performs an equality check of two objects.
static boolean eq(short[] a1, short[] a2)
          Performs an equality check for two short[] arguments
static boolean eq(short s1, short s2)
          Performs an equality check for two short arguments
static boolean notNull(Object o)
          Checks that the argument is not null
static boolean same(Object o1, Object o2)
          Performs a reference check of two objects.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

is

public is()
Method Detail

differentClass

public static boolean differentClass(Object candidate,
                                     Object other)
Test if the two objects are of the same Class. This assumes the first argument is not null. Also checks if the second argument is null.

Parameters:
candidate - the first object
other - the other object
Returns:
false if both objects are of the same Class, true if they are not OR the second argument is null (in which case the classes are not equal anyway).

same

public static boolean same(Object o1,
                           Object o2)
Performs a reference check of two objects.

Parameters:
o1 - the first object reference
o2 - the other object reference
Returns:
true if the objects references are for the same object

eq

public static boolean eq(Object o1,
                         Object o2)
Performs an equality check of two objects. Also checks neither is null.

Parameters:
o1 - the first object
o2 - the other object
Returns:
true if the objects are equal OR both are null

eq

public static boolean eq(boolean b1,
                         boolean b2)
Performs an equality check for two boolean arguments

Parameters:
b1 - the first argument
b2 - the other argument
Returns:
true if the arguments are equal

eq

public static boolean eq(byte b1,
                         byte b2)
Performs an equality check for two byte arguments

Parameters:
b1 - the first argument
b2 - the other argument
Returns:
true if the arguments are equal

eq

public static boolean eq(char c1,
                         char c2)
Performs an equality check for two char arguments

Parameters:
c1 - the first argument
c2 - the other argument
Returns:
true if the arguments are equal

eq

public static boolean eq(short s1,
                         short s2)
Performs an equality check for two short arguments

Parameters:
s1 - the first argument
s2 - the other argument
Returns:
true if the arguments are equal

eq

public static boolean eq(int i1,
                         int i2)
Performs an equality check for two integer arguments

Parameters:
i1 - the first argument
i2 - the other argument
Returns:
true if the arguments are equal

eq

public static boolean eq(long l1,
                         long l2)
Performs an equality check for two long arguments

Parameters:
l1 - the first argument
l2 - the other argument
Returns:
true if the arguments are equal

eq

public static boolean eq(float f1,
                         float f2)
Performs an equality check for two float arguments

Parameters:
f1 - the first argument
f2 - the other argument
Returns:
true if the arguments are equal
See Also:
Float.floatToIntBits(float)

eq

public static boolean eq(double d1,
                         double d2)
Performs an equality check for two double arguments.

Parameters:
d1 - the first argument
d2 - the other argument
Returns:
true if the arguments are equal
See Also:
Double.doubleToLongBits(double)

eq

public static boolean eq(boolean[] a1,
                         boolean[] a2)
Performs an equality check for two boolean[] arguments

Parameters:
a1 - the first argument
a2 - the other argument
Returns:
true if the arguments are equal
See Also:
Arrays.equals(boolean[], boolean[])

eq

public static boolean eq(byte[] a1,
                         byte[] a2)
Performs an equality check for two byte[] arguments

Parameters:
a1 - the first argument
a2 - the other argument
Returns:
true if the arguments are equal
See Also:
Arrays.equals(byte[], byte[])

eq

public static boolean eq(char[] a1,
                         char[] a2)
Performs an equality check for two char[] arguments

Parameters:
a1 - the first argument
a2 - the other argument
Returns:
true if the arguments are equal
See Also:
Arrays.equals(char[], char[])

eq

public static boolean eq(short[] a1,
                         short[] a2)
Performs an equality check for two short[] arguments

Parameters:
a1 - the first argument
a2 - the other argument
Returns:
true if the arguments are equal
See Also:
Arrays.equals(short[], short[])

eq

public static boolean eq(int[] a1,
                         int[] a2)
Performs an equality check for two int[] arguments

Parameters:
a1 - the first argument
a2 - the other argument
Returns:
true if the arguments are equal
See Also:
Arrays.equals(int[], int[])

eq

public static boolean eq(long[] a1,
                         long[] a2)
Performs an equality check for two long[] arguments

Parameters:
a1 - the first argument
a2 - the other argument
Returns:
true if the arguments are equal
See Also:
Arrays.equals(long[], long[])

eq

public static boolean eq(float[] a1,
                         float[] a2)
Performs an equality check for two float[] arguments

Parameters:
a1 - the first argument
a2 - the other argument
Returns:
true if the arguments are equal
See Also:
Arrays.equals(float[], float[])

eq

public static boolean eq(double[] a1,
                         double[] a2)
Performs an equality check for two double[] arguments

Parameters:
a1 - the first argument
a2 - the other argument
Returns:
true if the arguments are equal
See Also:
Arrays.equals(double[], double[])

eq

public static boolean eq(Object[] a1,
                         Object[] a2)
Performs an equality check for two Object[] arguments

Parameters:
a1 - the first argument
a2 - the other argument
Returns:
true if the arguments are equal
See Also:
Arrays.equals(Object[], Object[])

deepEq

public static boolean deepEq(Object[] a1,
                             Object[] a2)
Performs a deep equality check for two Object[] arguments

Parameters:
a1 - the first argument
a2 - the other argument
Returns:
true if the arguments are equal
See Also:
Arrays.deepEquals(Object[], Object[])

notNull

public static boolean notNull(Object o)
Checks that the argument is not null

Parameters:
o - the argument
Returns:
true if the argument is not null


Copyright © 2007-2009. All Rights Reserved.