/** * Returns the nested ContactGroup of a given ContactGroup with associated name. * * @param group the parent ContactGroup. * @param groupName the name of the nested group. * @return the nested ContactGroup. If not found, null will be returned. */ private ContactGroup getSubContactGroup(ContactGroup group, String groupName) { final Iterator<ContactGroup> contactGroups = group.getContactGroups().iterator(); ContactGroup grp = null; while (contactGroups.hasNext()) { ContactGroup contactGroup = contactGroups.next(); if (contactGroup.getGroupName().equals(groupName)) { grp = contactGroup; break; } else if (contactGroup.getContactGroups().size() > 0) { grp = getSubContactGroup(contactGroup, groupName); if (grp != null) { break; } } } return grp; }
private ContactGroup getSubContactGroup(ContactGroup group, JList list) { for (ContactGroup g : group.getContactGroups()) { if (g.getList() == list) { return g; } // Search subs ContactGroup g1 = getSubContactGroup(g, list); if (g1 != null) { return g1; } } return null; }