@SuppressWarnings("unchecked") private <T> List<T> getOptionsOfClass(OptionGroup p_group, Class<T> p_class) { List<T> result = new ArrayList<T>(); for (OptionDescription option : p_group.getOptions()) { if (option.getOption().getClass().equals(p_class)) { result.add((T) option.getOption()); } } for (OptionGroup group : p_group.getSubgroups()) { result.addAll(getOptionsOfClass(group, p_class)); } return result; }
private OptionGroup getOptionGroup(OptionGroup p_parent, String p_path) { OptionGroup result = null; List<OptionGroup> possibleSubGroups = m_optionGroups; if (p_parent != null) { possibleSubGroups = p_parent.getSubgroups(); } String groupName = ""; String theRestOfThePath = ""; if (p_path.contains("#")) { theRestOfThePath = p_path.substring(p_path.indexOf("#") + 1); groupName = p_path.substring(0, p_path.indexOf("#")); } else { groupName = p_path; theRestOfThePath = null; } for (OptionGroup optionsGroup : possibleSubGroups) { if (optionsGroup.getGroupName().equals(groupName)) { result = optionsGroup; break; } } if (result == null) { result = new OptionGroup(groupName); if (p_parent == null) { m_optionGroups.add(result); } else { p_parent.getSubgroups().add(result); } } if (theRestOfThePath != null) { return getOptionGroup(result, theRestOfThePath); } else { return result; } }