use of io.micronaut.core.annotation.AnnotatedElement in project micronaut-core by micronaut-projects.
the class DefaultValidator method validatePropertyInternal.
private <T> void validatePropertyInternal(@Nullable Class<T> rootBeanClass, @Nullable T rootBean, @Nullable Object object, @NonNull DefaultConstraintValidatorContext context, @NonNull Set<ConstraintViolation<Object>> overallViolations, @NonNull Class propertyType, @NonNull AnnotatedElement constrainedProperty, @Nullable Object propertyValue) {
final AnnotationMetadata annotationMetadata = constrainedProperty.getAnnotationMetadata();
final List<Class<? extends Annotation>> constraintTypes = annotationMetadata.getAnnotationTypesByStereotype(Constraint.class);
for (Class<? extends Annotation> constraintType : constraintTypes) {
ValueExtractor<Object> valueExtractor = null;
if (propertyValue != null && !annotationMetadata.hasAnnotation(Valid.class)) {
// noinspection unchecked
valueExtractor = valueExtractorRegistry.findUnwrapValueExtractor((Class<Object>) propertyValue.getClass()).orElse(null);
}
if (valueExtractor != null) {
valueExtractor.extractValues(propertyValue, (SimpleValueReceiver) (nodeName, extractedValue) -> valueConstraintOnProperty(rootBeanClass, rootBean, object, context, overallViolations, constrainedProperty, propertyType, extractedValue, constraintType));
} else {
valueConstraintOnProperty(rootBeanClass, rootBean, object, context, overallViolations, constrainedProperty, propertyType, propertyValue, constraintType);
}
}
}
Aggregations