From cc1e04a8b3f9d4b9e875376735ca701fac1729de Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Sun, 18 Mar 2018 17:06:27 +0100 Subject: [PATCH] Continued: - imlemented Comparable MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Roland Häder --- .../jusercore/model/user/LoginUser.java | 17 +++++++++++++++-- src/org/mxchange/jusercore/model/user/User.java | 2 +- 2 files changed, 16 insertions(+), 3 deletions(-) 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 -- 2.39.5