示例#1
0
  /**
   * Returns the group that is parent of the specified mockGroup or null if no parent was found.
   *
   * @param mockGroup the group whose parent we're looking for.
   * @return the MockContactGroup instance that mockGroup belongs to or null if no parent was found.
   */
  public MockContactGroup findGroupParent(MockContactGroup mockGroup) {
    if (subGroups.contains(mockGroup)) return this;

    Iterator<ContactGroup> subGroupsIter = subgroups();
    while (subGroupsIter.hasNext()) {
      MockContactGroup subgroup = (MockContactGroup) subGroupsIter.next();

      MockContactGroup parent = subgroup.findGroupParent(mockGroup);
      if (parent != null) return parent;
    }
    return null;
  }