Author: olegk
Date: Wed Jun  1 15:16:28 2005
New Revision: 179433

URL: http://svn.apache.org/viewcvs?rev=179433&view=rev
Log:
Code cleanup in #hashCode and #equals methods

Modified:
    
jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/HostConfiguration.java

Modified: 
jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/HostConfiguration.java
URL: 
http://svn.apache.org/viewcvs/jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/HostConfiguration.java?rev=179433&r1=179432&r2=179433&view=diff
==============================================================================
--- 
jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/HostConfiguration.java
 (original)
+++ 
jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/HostConfiguration.java
 Wed Jun  1 15:16:28 2005
@@ -485,45 +485,15 @@
      * @see java.lang.Object#equals(java.lang.Object)
      */
     public synchronized boolean equals(final Object o) {
-        
         if (o instanceof HostConfiguration) {
-            
             // shortcut if we're comparing with ourselves
             if (o == this) { 
                 return true;
             }
-            
             HostConfiguration that = (HostConfiguration) o;
-            
-            if (this.host != null) {
-                if (!this.host.equals(that.host)) {
-                    return false;
-                }
-            } else {
-                if (that.host != null) {
-                    return false;
-                }
-            }
-            if (this.proxyHost != null) {
-                if (!this.proxyHost.equals(that.proxyHost)) {
-                    return false;
-                }
-            } else {
-                if (that.proxyHost != null) {
-                    return false;
-                }
-            }
-            if (localAddress != null) {
-                if (!localAddress.equals(that.getLocalAddress())) {
-                    return false;
-                }
-            } else {
-                if (that.getLocalAddress() != null) {
-                    return false; 
-                }
-            }
-            // everything matches
-            return true;
+            return LangUtils.equals(this.host, that.host)
+                && LangUtils.equals(this.proxyHost, that.proxyHost)
+                && LangUtils.equals(this.localAddress, that.localAddress);
         } else {
             return false;
         }
@@ -537,6 +507,7 @@
         int hash = LangUtils.HASH_SEED;
         hash = LangUtils.hashCode(hash, this.host);
         hash = LangUtils.hashCode(hash, this.proxyHost);
+        hash = LangUtils.hashCode(hash, this.localAddress);
         return hash;
     }
 



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to