eq = deepEquals( (Object[]) e1, (Object[]) e2 ); } else { eq = e1.equals( e2 );
eq = deepEquals( (Object[]) e1, (Object[]) e2 ); } else { eq = e1.equals( e2 );
/** * Performs an equals() check on two Objects, either (or both) of which may be null. * <p> * This method returns <code>true</code> if both Objects are null. Whether, strictly speaking, * null == null is debatable, but this approach is useful for comparing two parent Objects who * have both left certain properties as null. Generally we want those two parent Objects to be * considered equal. * * @return true if both object1 and object2 are null, false if one is null and the other is not, * otherwise returns object1.equals( object2 ) */ public static boolean nullSafeEquals( Object object1, Object object2 ) { if ( object1 == null ) { return object2 == null; } // Array.equals is broken by default if ( object1.getClass().isArray() ) { if ( object2 == null || !object2.getClass().isArray() ) { return false; } return deepEquals( (Object[]) object1, (Object[]) object2 ); } return object1.equals( object2 ); }
/** * Performs an equals() check on two Objects, either (or both) of which may be null. * <p> * This method returns <code>true</code> if both Objects are null. Whether, strictly speaking, * null == null is debatable, but this approach is useful for comparing two parent Objects who * have both left certain properties as null. Generally we want those two parent Objects to be * considered equal. * * @return true if both object1 and object2 are null, false if one is null and the other is not, * otherwise returns object1.equals( object2 ) */ public static boolean nullSafeEquals( Object object1, Object object2 ) { if ( object1 == null ) { return object2 == null; } // Array.equals is broken by default if ( object1.getClass().isArray() ) { if ( object2 == null || !object2.getClass().isArray() ) { return false; } return deepEquals( (Object[]) object1, (Object[]) object2 ); } return object1.equals( object2 ); }