class ErrorDescriptorBuilderFinder {

    @SuppressWarnings("unchecked")
    public ValidationErrorDescriptorBuilder find(final ConstraintViolation violation) {
        ValidationErrorDescriptorBuilder validationErrorDescriptorBuilder = null;
        //Tries to check whether constraint validator class is a builder itself
        final ConstraintDescriptor constraintDescriptor = violation.getConstraintDescriptor();
        final List<Class<ConstraintValidator>> constraintValidatorClasses =
                constraintDescriptor.getConstraintValidatorClasses();
        if (constraintValidatorClasses != null) {
            for (Class<ConstraintValidator> constraintValidatorClass : constraintValidatorClasses) {
                if (ValidationErrorDescriptorBuilder.class.isAssignableFrom(constraintValidatorClass)) {
                    try {
                        final ConstraintValidator validator = constraintValidatorClass.newInstance();
                        validator.initialize(constraintDescriptor.getAnnotation());
                        validationErrorDescriptorBuilder = (ValidationErrorDescriptorBuilder) validator;
                        break;
                    } catch (Exception e) {
                        throw new IllegalStateException("Failed to instantiate validator", e);
                    }
                }
            }
        }
        //Tries to check if there are registered validator for default validation annotations.
        if (validationErrorDescriptorBuilder == null) {
            validationErrorDescriptorBuilder = genericTypeProcessorRegistry.
                    getTypeProcessor(constraintDescriptor.getAnnotation().getClass().getInterfaces()[0],
                            ValidationErrorDescriptorBuilder.class, false);
        }

        //Return default validator by default.
        if (validationErrorDescriptorBuilder == null) {
            validationErrorDescriptorBuilder = new DefaultConstraintValidationErrorDescriptorBuilder();
        }

        return validationErrorDescriptorBuilder;
    }

}