directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject [directory-ldap-api] branch master updated: o Many fixes in controls : hashCode/equals/toString
Date Thu, 25 Jan 2018 22:40:57 GMT
This is an automated email from the ASF dual-hosted git repository.

elecharny pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/directory-ldap-api.git


The following commit(s) were added to refs/heads/master by this push:
     new 3749602  o Many fixes in controls : hashCode/equals/toString
3749602 is described below

commit 3749602bf14d150428a7853997cd9b8e0ed8a07d
Author: Emmanuel L├ęcharny <elecharny@symas.com>
AuthorDate: Thu Jan 25 23:40:31 2018 +0100

    o Many fixes in controls : hashCode/equals/toString
---
 .../api/ldap/extras/controls/ad/AdDirSyncImpl.java | 14 +--
 .../ldap/extras/controls/ad/AdPolicyHintsImpl.java | 55 +++++++++++-
 .../syncrepl/syncDone/SyncDoneValueImpl.java       |  6 +-
 .../syncrepl/syncInfoValue/SyncInfoValueImpl.java  |  6 +-
 .../syncInfoValue/SyncRequestValueImpl.java        | 10 +--
 .../syncrepl/syncState/SyncStateValueImpl.java     | 12 +--
 .../transaction/TransactionSpecificationImpl.java  | 58 ++++++++++++-
 .../controls/vlv/VirtualListViewRequestImpl.java   | 12 ++-
 .../controls/vlv/VirtualListViewResponseImpl.java  | 12 ++-
 .../startTransaction/StartTransactionRequest.java  |  4 +-
 .../model/message/controls/EntryChangeImpl.java    | 11 ++-
 .../model/message/controls/PagedResultsImpl.java   | 17 ++--
 .../message/controls/PersistentSearchImpl.java     | 42 ++++++++-
 .../model/message/controls/ProxiedAuthzImpl.java   | 13 ++-
 .../message/controls/SortRequestControlImpl.java   | 99 +++++++++++++++++++++-
 .../message/controls/SortResponseControlImpl.java  | 19 +++--
 .../model/message/controls/SubentriesImpl.java     | 11 ++-
 17 files changed, 344 insertions(+), 57 deletions(-)

