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 |
---|---|
<A extends Annotation> |
findValidatorClasses(Class<A> annotationType,
ValidationTarget validationTarget)
Returns those validator classes for the given constraint annotation
matching the given target.
|
<A extends Annotation> |
getAllValidatorClasses(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 |
isMultiValueConstraint(Class<? extends Annotation> annotationType)
Checks whether a given annotation is a multi value constraint or not.
|
<A extends Annotation> |
putValidatorClasses(Class<A> annotationType,
List<Class<? extends ConstraintValidator<A,?>>> definitionClasses,
boolean keepExistingClasses)
Registers the given validator classes 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<Class<? extends ConstraintValidator<A,?>>> getAllValidatorClasses(Class<A> annotationType)
Constraint.validatedBy()
,
ConstraintMapping.constraintDefinition(Class)
).A
- the type of the annotationannotationType
- The constraint annotation type.public <A extends Annotation> List<Class<? extends ConstraintValidator<A,?>>> findValidatorClasses(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 putValidatorClasses(Class<A> annotationType, List<Class<? extends ConstraintValidator<A,?>>> definitionClasses, boolean keepExistingClasses)
A
- the type of the annotationannotationType
- The constraint annotation typedefinitionClasses
- The validators 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)
Copyright © 2017 JBoss by Red Hat. All rights reserved.