Class ConstraintAnnotationVisitor
- All Implemented Interfaces:
ElementVisitor<Void,
List<AnnotationMirror>>
ElementVisitor
that visits annotated elements (type declarations,
methods and fields) and applies different ConstraintCheck
s 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, verbose
Fields inherited from class javax.lang.model.util.SimpleElementVisitor6
DEFAULT_VALUE
-
Constructor Summary
ConstructorDescriptionConstraintAnnotationVisitor
(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
reportIssues
Methods inherited from class javax.lang.model.util.ElementKindVisitor7
visitVariableAsResourceVariable
Methods inherited from class javax.lang.model.util.ElementKindVisitor6
visitExecutable, visitExecutableAsConstructor, visitExecutableAsInstanceInit, visitExecutableAsStaticInit, visitPackage, visitType, visitTypeAsRecord, visitTypeParameter, visitVariable, visitVariableAsBindingVariable, visitVariableAsEnumConstant, visitVariableAsExceptionParameter, visitVariableAsLocalVariable
Methods inherited from class javax.lang.model.util.SimpleElementVisitor6
defaultAction
Methods 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
@Valid
annotation may only be given at non-static, non-primitive JavaBeans getter methods.
- Overrides:
visitExecutableAsMethod
in 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
@Valid
annotation may only be given at non-static, non-primitive fields.
- Overrides:
visitVariableAsField
in 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:
visitVariableAsParameter
in 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:
visitTypeAsAnnotationType
in 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:
visitTypeAsClass
in 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:
visitTypeAsEnum
in 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:
visitTypeAsInterface
in classElementKindVisitor6<Void,
List<AnnotationMirror>>
-