in bval-jsr/src/main/java/org/apache/bval/jsr/job/ValidationJob.java [198:225]
private ConstraintValidator getConstraintValidator(ConstraintD<?> constraint) {
return validatorContext.getOrComputeConstraintValidator(constraint, () -> {
final Class<? extends ConstraintValidator> constraintValidatorClass =
new ComputeConstraintValidatorClass<>(validatorContext.getConstraintsCache(), constraint,
getValidationTarget(), computeValidatedType(constraint)).get();
if (constraintValidatorClass == null) {
if (constraint.getComposingConstraints().isEmpty()) {
Exceptions.raise(UnexpectedTypeException::new, "No %s type located for non-composed constraint %s",
ConstraintValidator.class.getSimpleName(), constraint);
}
return NOOP_VALIDATOR;
}
ConstraintValidator constraintValidator = null;
Exception cause = null;
try {
constraintValidator =
validatorContext.getConstraintValidatorFactory().getInstance(constraintValidatorClass);
} catch (Exception e) {
cause = e;
}
if (constraintValidator == null) {
Exceptions.raise(ValidationException::new, cause, "Unable to get %s instance from %s",
constraintValidatorClass.getName(), validatorContext.getConstraintValidatorFactory());
}
return constraintValidator;
});
}