final Collection<String> missingValid = new ArrayList<String>();
final Field[] fields = Reflection.INSTANCE.getDeclaredFields(beanClass);
for (final Field field : fields) {
MetaProperty metaProperty = metabean.getProperty(field.getName());
// create a property for those fields for which there is not yet a
// MetaProperty
if (!factoryContext.getFactory().getAnnotationIgnores().isIgnoreAnnotations(field)) {
AccessStrategy access = new FieldAccess(field);
boolean create = metaProperty == null;
if (create) {
metaProperty = addMetaProperty(metabean, access);
}
if (!annotationProcessor.processAnnotations(metaProperty, beanClass, field, access,
new AppendValidationToMeta(metaProperty)) && create) {
metabean.putProperty(metaProperty.getName(), null);
}
if (field.getAnnotation(ConvertGroup.class) != null) {
missingValid.add(field.getName());
}
}
}
final Method[] methods = Reflection.INSTANCE.getDeclaredMethods(beanClass);
for (final Method method : methods) {
if (method.isSynthetic() || method.isBridge()) {
continue;
}
String propName = null;
if (method.getParameterTypes().length == 0) {
propName = MethodAccess.getPropertyName(method);
}
if (propName != null) {
if (!factoryContext.getFactory().getAnnotationIgnores().isIgnoreAnnotations(method)) {
AccessStrategy access = new MethodAccess(propName, method);
MetaProperty metaProperty = metabean.getProperty(propName);
boolean create = metaProperty == null;
// create a property for those methods for which there is
// not yet a MetaProperty
if (create) {
metaProperty = addMetaProperty(metabean, access);
}
if (!annotationProcessor.processAnnotations(metaProperty, beanClass, method, access,
new AppendValidationToMeta(metaProperty)) && create) {
metabean.putProperty(propName, null);
}
}
}
}
addXmlConstraints(beanClass, metabean);
for (final String name : missingValid) {
final MetaProperty metaProperty = metabean.getProperty(name);
if (metaProperty != null && metaProperty.getFeature(JsrFeatures.Property.REF_CASCADE) == null) {
throw new ConstraintDeclarationException("@ConvertGroup needs @Valid");
}
}
missingValid.clear();
}