};
}
@SuppressWarnings("unchecked")
private void bindAndValidate(Map<String, String> raw) throws BindException {
DataBinder dataBinder = new DataBinder(beanWrapper.getWrappedInstance());
dataBinder.setIgnoreUnknownFields(false);
dataBinder.setConversionService(conversionService);
MutablePropertySources mps = new MutablePropertySources();
mps.addFirst(new MapPropertySource("options", (Map) raw));
try {
dataBinder.bind(new PropertySourcesPropertyValues(mps));
}
catch (InvalidPropertyException e) {
dataBinder.getBindingResult().addError(new FieldError("options", e.getPropertyName(), e.getMessage()));
}
CustomValidatorBean validator = new CustomValidatorBean();
validator.afterPropertiesSet();
dataBinder.setValidator(validator);
Class<?>[] groups = determineGroupsToUse(beanWrapper.getWrappedInstance());
dataBinder.validate((Object[]) groups);
if (dataBinder.getBindingResult().hasErrors()) {
throw new BindException(dataBinder.getBindingResult());
}
}