public class ConstraintHelper extends Object
| Modifier and Type | Class and Description |
|---|---|
static class |
ConstraintHelper.AnnotationProcessorConstraintTarget
The validation target of a constraint annotation.
|
static class |
ConstraintHelper.AnnotationProcessorValidationTarget
Defines the object on which a validation is targeted.
|
static class |
ConstraintHelper.AnnotationType
The type of an annotation with respect to the BV API.
|
static class |
ConstraintHelper.ConstraintCheckResult
Possible results of a constraint check as returned by
checkConstraint(DeclaredType, TypeMirror). |
| Constructor and Description |
|---|
ConstraintHelper(Types typeUtils,
AnnotationApiHelper annotationApiHelper) |
| Modifier and Type | Method and Description |
|---|---|
ConstraintHelper.ConstraintCheckResult |
checkConstraint(DeclaredType constraintAnnotationType,
TypeMirror typeOfAnnotatedElement)
Checks whether the given annotation type (which must be a
constraint annotation type) may be specified at elements of the specified
type.
|
ConstraintHelper.ConstraintCheckResult |
checkCrossParameterTypes(DeclaredType constraintAnnotationType)
Check that a constraint has at most one cross-parameter validator that resolves to Object or Object[].
|
ConstraintHelper.AnnotationType |
getAnnotationType(AnnotationMirror annotationMirror)
Returns the
ConstraintHelper.AnnotationType of the given annotation. |
List<AnnotationMirror> |
getPartsOfMultiValuedConstraint(AnnotationMirror annotationMirror)
Returns a list with the constraint annotations contained in the given
array-valued annotation mirror.
|
Set<ConstraintHelper.AnnotationProcessorValidationTarget> |
getSupportedValidationTargets(DeclaredType constraintAnnotationType)
Returns the set of
AnnotationProcessorValidationTarget supported by the given constraint annotation type. |
boolean |
isComposedConstraint(TypeElement element)
Checks whether the given type element represents a composed constraint or not.
|
boolean |
isConstraintAnnotation(Element element)
Checks whether the given type element represents a constraint annotation
or not.
|
ConstraintHelper.AnnotationProcessorValidationTarget |
resolveValidationTarget(ExecutableElement element,
AnnotationMirror annotation)
Resolve the actual
AnnotationProcessorValidationTarget of a constraint annotation, when applied to a method/constructor. |
public ConstraintHelper(Types typeUtils, AnnotationApiHelper annotationApiHelper)
public boolean isConstraintAnnotation(Element element)
@Constraint meta-annotation (which is only allowed at annotation
declarations).element - The element of interest.public ConstraintHelper.AnnotationType getAnnotationType(AnnotationMirror annotationMirror)
ConstraintHelper.AnnotationType of the given annotation.annotationMirror - The annotation mirror of interest.public List<AnnotationMirror> getPartsOfMultiValuedConstraint(AnnotationMirror annotationMirror)
annotationMirror - An array-valued annotation mirror (meaning it has an
array-typed attribute with name "value").public ConstraintHelper.ConstraintCheckResult checkConstraint(DeclaredType constraintAnnotationType, TypeMirror typeOfAnnotatedElement)
constraintAnnotationType - A constraint annotation type.typeOfAnnotatedElement - A type which with an element is annotated.public boolean isComposedConstraint(TypeElement element)
element - The type element of interest. Must not be null.public ConstraintHelper.AnnotationProcessorValidationTarget resolveValidationTarget(ExecutableElement element, AnnotationMirror annotation)
AnnotationProcessorValidationTarget of a constraint annotation, when applied to a method/constructor.
When the annotation supports multiple ConstraintHelper.AnnotationProcessorValidationTargets (i.e. it is both cross-parameter and generic), the actual target is resolved using the
'validationAppliesTo()' attribute of the annotation.
element - the method/constructor on which the annotation is appliedannotation - the constraint annotationAnnotationProcessorValidationTarget, null if the target cannot be inferredpublic Set<ConstraintHelper.AnnotationProcessorValidationTarget> getSupportedValidationTargets(DeclaredType constraintAnnotationType)
AnnotationProcessorValidationTarget supported by the given constraint annotation type.
A constraint annotation can support ConstraintHelper.AnnotationProcessorValidationTarget.ANNOTATED_ELEMENT, ConstraintHelper.AnnotationProcessorValidationTarget.PARAMETERS or both.
constraintAnnotationType - the constraint annotation typeAnnotationProcessorValidationTargetspublic ConstraintHelper.ConstraintCheckResult checkCrossParameterTypes(DeclaredType constraintAnnotationType)
constraintAnnotationType - the constraint typeConstraintCheckResult#MULTIPLE_VALIDATORS_FOUND if the constraint has more than one cross-parameter validator,
ConstraintCheckResult#DISALLOWED if the constraint has one cross-parameter validator with a wrong generic type,
ConstraintCheckResult#ALLOWED otherwiseCopyright © 2007-2021 Red Hat, Inc. All Rights Reserved