Class ConstraintAnnotationVisitor
- All Implemented Interfaces:
ElementVisitor<Void,List<AnnotationMirror>>
ElementVisitor that visits annotated elements (type declarations,
methods and fields) and applies different ConstraintChecks to them.
Each ConstraintCheckIssue occurred will be reported using the
Messager API.- Author:
- Gunnar Morling
-
Field Summary
Fields inherited from class org.hibernate.validator.ap.internal.AbstractElementVisitor
messager, verboseFields inherited from class javax.lang.model.util.SimpleElementVisitor6
DEFAULT_VALUE -
Constructor Summary
ConstructorsConstructorDescriptionConstraintAnnotationVisitor(ProcessingEnvironment processingEnvironment, MessagerAdapter messager, Configuration configuration) -
Method Summary
Modifier and TypeMethodDescriptionvisitExecutableAsMethod(ExecutableElement method, List<AnnotationMirror> mirrors) Checks whether the given annotations are correctly specified at the given method.visitTypeAsAnnotationType(TypeElement annotationType, List<AnnotationMirror> mirrors) Checks whether the given annotations are correctly specified at the given annotation type declaration.Checks whether the given annotations are correctly specified at the given class type declaration.Checks whether the given annotations are correctly specified at the given enum type declaration.Checks whether the given annotations are correctly specified at the given interface type declaration.visitVariableAsField(VariableElement annotatedField, List<AnnotationMirror> mirrors) Checks whether the given annotations are correctly specified at the given field.visitVariableAsParameter(VariableElement annotatedField, List<AnnotationMirror> mirrors) Checks whether the given annotations are correctly specified at the given method parameter.Methods inherited from class org.hibernate.validator.ap.internal.AbstractElementVisitor
reportIssuesMethods inherited from class javax.lang.model.util.ElementKindVisitor7
visitVariableAsResourceVariableMethods inherited from class javax.lang.model.util.ElementKindVisitor6
visitExecutable, visitExecutableAsConstructor, visitExecutableAsInstanceInit, visitExecutableAsStaticInit, visitPackage, visitType, visitTypeAsRecord, visitTypeParameter, visitVariable, visitVariableAsBindingVariable, visitVariableAsEnumConstant, visitVariableAsExceptionParameter, visitVariableAsLocalVariableMethods inherited from class javax.lang.model.util.SimpleElementVisitor6
defaultActionMethods inherited from class javax.lang.model.util.AbstractElementVisitor6
visit, visit, visitModule, visitRecordComponent, visitUnknown
-
Constructor Details
-
ConstraintAnnotationVisitor
public ConstraintAnnotationVisitor(ProcessingEnvironment processingEnvironment, MessagerAdapter messager, Configuration configuration)
-
-
Method Details
-
visitExecutableAsMethod
Checks whether the given annotations are correctly specified at the given method. The following checks are performed:
- Constraint annotations may only be given at non-static, JavaBeans getter methods which's return type is supported by the constraints.
-
The
@Validannotation may only be given at non-static, non-primitive JavaBeans getter methods.
- Overrides:
visitExecutableAsMethodin classElementKindVisitor6<Void,List<AnnotationMirror>>
-
visitVariableAsField
Checks whether the given annotations are correctly specified at the given field. The following checks are performed:
- Constraint annotations may only be given at non-static fields which's type is supported by the constraints.
-
The
@Validannotation may only be given at non-static, non-primitive fields.
- Overrides:
visitVariableAsFieldin classElementKindVisitor6<Void,List<AnnotationMirror>>
-
visitVariableAsParameter
public Void visitVariableAsParameter(VariableElement annotatedField, List<AnnotationMirror> mirrors) Checks whether the given annotations are correctly specified at the given method parameter. The following checks are performed:
- Constraint annotation parameter values are meaningful and valid.
- Overrides:
visitVariableAsParameterin classElementKindVisitor6<Void,List<AnnotationMirror>>
-
visitTypeAsAnnotationType
Checks whether the given annotations are correctly specified at the given annotation type declaration. The following checks are performed:
- The only annotation types allowed to be annotated with other constraint annotations are composed constraint annotation type declarations.
- Overrides:
visitTypeAsAnnotationTypein classElementKindVisitor6<Void,List<AnnotationMirror>>
-
visitTypeAsClass
Checks whether the given annotations are correctly specified at the given class type declaration. The following checks are performed:
- Constraint annotations may at types supported by the constraints.
- Overrides:
visitTypeAsClassin classElementKindVisitor6<Void,List<AnnotationMirror>>
-
visitTypeAsEnum
Checks whether the given annotations are correctly specified at the given enum type declaration. The following checks are performed:
- Constraint annotations may at types supported by the constraints.
- Overrides:
visitTypeAsEnumin classElementKindVisitor6<Void,List<AnnotationMirror>>
-
visitTypeAsInterface
Checks whether the given annotations are correctly specified at the given interface type declaration. The following checks are performed:
- Constraint annotations may at types supported by the constraints.
- Overrides:
visitTypeAsInterfacein classElementKindVisitor6<Void,List<AnnotationMirror>>
-