directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r597947 - /directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/message/ModificationItemImpl.java
Date Sun, 25 Nov 2007 02:54:32 GMT
Author: elecharny
Date: Sat Nov 24 18:54:31 2007
New Revision: 597947

URL: http://svn.apache.org/viewvc?rev=597947&view=rev
Log:
Added hashCode() and equals() methods

Modified:
    directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/message/ModificationItemImpl.java

Modified: directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/message/ModificationItemImpl.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/message/ModificationItemImpl.java?rev=597947&r1=597946&r2=597947&view=diff
==============================================================================
--- directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/message/ModificationItemImpl.java
(original)
+++ directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/message/ModificationItemImpl.java
Sat Nov 24 18:54:31 2007
@@ -177,4 +177,52 @@
         
         return sb.toString();
     }
+    
+    
+    /**
+     * @see Object#hashCode()
+     */
+    public int hashCode()
+    {
+        int hash = 37;
+        
+        hash += hash*17 + getModificationOp();
+        hash += hash*17 + getAttribute().hashCode();
+        return hash;
+    }
+    
+    
+    /**
+     * @see Object#equals(Object)
+     */
+    public boolean equals( Object o )
+    {
+        // Basic equals checks
+        if ( this == o )
+        {
+            return true;
+        }
+        
+        if ( o == null )
+        {
+            return false;
+        }
+        
+        if ( ! (o instanceof ModificationItemImpl ) )
+        {
+            return false;
+        }
+        
+        ModificationItemImpl mod = (ModificationItemImpl)o;
+        
+        // Now, compares the modification content
+        // First, the modification type
+        if ( this.getModificationOp() != mod.getModificationOp() )
+        {
+            return false;
+        }
+        
+        // then the attribute
+        return this.getAttribute().equals( mod.getAttribute() );
+    }
 }



Mime
View raw message