Map<String, String>> validators) {
if (!propertyType.isValid(value)) {
result.addFailureMessage(property, "Property was expected to be of type " + propertyType.getName());
}
for (Map.Entry<Validator, Map<String, String>> validatorEntry : validators.entrySet()) {
Validator validator = validatorEntry.getKey();
Map<String, String> arguments = validatorEntry.getValue();
try {
String validatorMessage = validator.validate(value, arguments);
if (validatorMessage != null) {
if (validatorMessage.isEmpty()) {
validatorMessage = "Property does not contain a valid value for the " + validator
.getClass().getName() + " validator";
}
result.addFailureMessage(property, validatorMessage);
}
} catch (SlingValidationException e) {
// wrap in another SlingValidationException to include information about the property
throw new SlingValidationException("Could not call validator " + validator
.getClass().getName() + " for resourceProperty " + property, e);
}
}
}