directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fel...@apache.org
Subject svn commit: r946375 - in /directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap: filter/AssertionNode.java filter/ExtensibleNode.java filter/ScopeNode.java filter/SubstringNode.java message/internal/InternalAbstractRequest.java
Date Wed, 19 May 2010 20:31:49 GMT
Author: felixk
Date: Wed May 19 20:31:48 2010
New Revision: 946375

URL: http://svn.apache.org/viewvc?rev=946375&view=rev
Log:
Override equals when overriding hashCode. I did my best to guess the equals criterias.
Please note that we can have now failing test cases.

Modified:
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/AssertionNode.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/ExtensibleNode.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/ScopeNode.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/SubstringNode.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/message/internal/InternalAbstractRequest.java

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/AssertionNode.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/AssertionNode.java?rev=946375&r1=946374&r2=946375&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/AssertionNode.java
(original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/AssertionNode.java
Wed May 19 20:31:48 2010
@@ -20,6 +20,7 @@
 package org.apache.directory.shared.ldap.filter;
 
 import org.apache.directory.shared.i18n.I18n;
+import org.apache.directory.shared.ldap.message.internal.InternalRequest;
 
 
 /**
@@ -128,9 +129,56 @@ public abstract class AssertionNode exte
 
 
     /**
+     * {@inheritDoc}
+     */
+    @Override
+    public boolean equals( Object obj )
+    {
+        if ( obj == this )
+        {
+            return true;
+        }
+
+        if ( ( obj == null ) || !( obj instanceof AssertionNode ) )
+        {
+            return false;
+        }
+        AssertionNode that = ( AssertionNode ) obj;
+        if ( assertion == null ) {
+            if ( that.assertion != null)
+            {
+                return false;
+            }
+        }
+        else
+        {
+            if ( !assertion.equals( that.assertion ) )
+            {
+                return false;
+            }
+        }
+        if ( desc == null ) {
+            if ( that.desc != null)
+            {
+                return false;
+            }
+        }
+        else
+        {
+            if ( !desc.equals( that.desc ) )
+            {
+                return false;
+            }
+        }
+        return super.equals( obj );
+    }
+
+
+    /**
      * @see Object#hashCode()
      * @return the instance's hash code 
      */
+    @Override
     public int hashCode()
     {
         int h = 37;

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/ExtensibleNode.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/ExtensibleNode.java?rev=946375&r1=946374&r2=946375&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/ExtensibleNode.java
(original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/ExtensibleNode.java
Wed May 19 20:31:48 2010
@@ -169,9 +169,42 @@ public class ExtensibleNode extends Leaf
 
     
     /**
+     * {@inheritDoc}
+     */
+    @Override
+    public boolean equals( Object obj )
+    {
+        if ( obj == this )
+        {
+            return true;
+        }
+
+        if ( ( obj == null ) || !( obj instanceof ExtensibleNode ) )
+        {
+            return false;
+        }
+        ExtensibleNode that = ( ExtensibleNode ) obj;
+        if ( dnAttributes != that.dnAttributes )
+        {
+            return false;
+        }
+        if ( !matchingRuleId.equals( that.matchingRuleId ) )
+        {
+            return false;
+        }
+        if ( !value.equals( that.value ) )
+        {
+            return false;
+        }
+        return super.equals( obj );
+    }
+
+
+    /**
      * @see Object#hashCode()
      * @return the instance's hash code 
      */
+    @Override
     public int hashCode()
     {
         int h = 37;

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/ScopeNode.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/ScopeNode.java?rev=946375&r1=946374&r2=946375&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/ScopeNode.java
(original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/ScopeNode.java
Wed May 19 20:31:48 2010
@@ -124,9 +124,62 @@ public class ScopeNode extends AbstractE
 
 
     /**
+     * {@inheritDoc}
+     */
+    @Override
+    public boolean equals( Object obj )
+    {
+        if ( obj == this )
+        {
+            return true;
+        }
+
+        if ( ( obj == null ) || !( obj instanceof ScopeNode ) )
+        {
+            return false;
+        }
+        ScopeNode that = ( ScopeNode ) obj;
+        if ( aliasDerefAliases == null )
+        {
+            if ( that.aliasDerefAliases != null )
+            {
+                return false;
+            }
+        }
+        else
+        {
+            if ( !aliasDerefAliases.equals( that.aliasDerefAliases ) )
+            {
+                return false;
+            }
+        }
+        if ( baseDn == null )
+        {
+            if ( that.baseDn != null )
+            {
+                return false;
+            }
+        }
+        else
+        {
+            if ( !baseDn.equals( that.baseDn ) )
+            {
+                return false;
+            }
+        }
+        if ( scope.getScope() != that.scope.getScope() )
+        {
+            return false;
+        }
+        return super.equals( obj );
+    }
+
+
+    /**
      * @see Object#hashCode()
      * @return the instance's hash code 
      */
+    @Override
     public int hashCode()
     {
         int h = 37;

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/SubstringNode.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/SubstringNode.java?rev=946375&r1=946374&r2=946375&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/SubstringNode.java
(original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/filter/SubstringNode.java
Wed May 19 20:31:48 2010
@@ -249,9 +249,58 @@ public class SubstringNode extends LeafN
 
 
     /**
+     * {@inheritDoc}
+     */
+    @Override
+    public boolean equals( Object obj )
+    {
+        if ( obj == this )
+        {
+            return true;
+        }
+
+        if ( ( obj == null ) || !( obj instanceof SubstringNode ) )
+        {
+            return false;
+        }
+        SubstringNode that = ( SubstringNode ) obj;
+        if ( initialPattern == null )
+        {
+            if ( that.initialPattern != null )
+            {
+                return false;
+            }
+        }
+        else
+        {
+            if ( !initialPattern.equals( that.initialPattern ) )
+            {
+                return false;
+            }
+        }
+        if ( finalPattern == null )
+        {
+            if ( that.finalPattern != null )
+            {
+                return false;
+            }
+        }
+        else
+        {
+            if ( !finalPattern.equals( that.finalPattern ) )
+            {
+                return false;
+            }
+        }
+        return super.equals( obj );
+    }
+
+
+    /**
      * @see Object#hashCode()
      * @return the instance's hash code 
      */
+    @Override
     public int hashCode()
     {
         int h = 37;

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/message/internal/InternalAbstractRequest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/message/internal/InternalAbstractRequest.java?rev=946375&r1=946374&r2=946375&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/message/internal/InternalAbstractRequest.java
(original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/message/internal/InternalAbstractRequest.java
Wed May 19 20:31:48 2010
@@ -68,9 +68,34 @@ public class InternalAbstractRequest ext
 
 
     /**
+     * {@inheritDoc}
+     */
+    @Override
+    public boolean equals( Object obj )
+    {
+        if ( obj == this )
+        {
+            return true;
+        }
+
+        if ( ( obj == null ) || !( obj instanceof InternalAbstractMessage ) )
+        {
+            return false;
+        }
+        
+        if ( hasResponse != ( ( InternalRequest) obj ).hasResponse() )
+        {
+            return false;
+        }
+        return super.equals( obj );
+    }
+
+
+    /**
      * @see Object#hashCode()
      * @return the instance's hash code 
      */
+    @Override
     public int hashCode()
     {
         int hash = 37;



Mime
View raw message