diff --git a/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/controls/ad/AdDirSyncImpl.java
b/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/controls/ad/AdDirSyncImpl.java
index dc35b39..f3c9269 100644
--- a/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/controls/ad/AdDirSyncImpl.java
+++ b/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/controls/ad/AdDirSyncImpl.java
@@ -147,9 +147,8 @@ public class AdDirSyncImpl extends AbstractControl implements AdDirSync
     @Override
     public int hashCode()
     {
-        int h = 37;
+        int h = super.hashCode();
 
-        h = h * 17 + super.hashCode();
         h = h * 17 + AdDirSyncFlag.getBitmask( flags );
         h = h * 17 + maxReturnLength;
 
@@ -169,21 +168,22 @@ public class AdDirSyncImpl extends AbstractControl implements AdDirSync
      * @see Object#equals(Object)
      */
     @Override
-    public boolean equals( Object o )
+    public boolean equals( Object other )
     {
-        if ( this == o )
+        if ( this == other )
         {
             return true;
         }
 
-        if ( !( o instanceof AdDirSync ) )
+        if ( !( other instanceof AdDirSync ) )
         {
             return false;
         }
 
-        AdDirSync otherControl = ( AdDirSync ) o;
+        AdDirSync otherControl = ( AdDirSync ) other;
 
-        return ( maxReturnLength == otherControl.getMaxReturnLength() )
+        return super.equals( other ) 
+            && ( maxReturnLength == otherControl.getMaxReturnLength() )
             && ( flags.equals( otherControl.getFlags() ) )
             && ( Arrays.equals( cookie, otherControl.getCookie() ) )
             && ( isCritical() == otherControl.isCritical() );
diff --git a/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/controls/ad/AdPolicyHintsImpl.java
b/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/controls/ad/AdPolicyHintsImpl.java
index 09cd7c3..28b1c76 100644
--- a/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/controls/ad/AdPolicyHintsImpl.java
+++ b/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/controls/ad/AdPolicyHintsImpl.java
@@ -33,7 +33,6 @@ public class AdPolicyHintsImpl extends AbstractControl implements AdPolicyHints
     /** This control OID */
     private int flags;
 
-
     /**
      * Creates an instance of AdPolicyHintsImpl
      */
@@ -61,4 +60,58 @@ public class AdPolicyHintsImpl extends AbstractControl implements AdPolicyHints
     {
         this.flags = flags;
     }
+    
+    
+    /**
+     * @see Object#hashCode()
+     */
+    @Override
+    public int hashCode()
+    {
+        int h = 37;
+
+        h = h * 17 + super.hashCode();
+        h = h * 17 + flags;
+
+        return h;
+    }
+
+
+    /**
+     * @see Object#equals(Object)
+     */
+    @Override
+    public boolean equals( Object o )
+    {
+        if ( this == o )
+        {
+            return true;
+        }
+
+        if ( !( o instanceof AdPolicyHints ) )
+        {
+            return false;
+        }
+
+        AdPolicyHints otherControl = ( AdPolicyHints ) o;
+
+        return super.equals( o ) && flags == otherControl.getFlags();
+    }
+
+
+    /**
+     * @see Object#toString()
+     */
+    @Override
+    public String toString()
+    {
+        StringBuilder sb = new StringBuilder();
+
+        sb.append( "    AdPolicyHints control :\n" );
+        sb.append( "        oid : " ).append( getOid() ).append( '\n' );
+        sb.append( "        critical : " ).append( isCritical() ).append( '\n' );
+        sb.append( "        flags : 0x" ).append( Integer.toHexString( flags ) ).append(
"\n" );
+
+        return sb.toString();
+    }
 }
\ No newline at end of file
diff --git a/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/controls/syncrepl/syncDone/SyncDoneValueImpl.java
b/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/controls/syncrepl/syncDone/SyncDoneValueImpl.java
index 14b83dd..8a38755 100644
--- a/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/controls/syncrepl/syncDone/SyncDoneValueImpl.java
+++ b/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/controls/syncrepl/syncDone/SyncDoneValueImpl.java
@@ -108,9 +108,8 @@ public class SyncDoneValueImpl extends AbstractControl implements SyncDoneValue
     @Override
     public int hashCode()
     {
-        int h = 37;
+        int h = super.hashCode();
 
-        h = h * 17 + super.hashCode();
         h = h * 17 + ( refreshDeletes ? 1 : 0 );
 
         if ( cookie != null )
@@ -143,7 +142,8 @@ public class SyncDoneValueImpl extends AbstractControl implements SyncDoneValue
 
         SyncDoneValue otherControl = ( SyncDoneValue ) o;
 
-        return ( refreshDeletes == otherControl.isRefreshDeletes() )
+        return super.equals( o )
+            && ( refreshDeletes == otherControl.isRefreshDeletes() )
             && ( Arrays.equals( cookie, otherControl.getCookie() ) )
             && ( isCritical() == otherControl.isCritical() );
     }
diff --git a/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/controls/syncrepl/syncInfoValue/SyncInfoValueImpl.java
b/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/controls/syncrepl/syncInfoValue/SyncInfoValueImpl.java
index 456a9b2..7e1f4c3 100644
--- a/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/controls/syncrepl/syncInfoValue/SyncInfoValueImpl.java
+++ b/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/controls/syncrepl/syncInfoValue/SyncInfoValueImpl.java
@@ -194,9 +194,8 @@ public class SyncInfoValueImpl extends AbstractControl implements SyncInfoValue
     @Override
     public int hashCode()
     {
-        int h = 37;
+        int h = super.hashCode();
 
-        h = h * 17 + super.hashCode();
         h = h * 17 + type.getValue();
         h = h * 17 + ( refreshDone ? 1 : 0 );
         h = h * 17 + ( refreshDeletes ? 1 : 0 );
@@ -281,7 +280,8 @@ public class SyncInfoValueImpl extends AbstractControl implements SyncInfoValue
             }
         }
 
