@Nullable private static String getUserGroup(RosterEntry rosterEntry) { String group = null; for (RosterGroup rosterGroup : rosterEntry.getGroups()) { group = rosterGroup.getName(); } return group; }
static RosterPacket.Item toRosterItem(RosterEntry entry) { RosterPacket.Item item = new RosterPacket.Item(entry.getUser(), entry.getName()); item.setItemType(entry.getType()); item.setItemStatus(entry.getStatus()); // Set the correct group names for the item. for (RosterGroup group : entry.getGroups()) { item.addGroupName(group.getName()); } return item; }
/** * Returns an unmodifiable collection of the roster groups that this entry belongs to. * * @return an iterator for the groups this entry belongs to. */ public Collection<RosterGroup> getGroups() { List<RosterGroup> results = new ArrayList<RosterGroup>(); // Loop through all roster groups and find the ones that contain this // entry. This algorithm should be fine for (RosterGroup group : roster.getGroups()) { if (group.contains(this)) { results.add(group); } } return Collections.unmodifiableCollection(results); }
public String toString() { StringBuilder buf = new StringBuilder(); if (name != null) { buf.append(name).append(": "); } buf.append(user); Collection<RosterGroup> groups = getGroups(); if (!groups.isEmpty()) { buf.append(" ["); Iterator<RosterGroup> iter = groups.iterator(); RosterGroup group = iter.next(); buf.append(group.getName()); while (iter.hasNext()) { buf.append(", "); group = iter.next(); buf.append(group.getName()); } buf.append("]"); } return buf.toString(); }