/** * 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); }