public class ConstraintHelper extends Object
Modifier and Type | Field and Description |
---|---|
static String |
GROUPS |
static String |
MESSAGE |
static String |
PAYLOAD |
static String |
VALIDATION_APPLIES_TO |
Constructor and Description |
---|
ConstraintHelper() |
Modifier and Type | Method and Description |
---|---|
void |
clear() |
<A extends Annotation> |
findValidatorDescriptors(Class<A> annotationType,
ValidationTarget validationTarget)
Returns those validator descriptors for the given constraint annotation
matching the given target.
|
<A extends Annotation> |
getAllValidatorDescriptors(Class<A> annotationType)
Returns the constraint validator classes for the given constraint
annotation type, as retrieved from
Constraint.validatedBy() ,
internally registered validators for built-in constraints
XML configuration and
programmatically registered validators (see
ConstraintMapping.constraintDefinition(Class) ).
The result is cached internally. |
<A extends Annotation> |
getConstraintsFromMultiValueConstraint(A multiValueConstraint)
Returns the constraints which are part of the given multi-value constraint.
|
boolean |
isConstraintAnnotation(Class<? extends Annotation> annotationType)
Checks whether the specified annotation is a valid constraint annotation.
|
boolean |
isConstraintComposition(Class<? extends Annotation> annotationType) |
boolean |
isJdkAnnotation(Class<? extends Annotation> annotation) |
boolean |
isMultiValueConstraint(Class<? extends Annotation> annotationType)
Checks whether a given annotation is a multi value constraint or not.
|
<A extends Annotation> |
putValidatorDescriptors(Class<A> annotationType,
List<ConstraintValidatorDescriptor<A>> validatorDescriptors,
boolean keepExistingClasses)
Registers the given validator descriptors with the given constraint
annotation type.
|
public static final String GROUPS
public static final String PAYLOAD
public static final String MESSAGE
public static final String VALIDATION_APPLIES_TO
public <A extends Annotation> List<ConstraintValidatorDescriptor<A>> getAllValidatorDescriptors(Class<A> annotationType)
Constraint.validatedBy()
,
ConstraintMapping.constraintDefinition(Class)
).A
- the type of the annotationannotationType
- The constraint annotation type.public <A extends Annotation> List<ConstraintValidatorDescriptor<A>> findValidatorDescriptors(Class<A> annotationType, ValidationTarget validationTarget)
A
- the type of the annotationannotationType
- The annotation of interest.validationTarget
- The target, either annotated element or parameters.public <A extends Annotation> void putValidatorDescriptors(Class<A> annotationType, List<ConstraintValidatorDescriptor<A>> validatorDescriptors, boolean keepExistingClasses)
A
- the type of the annotationannotationType
- The constraint annotation typevalidatorDescriptors
- The validator descriptors to registerkeepExistingClasses
- Whether already-registered validators should be kept or notpublic boolean isMultiValueConstraint(Class<? extends Annotation> annotationType)
annotationType
- the annotation type to check.true
if the specified annotation is a multi value constraints, false
otherwise.public <A extends Annotation> List<Annotation> getConstraintsFromMultiValueConstraint(A multiValueConstraint)
Invoke isMultiValueConstraint(Class)
prior to calling this method to check whether a given constraint
actually is a multi-value constraint.
A
- the type of the annotationmultiValueConstraint
- the multi-value constraint annotation from which to retrieve the contained constraintsnull
.public boolean isConstraintAnnotation(Class<? extends Annotation> annotationType)
Constraint
annotationType
- The annotation type to test.true
if the annotation fulfills the above conditions, false
otherwise.public boolean isConstraintComposition(Class<? extends Annotation> annotationType)
public boolean isJdkAnnotation(Class<? extends Annotation> annotation)
public void clear()
Copyright © 2021 JBoss by Red Hat. All rights reserved.