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 2006/12/30 19:37:49 UTC

svn commit: r491286 - /directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/name/AttributeTypeAndValue.java

Author: elecharny
Date: Sat Dec 30 10:37:48 2006
New Revision: 491286

URL: http://svn.apache.org/viewvc?view=rev&rev=491286
Log:
Added an equals() method to superseed the Object.equals() standard method

Modified:
    directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/name/AttributeTypeAndValue.java

Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/name/AttributeTypeAndValue.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/name/AttributeTypeAndValue.java?view=diff&rev=491286&r1=491285&r2=491286
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/name/AttributeTypeAndValue.java (original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/name/AttributeTypeAndValue.java Sat Dec 30 10:37:48 2006
@@ -553,6 +553,49 @@
         return result;
     }
 
+    /**
+     * @see Object#equals(Object)
+     */
+    public boolean equals( Object obj )
+    {
+        if ( this == obj )
+        {
+            return true;
+        }
+        
+        if ( obj == null)
+        {
+            return false;
+        }
+        
+        if ( obj.getClass() != this.getClass() )
+        {
+            return false;
+        }
+        
+        AttributeTypeAndValue instance = (AttributeTypeAndValue)obj;
+     
+        // Compare the type
+        if ( this.type == null )
+        {
+            if ( instance.type != null )
+            {
+                return false;
+            }
+        }
+        else 
+        {
+            if ( !this.type.equals( instance.type ) )
+            {
+                return false;
+            }
+        }
+            
+        // Compare the value
+        return ( this.value == null ? 
+            instance.value == null  :
+            this.type.equals( instance.type ) );
+    }
 
     /**
      * A String representation of a AttributeTypeAndValue.