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 2015/06/13 10:58:00 UTC

svn commit: r1685223 - /directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/wrappers/ServerIdWrapper.java

Author: elecharny
Date: Sat Jun 13 08:57:59 2015
New Revision: 1685223

URL: http://svn.apache.org/r1685223
Log:
Added the missing clone/hashcode/equals methods

Modified:
    directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/wrappers/ServerIdWrapper.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=1685223&r1=1685222&r2=1685223&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 Sat Jun 13 08:57:59 2015
@@ -26,13 +26,13 @@ package org.apache.directory.studio.open
  * 
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public class ServerIdWrapper
+public class ServerIdWrapper implements Cloneable
 {
     /** The server ID */
-    int serverId;
+    private int serverId;
     
     /** The URL, if any */
-    String url;
+    private String url;
 
     /**
      * Creates a new instance of ServerIdWrapper.
@@ -104,6 +104,81 @@ public class ServerIdWrapper
     
     
     /**
+     * Clone the current object
+     */
+    public ServerIdWrapper clone()
+    {
+        try
+        {
+            return (ServerIdWrapper)super.clone();
+        }
+        catch ( CloneNotSupportedException e )
+        {
+            return null;
+        }
+    }
+
+    
+    /**
+     * @see Object#equals(Object)
+     */
+    public boolean equals( Object that )
+    {
+        // Quick test
+        if ( this == that )
+        {
+            return true;
+        }
+        
+        if ( that instanceof ServerIdWrapper )
+        {
+            ServerIdWrapper thatInstance = (ServerIdWrapper)that;
+            
+            if ( serverId != thatInstance.serverId )
+            {
+                return false;
+            }
+            
+            if ( url == thatInstance.url )
+            {
+                return true;
+            }
+            
+            if ( url != null )
+            {
+                return url.equals( thatInstance.url );
+            }
+            else
+            {
+                return thatInstance.url == null;
+            }
+        }
+        else
+        {
+            return false;
+        }
+    }
+
+    
+    /**
+     * @see Object#hashCode()
+     */
+    public int hashCode()
+    {
+        int h = 37;
+        
+        h += h*17 + serverId;
+        
+        if ( url != null )
+        {
+            h += h*17 + url.hashCode();
+        }
+        
+        return h;
+    }
+
+    
+    /**
      * @see Object#toString()
      */
     public String toString()