directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1685684 - in /directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/wrappers: ServerIdWrapper.java SsfWrapper.java
Date Mon, 15 Jun 2015 22:44:23 GMT
Author: elecharny
Date: Mon Jun 15 22:44:23 2015
New Revision: 1685684

URL: http://svn.apache.org/r1685684
Log:
Added the Comparator interface and its implementation

Modified:
    directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/wrappers/ServerIdWrapper.java
    directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/wrappers/SsfWrapper.java

Modified: directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/wrappers/ServerIdWrapper.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/wrappers/ServerIdWrapper.java?rev=1685684&r1=1685683&r2=1685684&view=diff
==============================================================================
--- directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/wrappers/ServerIdWrapper.java
(original)
+++ directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/wrappers/ServerIdWrapper.java
Mon Jun 15 22:44:23 2015
@@ -31,7 +31,7 @@ import org.apache.directory.api.util.Str
  * 
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public class ServerIdWrapper implements Cloneable
+public class ServerIdWrapper implements Cloneable, Comparable<ServerIdWrapper>
 {
     /** The server ID */
     private int serverId;
@@ -213,6 +213,36 @@ public class ServerIdWrapper implements
         return h;
     }
 
+
+    /**
+     * @see Comparable#compareTo()
+     */
+    public int compareTo( ServerIdWrapper that )
+    {
+        if ( that == null )
+        {
+            return 1;
+        }
+        
+        // Check the serverId first
+        if ( serverId == that.serverId )
+        {
+            // Now, compare the url
+            if ( Strings.isEmpty( url ) )
+            {
+                return 0;
+            }
+            else
+            {
+                return url.compareToIgnoreCase( that.url );
+            }
+        }
+        else
+        {
+            return serverId - that.serverId;
+        }
+    }
+    
     
     /**
      * @see Object#toString()

Modified: directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/wrappers/SsfWrapper.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/wrappers/SsfWrapper.java?rev=1685684&r1=1685683&r2=1685684&view=diff
==============================================================================
--- directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/wrappers/SsfWrapper.java
(original)
+++ directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/wrappers/SsfWrapper.java
Mon Jun 15 22:44:23 2015
@@ -32,7 +32,7 @@ import org.apache.directory.studio.openl
  * 
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public class SsfWrapper implements Cloneable
+public class SsfWrapper implements Cloneable, Comparable<SsfWrapper>
 {
     /** The feature */
     private SsfFeatureEnum feature;
@@ -257,6 +257,30 @@ public class SsfWrapper implements Clone
         }
     }
 
+
+    /**
+     * @see Comparable#compareTo()
+     */
+    public int compareTo( SsfWrapper that )
+    {
+        // Compare by feature first then by nbBits
+        if ( that == null )
+        {
+            return 1;
+        }
+        
+        int comp = feature.getText().compareTo( that.feature.getText() );
+        
+        if ( comp == 0 )
+        {
+            return nbBits - that.nbBits;
+        }
+        else
+        {
+            return comp;
+        }
+    }
+
 
     /**
      * @see Object#toString()



Mime
View raw message