public boolean supports(Annotation annotation, Class clazz, PropertyDescriptor descriptor) {
return Basic.class.isInstance(annotation);
}
public void handleAnnotation(Annotation annotation, Class clazz, PropertyDescriptor descriptor, MutableBeanValidationConfiguration configuration) {
Basic basic = (Basic)annotation;
Set<Annotation> annotations = getAllPropertyAnnotations(clazz, descriptor);
// handling nullability only if more explicit validation annotations do not exit.
if (!contains(annotations, NotNull.class) &&
(!LibraryUtils.HIBERNATE_VALIDATOR_IN_CLASSPATH || !contains(annotations, org.hibernate.validator.NotNull.class))) {
if (!basic.optional()) {
PropertyValidationRule propertyRule = new PropertyValidationRule(descriptor.getName(), new NotNullValidationRule());
configuration.addPropertyRule(descriptor.getName(), propertyRule);
}
}