You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cayenne.apache.org by aa...@apache.org on 2006/05/24 04:18:13 UTC
svn commit: r409038 -
/incubator/cayenne/main/trunk/cayenne/cayenne-java/src/cayenne/java/org/objectstyle/cayenne/util/Util.java
Author: aadamchik
Date: Tue May 23 19:18:12 2006
New Revision: 409038
URL: http://svn.apache.org/viewvc?rev=409038&view=rev
Log:
minor cleanup of comparison algorithm
Modified:
incubator/cayenne/main/trunk/cayenne/cayenne-java/src/cayenne/java/org/objectstyle/cayenne/util/Util.java
Modified: incubator/cayenne/main/trunk/cayenne/cayenne-java/src/cayenne/java/org/objectstyle/cayenne/util/Util.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/cayenne/cayenne-java/src/cayenne/java/org/objectstyle/cayenne/util/Util.java?rev=409038&r1=409037&r2=409038&view=diff
==============================================================================
--- incubator/cayenne/main/trunk/cayenne/cayenne-java/src/cayenne/java/org/objectstyle/cayenne/util/Util.java (original)
+++ incubator/cayenne/main/trunk/cayenne/cayenne-java/src/cayenne/java/org/objectstyle/cayenne/util/Util.java Tue May 23 19:18:12 2006
@@ -282,26 +282,23 @@
* Compares two objects similar to "Object.equals(Object)". Unlike Object.equals(..),
* this method doesn't throw an exception if any of the two objects is null.
*/
- public static boolean nullSafeEquals(Object obj1, Object obj2) {
- if (obj1 == null && obj2 == null) {
- return true;
+ public static boolean nullSafeEquals(Object o1, Object o2) {
+
+ if (o1 == null) {
+ return o2 == null;
}
- else if (obj1 != null) {
- // Arrays must be handled differently since equals() only does
- // an "==" for an array and ignores equivalence. If an array, use
- // the Jakarta Commons Language component EqualsBuilder to determine
- // the types contained in the array and do individual comparisons.
- if (obj1.getClass().isArray()) {
- EqualsBuilder builder = new EqualsBuilder();
- builder.append(obj1, obj2);
- return builder.isEquals();
- }
- else { // It is NOT an array, so use regular equals()
- return obj1.equals(obj2);
- }
+
+ // Arrays must be handled differently since equals() only does
+ // an "==" for an array and ignores equivalence. If an array, use
+ // the Jakarta Commons Language component EqualsBuilder to determine
+ // the types contained in the array and do individual comparisons.
+ if (o1.getClass().isArray()) {
+ EqualsBuilder builder = new EqualsBuilder();
+ builder.append(o1, o2);
+ return builder.isEquals();
}
- else {
- return false;
+ else { // It is NOT an array, so use regular equals()
+ return o1.equals(o2);
}
}