]> git.argeo.org Git - lgpl/argeo-commons.git/blobdiff - security/runtime/org.argeo.security.core/src/main/java/org/argeo/security/SimpleArgeoUser.java
Improve Security
[lgpl/argeo-commons.git] / security / runtime / org.argeo.security.core / src / main / java / org / argeo / security / SimpleArgeoUser.java
index ca7229c2b27cef7770295f84500ba54d98ccd2b8..c021f8e4453a8e1ae61975c7839c644c9f9d7288 100644 (file)
@@ -28,7 +28,8 @@ import org.argeo.ArgeoException;
  * Read-write implementation of an Argeo user. Typically initialized with a
  * generic instance (read-only9 in order to modify a user.
  */
-public class SimpleArgeoUser implements ArgeoUser, Serializable {
+public class SimpleArgeoUser implements ArgeoUser, Serializable,
+               Comparable<ArgeoUser> {
        private static final long serialVersionUID = 1L;
 
        private String username;
@@ -70,24 +71,27 @@ public class SimpleArgeoUser implements ArgeoUser, Serializable {
                                                "Could not find a user nature of type " + type);
                }
 
-               // for (int i = 0; i < userNatures.size(); i++) {
-               // String type = userNatures.get(i).getType();
-               // boolean found = false;
-               // for (int j = 0; j < userNatures.size(); j++) {
-               // String newType = userNaturesData.get(j).getType();
-               // if (type.equals(newType))
-               // found = true;
-               // }
-               // if (!found)
-               // throw new ArgeoException(
-               // "Could not find a user nature of type " + type);
-               // }
-
                for (String key : userNatures.keySet()) {
                        userNatures.put(key, userNaturesData.get(key));
                }
        }
 
+       @Override
+       public boolean equals(Object obj) {
+               if (!(obj instanceof ArgeoUser))
+                       return false;
+               return ((ArgeoUser) obj).getUsername().equals(username);
+       }
+
+       public int compareTo(ArgeoUser o) {
+               return username.compareTo(o.getUsername());
+       }
+
+       @Override
+       public int hashCode() {
+               return username.hashCode();
+       }
+
        @Override
        public String toString() {
                return username;