You are viewing a plain text version of this content. The canonical link for it is here.
Posted to torque-dev@db.apache.org by tf...@apache.org on 2012/06/09 05:47:39 UTC

svn commit: r1348319 - /db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/manager/MethodCacheKey.java

Author: tfischer
Date: Sat Jun  9 03:47:39 2012
New Revision: 1348319

URL: http://svn.apache.org/viewvc?rev=1348319&view=rev
Log:
use standard hashCode and equals methods

Modified:
    db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/manager/MethodCacheKey.java

Modified: db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/manager/MethodCacheKey.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/manager/MethodCacheKey.java?rev=1348319&r1=1348318&r2=1348319&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/manager/MethodCacheKey.java (original)
+++ db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/manager/MethodCacheKey.java Sat Jun  9 03:47:39 2012
@@ -22,6 +22,9 @@ package org.apache.torque.manager;
 import java.io.Serializable;
 
 import org.apache.commons.lang.ObjectUtils;
+import org.apache.commons.lang.builder.EqualsBuilder;
+import org.apache.commons.lang.builder.HashCodeBuilder;
+import org.apache.torque.criteria.Criterion;
 
 /**
  * @version $Id$
@@ -82,34 +85,44 @@ public class MethodCacheKey implements S
         return groupKey;
     }
 
+    @Override
     public boolean equals(Object obj)
     {
-        boolean equal = false;
-        if (obj instanceof MethodCacheKey)
+        if (this == obj)
         {
-            MethodCacheKey sck = (MethodCacheKey) obj;
-            equal = ObjectUtils.equals(sck.method, method);
-            equal &= ObjectUtils.equals(sck.instanceOrClass, instanceOrClass);
-            if (equal)
-            {
-                equal &= ObjectUtils.equals(sck.args, args);
-            }
+            return true;
+        }
+        if (obj == null)
+        {
+            return false;
+        }
+        if (obj.getClass() != this.getClass())
+        {
+            return false;
         }
 
-        return equal;
+        MethodCacheKey methodCacheKey = (MethodCacheKey) obj;
+        EqualsBuilder equalsBuilder = new EqualsBuilder();
+        equalsBuilder.append(methodCacheKey.method, method)
+                .append(methodCacheKey.instanceOrClass, instanceOrClass)
+                .append(methodCacheKey.args, args);
+        return equalsBuilder.isEquals();
     }
 
+    @Override
     public int hashCode()
     {
-        int h = instanceOrClass.hashCode();
-        h += method.hashCode();
-        h += args.hashCode();
-        return h;
+        HashCodeBuilder hashCodeBuilder = new HashCodeBuilder();
+        hashCodeBuilder.append(method)
+                .append(instanceOrClass)
+                .append(args);
+        return hashCodeBuilder.toHashCode();
     }
 
+    @Override
     public String toString()
     {
-        StringBuffer sb = new StringBuffer(50);
+        StringBuilder sb = new StringBuilder();
         sb.append(instanceOrClass);
         sb.append("::");
         sb.append(method).append('(');



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