Merge "HostTracker Bundle Separation"
[controller.git] / opendaylight / usermanager / src / main / java / org / opendaylight / controller / usermanager / internal / UserConfig.java
index fd491fe880c36d928f2ca07eb52587d2355ba6c9..c7ddd4a6ecfd2918508924fe0fc78be2339268eb 100644 (file)
@@ -15,8 +15,6 @@ import java.util.List;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
-import org.apache.commons.lang3.builder.EqualsBuilder;
-import org.apache.commons.lang3.builder.HashCodeBuilder;
 import org.opendaylight.controller.sal.authorization.AuthResultEnum;
 import org.opendaylight.controller.sal.utils.Status;
 import org.opendaylight.controller.sal.utils.StatusCode;
@@ -51,7 +49,7 @@ public class UserConfig implements Serializable {
         this.roles = (roles == null) ? new ArrayList<String>()
                 : new ArrayList<String>(roles);
     }
-    
+
     public String getUser() {
         return user;
     }
@@ -66,12 +64,40 @@ public class UserConfig implements Serializable {
 
     @Override
     public int hashCode() {
-        return HashCodeBuilder.reflectionHashCode(this);
+        final int prime = 31;
+        int result = 1;
+        result = prime * result
+                + ((password == null) ? 0 : password.hashCode());
+        result = prime * result + ((roles == null) ? 0 : roles.hashCode());
+        result = prime * result + ((user == null) ? 0 : user.hashCode());
+        return result;
     }
 
     @Override
     public boolean equals(Object obj) {
-        return EqualsBuilder.reflectionEquals(this, obj);
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        UserConfig other = (UserConfig) obj;
+        if (password == null) {
+            if (other.password != null)
+                return false;
+        } else if (!password.equals(other.password))
+            return false;
+        if (roles == null) {
+            if (other.roles != null)
+                return false;
+        } else if (!roles.equals(other.roles))
+            return false;
+        if (user == null) {
+            if (other.user != null)
+                return false;
+        } else if (!user.equals(other.user))
+            return false;
+        return true;
     }
 
     @Override
@@ -135,24 +161,24 @@ public class UserConfig implements Serializable {
             return new Status(StatusCode.BADREQUEST,
                     "Current password is incorrect");
         }
-        
+
         // Create a new object with the proposed modifications
         UserConfig proposed = new UserConfig();
         proposed.user = this.user;
         proposed.password = (newPassword != null)? newPassword : this.password;
         proposed.roles = (newRoles != null)? newRoles : this.roles;
-        
+
         // Validate it
         Status status = proposed.validate();
         if (!status.isSuccess()) {
             return status;
         }
-        
+
         // Accept the modifications
         this.user = proposed.user;
         this.password = proposed.password;
         this.roles = new ArrayList<String>(proposed.roles);
-        
+
         return status;
     }
 
@@ -166,7 +192,7 @@ public class UserConfig implements Serializable {
         }
         return locResponse;
     }
-    
+
     protected String getRolesString() {
         StringBuffer buffer = new StringBuffer();
         if (!roles.isEmpty()) {