-        return ( refreshDeletes == otherControl.isRefreshDeletes() )
+        return super.equals( o )
+            && ( refreshDeletes == otherControl.isRefreshDeletes() )
             && ( refreshDone == otherControl.isRefreshDone() )
             && ( type == otherControl.getType() )
             && ( Arrays.equals( cookie, otherControl.getCookie() ) ) 
diff --git a/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/controls/syncrepl/syncInfoValue/SyncRequestValueImpl.java
b/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/controls/syncrepl/syncInfoValue/SyncRequestValueImpl.java
index 398ae8b..4065c5a 100644
--- a/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/controls/syncrepl/syncInfoValue/SyncRequestValueImpl.java
+++ b/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/controls/syncrepl/syncInfoValue/SyncRequestValueImpl.java
@@ -154,9 +154,8 @@ public class SyncRequestValueImpl extends AbstractControl implements SyncRequest
     @Override
     public int hashCode()
     {
-        int h = 37;
+        int h = super.hashCode();
 
-        h = h * 17 + super.hashCode();
         h = h * 17 + ( isReloadHint ? 1 : 0 );
         h = h * 17 + mode.getValue();
 
@@ -178,9 +177,9 @@ public class SyncRequestValueImpl extends AbstractControl implements SyncRequest
     @Override
     public boolean equals( Object o )
     {
-        if ( !super.equals( o ) )
+        if ( this == o )
         {
-            return false;
+            return true;
         }
 
         if ( !( o instanceof SyncRequestValue ) )
@@ -190,7 +189,8 @@ public class SyncRequestValueImpl extends AbstractControl implements SyncRequest
 
         SyncRequestValue otherControl = ( SyncRequestValue ) o;
 
-        return ( mode == otherControl.getMode() )
+        return super.equals( o )
+            && ( mode == otherControl.getMode() )
             && ( isReloadHint == otherControl.isReloadHint() )
             && ( Arrays.equals( cookie, otherControl.getCookie() ) );
     }
diff --git a/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/controls/syncrepl/syncState/SyncStateValueImpl.java
b/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/controls/syncrepl/syncState/SyncStateValueImpl.java
index b37cddf..ccab048 100644
--- a/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/controls/syncrepl/syncState/SyncStateValueImpl.java
+++ b/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/controls/syncrepl/syncState/SyncStateValueImpl.java
@@ -131,9 +131,8 @@ public class SyncStateValueImpl extends AbstractControl implements SyncStateValu
     @Override
     public int hashCode()
     {
-        int h = 37;
+        int h = super.hashCode();
 
-        h = h * 17 + super.hashCode();
         h = h * 17 + type.getValue();
 
         if ( cookie != null )
@@ -162,11 +161,11 @@ public class SyncStateValueImpl extends AbstractControl implements SyncStateValu
     @Override
     public boolean equals( Object o )
     {
-        if ( !super.equals( o ) )
+        if ( this == o )
         {
-            return false;
+            return true;
         }
-
+        
         if ( !( o instanceof SyncStateValue ) )
         {
             return false;
@@ -174,7 +173,8 @@ public class SyncStateValueImpl extends AbstractControl implements SyncStateValu
 
         SyncStateValue otherControl = ( SyncStateValue ) o;
 
-        return ( type == otherControl.getSyncStateType() )
+        return super.equals( o )
+            && ( type == otherControl.getSyncStateType() )
             && ( Arrays.equals( entryUuid, otherControl.getEntryUUID() ) )
             && ( Arrays.equals( cookie, otherControl.getCookie() ) )
             && ( isCritical() == otherControl.isCritical() );
diff --git a/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/controls/transaction/TransactionSpecificationImpl.java
b/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/controls/transaction/TransactionSpecificationImpl.java
index 4e9f793..22aeba9 100644
--- a/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/controls/transaction/TransactionSpecificationImpl.java
+++ b/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/controls/transaction/TransactionSpecificationImpl.java
@@ -18,6 +18,8 @@
  */
 package org.apache.directory.api.ldap.extras.controls.transaction;
 
+import java.util.Arrays;
+
 import org.apache.directory.api.ldap.model.message.controls.AbstractControl;
 import org.apache.directory.api.util.Strings;
 
@@ -33,7 +35,6 @@ public class TransactionSpecificationImpl extends AbstractControl implements
Tra
     /** The Transaction Specification identifier */
     private byte[] identifier;
 
-
     /**
      * Default constructor
      */
@@ -66,6 +67,49 @@ public class TransactionSpecificationImpl extends AbstractControl implements
Tra
             System.arraycopy( identifier, 0, this.identifier, 0, identifier.length );
         }
     }
+
+
+    /**
+     * @see Object#hashCode()
+     */
+    @Override
+    public int hashCode()
+    {
+        int h = super.hashCode();
+
+        if ( identifier != null )
+        {
+            for ( byte b : identifier )
+            {
+                h = h * 17 + b;
+            }
+        }
+
+        return h;
+    }
+
+
+    /**
+     * @see Object#equals(Object)
+     */
+    @Override
+    public boolean equals( Object o )
+    {
+        if ( this == o )
+        {
+            return true;
+        }
+        
+        if ( !( o instanceof TransactionSpecification ) )
+        {
+            return false;
+        }
+
+        TransactionSpecification otherControl = ( TransactionSpecification ) o;
+
+        return super.equals( o )
+            && Arrays.equals( identifier, otherControl.getIdentifier() );
+    }
     
     
     /**
@@ -74,13 +118,21 @@ public class TransactionSpecificationImpl extends AbstractControl implements
Tra
     @Override
     public String toString()
     {
+        StringBuilder sb = new StringBuilder();
+
+        sb.append( "    Transaction Spcecification control :\n" );
+        sb.append( "        oid : " ).append( getOid() ).append( '\n' );
+        sb.append( "        critical : " ).append( isCritical() ).append( '\n' );
+        
         if ( identifier != null )
         {
-            return "Transaction specification ID=null";
+            sb.append( "        Transaction ID=null" ).append( '\n' );
         }
         else
         {
-            return "Transaction specification ID=" + Strings.dumpBytes( identifier );
+            sb.append( "        Transaction ID=" ).append( Strings.dumpBytes( identifier
) ).append( '\n' );
         }
+        
+        return sb.toString();
     }
 }
diff --git a/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/controls/vlv/VirtualListViewRequestImpl.java
b/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/controls/vlv/VirtualListViewRequestImpl.java
index a15248d..2305bfc 100644
--- a/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/controls/vlv/VirtualListViewRequestImpl.java
+++ b/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/controls/vlv/VirtualListViewRequestImpl.java
@@ -244,14 +244,20 @@ public class VirtualListViewRequestImpl extends AbstractControl implements
Virtu
     @Override
     public boolean equals( Object o )
     {
-        if ( !super.equals( o ) )
+        if ( this == o )
+        {
+            return true;
+        }
+        
+        if ( !( o instanceof VirtualListViewRequest ) )
         {
             return false;
         }
 
-        VirtualListViewRequestImpl otherControl = ( VirtualListViewRequestImpl ) o;
+        VirtualListViewRequest otherControl = ( VirtualListViewRequest ) o;
 
-        return ( beforeCount == otherControl.getBeforeCount() )
+        return super.equals( o )
+            && ( beforeCount == otherControl.getBeforeCount() )
             && ( afterCount == otherControl.getAfterCount() )
             && ( offset == otherControl.getOffset() )
             && ( contentCount == otherControl.getContentCount() )
diff --git a/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/controls/vlv/VirtualListViewResponseImpl.java
b/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/controls/vlv/VirtualListViewResponseImpl.java
index 3414fbe..88971b1 100644
--- a/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/controls/vlv/VirtualListViewResponseImpl.java
+++ b/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/controls/vlv/VirtualListViewResponseImpl.java
@@ -176,14 +176,20 @@ public class VirtualListViewResponseImpl extends AbstractControl implements
Virt
     @Override
     public boolean equals( Object o )
     {
-        if ( !super.equals( o ) )
+        if ( this == o )
+        {
+            return true;
+        }
+        
+        if ( !( o instanceof VirtualListViewRequest ) )
         {
             return false;
         }
 
-        VirtualListViewResponseImpl otherControl = ( VirtualListViewResponseImpl ) o;
+        VirtualListViewResponse otherControl = ( VirtualListViewResponse ) o;
 
-        return ( targetPosition == otherControl.getTargetPosition() )
+        return super.equals( o )
+            && ( targetPosition == otherControl.getTargetPosition() )
             && ( contentCount == otherControl.getContentCount() )
             && ( virtualListViewResult == otherControl.getVirtualListViewResult()
)
             && Arrays.equals( contextId, otherControl.getContextId() );
diff --git a/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/extended/startTransaction/StartTransactionRequest.java
b/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/extended/startTransaction/StartTransactionRequest.java
index 51e07b0..bda2dbe 100644
--- a/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/extended/startTransaction/StartTransactionRequest.java
+++ b/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/extended/startTransaction/StartTransactionRequest.java
@@ -24,7 +24,7 @@ import org.apache.directory.api.ldap.model.message.ExtendedRequest;
 
 
 /**
- * The TransactionRequest interface. This is for the RFC 5805 Start Transaction Request,
+ * The StartTransactionRequest interface. This is for the RFC 5805 Start Transaction Request,
  * which grammar is :
  * <pre>
  * ExtendedRequest ::= [APPLICATION 23] SEQUENCE {
@@ -38,6 +38,6 @@ import org.apache.directory.api.ldap.model.message.ExtendedRequest;
  */
 public interface StartTransactionRequest extends ExtendedRequest
 {
-    /** The OID for the Transaction extended operation request. */
+    /** The OID for the StartTransaction extended operation request. */
     String EXTENSION_OID = "1.3.6.1.1.21.1";
 }
\ No newline at end of file
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/controls/EntryChangeImpl.java
b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/controls/EntryChangeImpl.java
index d5f3f66..243ac1a 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/controls/EntryChangeImpl.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/controls/EntryChangeImpl.java
@@ -132,14 +132,21 @@ public class EntryChangeImpl extends AbstractControl implements EntryChange
     @Override
     public boolean equals( Object o )
     {
-        if ( !super.equals( o ) )
+        if ( this == o )
+        {
+            return true;
+        }
+        
+        if ( !( o instanceof EntryChange ) )
         {
             return false;
         }
 
         EntryChange otherControl = ( EntryChange ) o;
 
-        return ( changeNumber == otherControl.getChangeNumber() ) && ( changeType
== otherControl.getChangeType() )
+        return super.equals( o ) 
+            && ( changeNumber == otherControl.getChangeNumber() ) 
+            && ( changeType == otherControl.getChangeType() )
             && ( previousDn.equals( otherControl.getPreviousDn() ) );
     }
 
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/controls/PagedResultsImpl.java
b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/controls/PagedResultsImpl.java
index cf4e67b..2742b52 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/controls/PagedResultsImpl.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/controls/PagedResultsImpl.java
@@ -175,16 +175,23 @@ public class PagedResultsImpl extends AbstractControl implements PagedResults
      * @see Object#equals(Object)
      */
     @Override
-    public boolean equals( Object o )
+    public boolean equals( Object other )
     {
-        if ( !super.equals( o ) )
+        if ( this == other )
         {
-            return false;
+            return true;
         }
 
-        PagedResults otherControl = ( PagedResults ) o;
+        if ( !( other instanceof PagedResults ) )
+        {
+            return false;
+        }
+        
+        PagedResults otherControl = ( PagedResults ) other;
 
-        return ( size == otherControl.getSize() ) && Arrays.equals( cookie, otherControl.getCookie()
);
+        return super.equals( other ) 
+            && ( size == otherControl.getSize() ) 
+            && Arrays.equals( cookie, otherControl.getCookie() );
     }
 
 
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/controls/PersistentSearchImpl.java
b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/controls/PersistentSearchImpl.java
index 14e5d5d..4e8b861 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/controls/PersistentSearchImpl.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/controls/PersistentSearchImpl.java
@@ -19,7 +19,6 @@
  */
 package org.apache.directory.api.ldap.model.message.controls;
 
-
 /**
  * A persistence search object
  * 
@@ -155,6 +154,47 @@ public class PersistentSearchImpl extends AbstractControl implements
PersistentS
 
 
     /**
+     * @see Object#hashCode()
+     */
+    @Override
+    public int hashCode()
+    {
+        int h = super.hashCode();
+
+        h = h * 37 + ( changesOnly ? 1 : 0 );
+        h = h * 37 + ( returnECs ? 1 : 0 );
+        h = h * 37 + changeTypes;
+
+        return h;
+    }
+
+
+    /**
+     * @see Object#equals(Object)
+     */
+    @Override
+    public boolean equals( Object other )
+    {
+        if ( this == other )
+        {
+            return true;
+        }
+
+        if ( !( other instanceof PersistentSearch ) )
+        {
+            return false;
+        }
+        
+        PersistentSearch otherControl = ( PersistentSearch ) other;
+
+        return super.equals( other ) 
+            && ( changesOnly == otherControl.isChangesOnly() ) 
+            && ( returnECs == otherControl.isReturnECs() ) 
+            && ( changeTypes == otherControl.getChangeTypes() );
+    }
+
+
+    /**
      * Return a String representing this PSearchControl.
      */
     @Override
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/controls/ProxiedAuthzImpl.java
b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/controls/ProxiedAuthzImpl.java
index 6e25e72..bf4dcf8 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/controls/ProxiedAuthzImpl.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/controls/ProxiedAuthzImpl.java
@@ -126,15 +126,20 @@ public class ProxiedAuthzImpl extends AbstractControl implements ProxiedAuthz
     @Override
     public boolean equals( Object o )
     {
-        if ( !super.equals( o ) )
+        if ( this == o )
         {
-            return false;
+            return true;
         }
 
+        if ( !( o instanceof ProxiedAuthz ) )
+        {
+            return false;
+        }
+        
         ProxiedAuthz otherControl = ( ProxiedAuthz ) o;
 
-        return ( authzId == otherControl.getAuthzId() )
-            || ( ( authzId != null ) && authzId.equals( otherControl.getAuthzId()
) );
+        return super.equals( o )
+            && ( ( authzId == otherControl.getAuthzId() ) || ( ( authzId != null
) && authzId.equals( otherControl.getAuthzId() ) ) );
     }
 
 
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/controls/SortRequestControlImpl.java
b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/controls/SortRequestControlImpl.java
index b75179d..373ed76 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/controls/SortRequestControlImpl.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/controls/SortRequestControlImpl.java
@@ -80,6 +80,71 @@ public class SortRequestControlImpl extends AbstractControl implements
SortReque
         sortKeys.add( skey );
     }
 
+    
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public int hashCode()
+    {
+        int hash = super.hashCode();
+        
+        if ( sortKeys != null )
+        {
+            for ( SortKey sortKey : sortKeys )
+            {
+                hash = hash * 17 + sortKey.hashCode();
+            }
+        }
+        
+        return hash;
+    }
+
+    
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public boolean equals( Object o )
+    {
+        if ( this == o )
+        {
+            return true;
+        }
+        
+        if ( !( o instanceof SortRequest ) )
+        {
+            return false;
+        }
+        
+        SortRequest that = ( SortRequest ) o;
+        
+        if ( !super.equals( o ) )
+        {
+            return false;
+        }
+        
+        if ( sortKeys == null )
+        {
+            return that.getSortKeys() == null;
+        }
+        
+        if ( ( that.getSortKeys() == null ) || ( sortKeys.size() != that.getSortKeys().size()
) )
+        {
+            return false;
+        }
+        
+        for ( SortKey sortKey : that.getSortKeys() )
+        {
+            if ( !sortKeys.contains( sortKey ) )
+            {
+                return false;
+            }
+        }
+        
+        return true;
+    }
+
 
     /**
      * {@inheritDoc}
@@ -87,6 +152,38 @@ public class SortRequestControlImpl extends AbstractControl implements
SortReque
     @Override
     public String toString()
     {
-        return "SortRequestControlImpl [sortKeys=" + sortKeys + "]";
+        StringBuilder sb = new StringBuilder();
+
+        sb.append( "    Sort Request Control\n" );
+        sb.append( "        oid : " ).append( getOid() ).append( '\n' );
+        sb.append( "        critical : " ).append( isCritical() ).append( '\n' );
+        
+        if ( sortKeys != null )
+        {
+            sb.append( "        sortKeys : [" );
+            boolean isFirst = true;
+            
+            for ( SortKey sortKey : sortKeys )
+            {
+                if ( isFirst )
+                {
+                    isFirst = false;
+                }
+                else
+                {
+                    sb.append( ", " );
+                }
+                
+                sb.append( sortKey.getAttributeTypeDesc() );
+            }
+            
+            sb.append( "]\n" );
+        }
+        else
+        {
+            sb.append( "        sortKeys : null\n" );
+        }
+        
+        return sb.toString();
     }
 }
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/controls/SortResponseControlImpl.java
b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/controls/SortResponseControlImpl.java
index 99773eb..655ac2a 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/controls/SortResponseControlImpl.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/controls/SortResponseControlImpl.java
@@ -87,10 +87,10 @@ public class SortResponseControlImpl extends AbstractControl implements
SortResp
     @Override
     public int hashCode()
     {
-        final int prime = 31;
         int hash = super.hashCode();
-        hash = prime * hash + ( ( attributeName == null ) ? 0 : attributeName.hashCode()
);
-        hash = prime * hash + ( ( this.result == null ) ? 0 : this.result.hashCode() );
+        
+        hash = 37 * hash + ( ( attributeName == null ) ? 0 : attributeName.hashCode() );
+        hash = 37 * hash + ( ( this.result == null ) ? 0 : this.result.hashCode() );
         
         return hash;
     }
@@ -102,13 +102,23 @@ public class SortResponseControlImpl extends AbstractControl implements
SortResp
     @Override
     public boolean equals( Object o )
     {
-        if ( !super.equals( o ) )
+        if ( this == o )
+        {
+            return true;
+        }
+        
+        if ( !( o instanceof SortResponse ) )
         {
             return false;
         }
         
         SortResponse that = ( SortResponse ) o;
         
+        if ( !super.equals( o ) )
+        {
+            return false;
+        }
+        
         if ( result != that.getSortResult() )
         {
             return false;
@@ -135,5 +145,4 @@ public class SortResponseControlImpl extends AbstractControl implements
SortResp
     {
         return "SortResponseControlImpl [result=" + result + ", attributeName=" + attributeName
+ "]";
     }
-    
 }
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/controls/SubentriesImpl.java
b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/controls/SubentriesImpl.java
index 3d3fe9c..643c241 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/controls/SubentriesImpl.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/controls/SubentriesImpl.java
@@ -106,14 +106,19 @@ public class SubentriesImpl extends AbstractControl implements Subentries
     @Override
     public boolean equals( Object o )
     {
-        if ( !super.equals( o ) )
+        if ( this == o )
+        {
+            return true;
+        }
+        
+        if ( !( o instanceof Subentries ) )
         {
             return false;
         }
-
+        
         Subentries otherDecorator = ( Subentries ) o;
 
-        return visibility == otherDecorator.isVisible();
+        return super.equals( o ) && visibility == otherDecorator.isVisible();
     }
 
 

-- 
To stop receiving notification emails like this one, please contact
elecharny@apache.org.

Mime
View raw message