You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by el...@apache.org on 2007/01/02 00:05:15 UTC
svn commit: r491674 -
/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/message/LockableAttributeImpl.java
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();