@SuppressWarnings("unchecked")
private void addXmlConstraints(Class<?> beanClass, MetaBean metabean)
throws IllegalAccessException, InvocationTargetException {
for (MetaConstraint<?, ? extends Annotation> meta : factoryContext.getFactory()
.getMetaConstraints(beanClass)) {
MetaProperty metaProperty;
if (meta.getAccessStrategy() == null) { // class level
metaProperty = null;
} else { // property level
metaProperty =
metabean.getProperty(meta.getAccessStrategy().getPropertyName());
if (metaProperty == null) {
metaProperty = addMetaProperty(metabean,
meta.getAccessStrategy().getPropertyName(),
meta.getAccessStrategy().getJavaType());
}
}
Class<? extends ConstraintValidator<? extends Annotation, ?>>[] validatorClasses =
findConstraintValidatorClasses(meta.getAnnotation(), null);
applyConstraint(
(Annotation) meta.getAnnotation(),
(Class<? extends ConstraintValidator<Annotation, ?>>[]) validatorClasses,
metaProperty, beanClass, meta.getAccessStrategy(),
new AppendValidationToMeta(metaProperty == null ? metabean
: metaProperty));
}
for (AccessStrategy access : factoryContext.getFactory().getValidAccesses(beanClass)) {
MetaProperty metaProperty = metabean.getProperty(access.getPropertyName());
if (metaProperty == null) {
metaProperty =
addMetaProperty(metabean, access.getPropertyName(), access.getJavaType());
}
processValid(metaProperty, access);