Set<String> allowedAttributes) {
Set<String> foundAttributes = Sets.newHashSet();
for (String attrBundle : attributeBundles) {
Parameter parameter = template.getParameterByPrimary(attrBundle);
if (parameter == null || !(parameter.getType() instanceof BundleType)) {
alertSink.add(new InvalidAttrBundleError(node, attrBundle));
continue;
}
for (Map.Entry<String, AttributeValidator> attr :
((BundleType) parameter.getType()).getAttrMap().entrySet()) {
AttributeValidator validator = validatorMap.get(attr.getKey());
if (validator == null) {
// no validator match, so we either already have seen this
// attribute or this attribute isn't allowed at all
if (allowedAttributes.contains(attr.getKey())) {
alertSink.add(new DuplicateAttributeError(node, attrBundle,
attr.getKey()));
} else {
alertSink.add(new UnknownAttributeError(node, attr.getKey()));
}
} else if (!validator.equals(attr.getValue())) {
alertSink.add(new MismatchedAttributeValidatorsError(
node, attr.getKey(), parameter.getPrimaryName()));
} else {
foundAttributes.add(attr.getKey());
}
}
}