From: Roland Häder Date: Sun, 18 Mar 2018 16:06:27 +0000 (+0100) Subject: Continued: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=cc1e04a8b3f9d4b9e875376735ca701fac1729de;p=juser-core.git Continued: - imlemented Comparable Signed-off-by: Roland Häder --- diff --git a/src/org/mxchange/jusercore/model/user/LoginUser.java b/src/org/mxchange/jusercore/model/user/LoginUser.java index e5d6eca..df3e020 100644 --- a/src/org/mxchange/jusercore/model/user/LoginUser.java +++ b/src/org/mxchange/jusercore/model/user/LoginUser.java @@ -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) { diff --git a/src/org/mxchange/jusercore/model/user/User.java b/src/org/mxchange/jusercore/model/user/User.java index b71412f..83c7e39 100644 --- a/src/org/mxchange/jusercore/model/user/User.java +++ b/src/org/mxchange/jusercore/model/user/User.java @@ -28,7 +28,7 @@ import org.mxchange.jusercore.model.user.status.UserAccountStatus; *

* @author Roland Häder */ -public interface User extends Serializable { +public interface User extends Comparable, Serializable { /** * Getter for account status