@Override
@SuppressWarnings({ "rawtypes", "unchecked" })
public boolean isValid(Rewrite event, EvaluationContext context, Object value)
{
Validator validator = null;
// let one of the SPI implementations build the validator
Iterator<ValidatorProvider> providers = ServiceLoader.load(ValidatorProvider.class).iterator();
while (providers.hasNext()) {
ValidatorProvider provider = providers.next();
if (targetType != null) {
validator = provider.getByTargetType(targetType);
}
else if (validatorType != null) {
validator = provider.getByValidatorType(validatorType);
}
else {
validator = provider.getByValidatorId(validatorId);
}
if (validator != null) {
break;
}
}
Assert.notNull(validator, "Got no validator from any ValidatorProvider for: " + this.toString());
return validator.isValid(event, context, value);
}