@Override public int compareTo(GroupableActivity activity) { Long index = Long.valueOf(this.getDisplayIndex() == null ? "0" : this.getDisplayIndex()); Long otherIndex = Long.valueOf(activity.getDisplayIndex() == null ? "0" : activity.getDisplayIndex()); if (index == null) { if (otherIndex == null) { return 0; } else { return -1; } } else { if (otherIndex == null) { return 1; } else if (index instanceof Comparable) { // Return opposite, since higher index goes first return index.compareTo(otherIndex) * -1; } else { return 0; } } }
@Override public int compareTo(GroupableActivity activity) { Long index = Long.valueOf(this.getDisplayIndex() == null ? "0" : this.getDisplayIndex()); Long otherIndex = Long.valueOf(activity.getDisplayIndex() == null ? "0" : activity.getDisplayIndex()); if (index == null) { if (otherIndex == null) { return 0; } else { return -1; } } else { if (otherIndex == null) { return 1; } else if (index instanceof Comparable) { // Return opposite, since higher index goes first return index.compareTo(otherIndex) * -1; } else { return 0; } } } }
@Override public int compareTo(GroupableActivity activity) { Long index = Long.valueOf(this.getDisplayIndex() == null ? "0" : this.getDisplayIndex()); Long otherIndex = Long.valueOf(activity.getDisplayIndex() == null ? "0" : activity.getDisplayIndex()); if (index == null) { if (otherIndex == null) { return 0; } else { return -1; } } else { if (otherIndex == null) { return 1; } else if (index instanceof Comparable) { //Return opposite, since higher index goes first return index.compareTo(otherIndex) * -1; } else { return 0; } } } }
@Override public int compareTo(GroupableActivity activity) { Long index = Long.valueOf(this.getDisplayIndex() == null ? "0" : this.getDisplayIndex()); Long otherIndex = Long.valueOf(activity.getDisplayIndex() == null ? "0" : activity.getDisplayIndex()); if (index == null) { if (otherIndex == null) { return 0; } else { return -1; } } else { if (otherIndex == null) { return 1; } else if (index instanceof Comparable) { // Return opposite, since higher index goes first return index.compareTo(otherIndex) * -1; } else { return 0; } } } }
@Override public int compareTo(GroupableActivity activity) { Long index = Long.valueOf(this.getDisplayIndex() == null ? "0" : this.getDisplayIndex()); Long otherIndex = Long.valueOf(activity.getDisplayIndex() == null ? "0" : activity.getDisplayIndex()); if (index == null) { if (otherIndex == null) { return 0; } else { return -1; } } else { if (otherIndex == null) { return 1; } else if (index instanceof Comparable) { //Return opposite, since higher index goes first return index.compareTo(otherIndex) * -1; } else { return 0; } } } }
public GroupPojo(List<T> summaries, int id, String orcid, ExternalIDs ids){ setGroupId(id); Long maxDisplayIndex = null; setActivities(new ArrayList<T>()); for (T summary : summaries) { getActivities().add(summary); Long displayIndex = Long.parseLong(summary.getDisplayIndex()); if (maxDisplayIndex == null || displayIndex > maxDisplayIndex) { maxDisplayIndex = displayIndex; setActivePutCode(summary.getPutCode()); setActiveVisibility(summary.getVisibility().name()); setDefaultActivity(summary); } if (summary.getSource().retrieveSourcePath().equals(orcid)) { setUserVersionPresent(true); } } if (ids != null) { for (ExternalID extId : ids.getExternalIdentifier()) { if (extId.getRelationship() == null) { extId.setRelationship(Relationship.SELF); } externalIdentifiers.add(ActivityExternalIdentifier.valueOf(extId)); } } }