]> git.mxchange.org Git - juser-core.git/commitdiff
Continued:
authorRoland Häder <roland@mxchange.org>
Sun, 18 Mar 2018 16:06:27 +0000 (17:06 +0100)
committerRoland Häder <roland@mxchange.org>
Sun, 18 Mar 2018 16:06:27 +0000 (17:06 +0100)
- imlemented Comparable

Signed-off-by: Roland Häder <roland@mxchange.org>
src/org/mxchange/jusercore/model/user/LoginUser.java
src/org/mxchange/jusercore/model/user/User.java

index e5d6eca9673a9187ac116747b87cdbc6cd82b14a..df3e0203173c341bcc3658b14226bfb66fef3a7b 100644 (file)
@@ -168,8 +168,6 @@ public class LoginUser implements User {
         * Default constructor
         */
        public LoginUser () {
-               // Default is invisible
-               this.userProfileMode = ProfileMode.INVISIBLE;
        }
 
        /**
@@ -222,6 +220,21 @@ public class LoginUser implements User {
                this.userContact = userContact;
        }
 
+       @Override
+       public int compareTo (final User user) {
+               // Checkparameter and return 0 if equal
+               if (null == user) {
+                       // Should not happen
+                       throw new NullPointerException("user is null"); //NOI18N
+               } else if (Objects.equals(this, user)) {
+                       // Same object
+                       return 0;
+               }
+
+               // There can only be one user per user name
+               return this.getUserName().compareTo(user.getUserName());
+       }
+
        @Override
        public boolean equals (final Object object) {
                if (null == object) {
index b71412f791e4f703f92dbcfa28593ffa6af9c4a4..83c7e392d8d23549850107cd59f5d693c5656c65 100644 (file)
@@ -28,7 +28,7 @@ import org.mxchange.jusercore.model.user.status.UserAccountStatus;
  * <p>
  * @author Roland Häder<roland@mxchange.org>
  */
-public interface User extends Serializable {
+public interface User extends Comparable<User>, Serializable {
 
        /**
         * Getter for account status