db-torque-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tfisc...@apache.org
Subject svn commit: r1213051 - /db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/sql/PreparedStatementPart.java
Date Sun, 11 Dec 2011 20:02:55 GMT
Author: tfischer
Date: Sun Dec 11 20:02:54 2011
New Revision: 1213051

URL: http://svn.apache.org/viewvc?rev=1213051&view=rev
Log:
use hashCodeBuilder and equalsBuilder for hashCode and equals methods

Modified:
    db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/sql/PreparedStatementPart.java

Modified: db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/sql/PreparedStatementPart.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/sql/PreparedStatementPart.java?rev=1213051&r1=1213050&r2=1213051&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/sql/PreparedStatementPart.java
(original)
+++ db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/sql/PreparedStatementPart.java
Sun Dec 11 20:02:54 2011
@@ -21,6 +21,9 @@ package org.apache.torque.sql;
 
 import java.util.ArrayList;
 import java.util.List;
+
+import org.apache.commons.lang.builder.EqualsBuilder;
+import org.apache.commons.lang.builder.HashCodeBuilder;
 /**
  * The rendered SQL for a part of a prepared statement.
  *
@@ -62,9 +65,10 @@ public class PreparedStatementPart
     @Override
     public int hashCode()
     {
-        int result = sql.hashCode();
-        result = 31 * result + preparedStatementReplacements.hashCode();
-        return result;
+        HashCodeBuilder hashCodeBuilder = new HashCodeBuilder();
+        hashCodeBuilder.append(sql);
+        hashCodeBuilder.append(preparedStatementReplacements);
+        return hashCodeBuilder.toHashCode();
     }
 
     @Override
@@ -83,16 +87,12 @@ public class PreparedStatementPart
             return false;
         }
         PreparedStatementPart other = (PreparedStatementPart) obj;
-        if (!sql.equals(other.sql))
-        {
-            return false;
-        }
-        if (!preparedStatementReplacements.equals(
-                other.preparedStatementReplacements))
-        {
-            return false;
-        }
-        return true;
+        EqualsBuilder equalsBuilder = new EqualsBuilder();
+        equalsBuilder.append(other.sql, this.sql);
+        equalsBuilder.append(
+                other.preparedStatementReplacements,
+                this.preparedStatementReplacements);
+        return equalsBuilder.isEquals();
     }
 
     @Override



---------------------------------------------------------------------
To unsubscribe, e-mail: torque-dev-unsubscribe@db.apache.org
For additional commands, e-mail: torque-dev-help@db.apache.org


Mime
View raw message