// check for duplicates in common params
Set<String> commonParamNames = new HashSet<String>();
if (commonParams != null) {
for (int i = 0; i < commonParams.length; i++) {
if (!commonParamNames.add(commonParams[i].getName())) {
throw new ResourceInitializationException(
ResourceInitializationException.DUPLICATE_CONFIGURATION_PARAMETER_NAME,
new Object[] { commonParams[i].getName(), getMetaData().getName(),
commonParams[i].getSourceUrlString() });
}
}
}
// check for duplicates in groups
ConfigurationGroup[] groups = cfgParamDecls.getConfigurationGroups();
if (groups != null) {
Map<String, Set<String>> groupToParamSetMap = new HashMap<String, Set<String>>(); // map from group name to HashSet of param names
// in that group
for (int i = 0; i < groups.length; i++) {
String[] names = groups[i].getNames();
for (int j = 0; j < names.length; j++) {
Set<String> paramNamesInGroup = groupToParamSetMap.get(names[j]);
if (paramNamesInGroup == null) {
// first time we've seen this group. create an entry and add common params
paramNamesInGroup = new HashSet<String>(commonParamNames);
}
// check for duplicate parameter names
ConfigurationParameter[] paramsInGroup = groups[i].getConfigurationParameters();
if (paramsInGroup != null) {
for (int k = 0; k < paramsInGroup.length; k++) {
if (!paramNamesInGroup.add(paramsInGroup[k].getName())) {
throw new ResourceInitializationException(
ResourceInitializationException.DUPLICATE_CONFIGURATION_PARAMETER_NAME,
new Object[] { paramsInGroup[k].getName(), getMetaData().getName(),
paramsInGroup[k].getSourceUrlString() });
}
}