directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r491674 - /directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/message/LockableAttributeImpl.java
Date Mon, 01 Jan 2007 23:05:15 GMT
Author: elecharny
Date: Mon Jan  1 15:05:14 2007
New Revision: 491674

URL: http://svn.apache.org/viewvc?view=rev&rev=491674
Log:
Added a hashCode() method as we have overloaded the equals() method

Modified:
    directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/message/LockableAttributeImpl.java

Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/message/LockableAttributeImpl.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/message/LockableAttributeImpl.java?view=diff&rev=491674&r1=491673&r2=491674
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/message/LockableAttributeImpl.java
(original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/message/LockableAttributeImpl.java
Mon Jan  1 15:05:14 2007
@@ -566,7 +566,7 @@
             return true;
         }
 
-        if ( !( obj instanceof Attribute ) )
+        if ( ( obj == null ) || !( obj instanceof Attribute ) )
         {
             return false;
         }
@@ -619,7 +619,37 @@
         		return true;
         }
     }
-    
+
+    /**
+     * @see Object#hashCode()
+     */
+    public int hashCode()
+    {
+        int hash = 7;
+        hash = hash*31 + size;
+        hash = hash*31 + ( upId == null ? 0 : upId.hashCode() );
+        
+        switch (size)
+        {
+            case 0 :
+                return hash;
+                
+            case 1 :
+                return hash*31 + ( value == null ? 0 : value.hashCode() );
+                
+            default :
+                for ( Object value:list )
+                {
+                    hash = hash*31 + ( value == null ? 0 : value.hashCode() );
+                }
+            
+                return hash;
+        }
+    }
+
+    /**
+     * @see Object#toString()
+     */
     public String toString()
     {
     	StringBuffer sb = new StringBuffer();



Mime
View raw message