harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From telli...@apache.org
Subject svn commit: r833384 - /harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/dns/SList.java
Date Fri, 06 Nov 2009 13:13:36 GMT
Author: tellison
Date: Fri Nov  6 13:13:36 2009
New Revision: 833384

URL: http://svn.apache.org/viewvc?rev=833384&view=rev
Log:
Define hashCode for a SList.Server as it is put into a hash map.

Modified:
    harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/dns/SList.java

Modified: harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/dns/SList.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/dns/SList.java?rev=833384&r1=833383&r2=833384&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/dns/SList.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/dns/SList.java
Fri Nov  6 13:13:36 2009
@@ -500,12 +500,14 @@
          */
         @Override
         public boolean equals(Object obj) {
-            SList.Server srv = null;
-
+            if (this == obj) {
+                return true;
+            }
             if (!(obj instanceof SList.Server)) {
                 return false;
             }
-            srv = (SList.Server) obj;
+
+            SList.Server srv = (SList.Server) obj;
             if (serverIP == null || srv.getIP() == null) {
                 if (this.getName() == null || srv.getName() == null) {
                     return false;
@@ -516,6 +518,14 @@
             return this.getIP().equals(srv.getIP())
                     && this.getPort() == srv.getPort();
         }
+        
+        /**
+         * Returns the hash code of the receiver.
+         */
+        @Override
+        public int hashCode() {
+            return getIP().hashCode() + getPort();
+        }
 
         /**
          * @return Returns the serverIP.



Mime
View raw message