diff --git a/src/main/java/org/gcube/portlets/user/vremembers/shared/BelongingUser.java b/src/main/java/org/gcube/portlets/user/vremembers/shared/BelongingUser.java index df5a86b..5befd0f 100644 --- a/src/main/java/org/gcube/portlets/user/vremembers/shared/BelongingUser.java +++ b/src/main/java/org/gcube/portlets/user/vremembers/shared/BelongingUser.java @@ -1,6 +1,7 @@ package org.gcube.portlets.user.vremembers.shared; import java.io.Serializable; +import java.util.Comparator; @SuppressWarnings("serial") public class BelongingUser implements Serializable, Comparable { @@ -11,7 +12,7 @@ public class BelongingUser implements Serializable, Comparable { private String institution; private String profileLink; private boolean hasPhoto; - + public BelongingUser(String username, String fullName, String avatarId, String headline, String institution, String profileLink, boolean hasPhoto) { super(); @@ -22,6 +23,7 @@ public class BelongingUser implements Serializable, Comparable { this.institution = institution; this.hasPhoto = hasPhoto; this.profileLink = profileLink; + } public BelongingUser() { @@ -78,7 +80,7 @@ public class BelongingUser implements Serializable, Comparable { this.institution = institution; } - + public boolean hasPhoto() { return hasPhoto; } @@ -86,8 +88,8 @@ public class BelongingUser implements Serializable, Comparable { public void setHasPhoto(boolean hasPhoto) { this.hasPhoto = hasPhoto; } - - + + public String getProfileLink() { return profileLink; @@ -97,14 +99,28 @@ public class BelongingUser implements Serializable, Comparable { this.profileLink = profileLink; } + @Override public int compareTo(BelongingUser o) { - if (this.hasPhoto && !o.hasPhoto) + if (this.hasHeadline() && !o.hasHeadline()) { return -1; - if (!this.hasPhoto && o.hasPhoto) + } + if (!this.hasHeadline() && o.hasHeadline()) return 1; + + if ( (this.hasHeadline() && o.hasHeadline()) || ((!this.hasHeadline() && !o.hasHeadline())) ) { + if (this.hasPhoto && !o.hasPhoto) + return -1; + if (!this.hasPhoto && o.hasPhoto) + return 1; + return 0; + } return 0; } - + + private boolean hasHeadline() { + return (headline != null && headline.compareTo("") != 0); + } + }