private void parsePropertyLevelOverrides( List<GetterType> getters, Class<?> beanClass, String defaultPackage) { List<String> getterNames = newArrayList(); for (GetterType getterType : getters) { String getterName = getterType.getName(); if (getterNames.contains(getterName)) { throw log.getIsDefinedTwiceInMappingXmlForBeanException(getterName, beanClass.getName()); } else { getterNames.add(getterName); } boolean containsMethod = ReflectionHelper.containsMethodWithPropertyName(beanClass, getterName); if (!containsMethod) { throw log.getBeanDoesNotContainThePropertyException(beanClass.getName(), getterName); } final Method method = ReflectionHelper.getMethodFromPropertyName(beanClass, getterName); // ignore annotations boolean ignoreGetterAnnotation = getterType.getIgnoreAnnotations() == null ? false : getterType.getIgnoreAnnotations(); if (ignoreGetterAnnotation) { annotationProcessingOptions.ignorePropertyLevelConstraintAnnotationsOnMember(method); } // valid if (getterType.getValid() != null) { addCascadedMember(beanClass, method); } // constraints for (ConstraintType constraint : getterType.getConstraint()) { MetaConstraint<?> metaConstraint = createMetaConstraint(constraint, beanClass, method, defaultPackage); addMetaConstraint(beanClass, metaConstraint); } } }
private void parseFieldLevelOverrides( List<FieldType> fields, Class<?> beanClass, String defaultPackage) { List<String> fieldNames = newArrayList(); for (FieldType fieldType : fields) { String fieldName = fieldType.getName(); if (fieldNames.contains(fieldName)) { throw log.getIsDefinedTwiceInMappingXmlForBeanException(fieldName, beanClass.getName()); } else { fieldNames.add(fieldName); } final boolean containsField = ReflectionHelper.containsDeclaredField(beanClass, fieldName); if (!containsField) { throw log.getBeanDoesNotContainTheFieldException(beanClass.getName(), fieldName); } final Field field = ReflectionHelper.getDeclaredField(beanClass, fieldName); // ignore annotations boolean ignoreFieldAnnotation = fieldType.getIgnoreAnnotations() == null ? false : fieldType.getIgnoreAnnotations(); if (ignoreFieldAnnotation) { annotationProcessingOptions.ignorePropertyLevelConstraintAnnotationsOnMember(field); } // valid if (fieldType.getValid() != null) { addCascadedMember(beanClass, field); } // constraints for (ConstraintType constraint : fieldType.getConstraint()) { MetaConstraint<?> metaConstraint = createMetaConstraint(constraint, beanClass, field, defaultPackage); addMetaConstraint(beanClass, metaConstraint); } } }