public class ConstraintHelper
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
GROUPS |
static java.lang.String |
MESSAGE |
static java.lang.String |
PAYLOAD |
static java.lang.String |
VALIDATION_APPLIES_TO |
Constructor and Description |
---|
ConstraintHelper() |
Modifier and Type | Method and Description |
---|---|
void |
clear() |
<A extends java.lang.annotation.Annotation> |
findValidatorDescriptors(java.lang.Class<A> annotationType,
javax.validation.constraintvalidation.ValidationTarget validationTarget)
Returns those validator descriptors for the given constraint annotation
matching the given target.
|
<A extends java.lang.annotation.Annotation> |
getAllValidatorDescriptors(java.lang.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 java.lang.annotation.Annotation> |
getConstraintsFromMultiValueConstraint(A multiValueConstraint)
Returns the constraints which are part of the given multi-value constraint.
|
boolean |
isConstraintAnnotation(java.lang.Class<? extends java.lang.annotation.Annotation> annotationType)
Checks whether the specified annotation is a valid constraint annotation.
|
boolean |
isConstraintComposition(java.lang.Class<? extends java.lang.annotation.Annotation> annotationType) |
boolean |
isJdkAnnotation(java.lang.Class<? extends java.lang.annotation.Annotation> annotation) |
boolean |
isMultiValueConstraint(java.lang.Class<? extends java.lang.annotation.Annotation> annotationType)
Checks whether a given annotation is a multi value constraint or not.
|
<A extends java.lang.annotation.Annotation> |
putValidatorDescriptors(java.lang.Class<A> annotationType,
java.util.List<ConstraintValidatorDescriptor<A>> validatorDescriptors,
boolean keepExistingClasses)
Registers the given validator descriptors with the given constraint
annotation type.
|
public static final java.lang.String GROUPS
public static final java.lang.String PAYLOAD
public static final java.lang.String MESSAGE
public static final java.lang.String VALIDATION_APPLIES_TO
public <A extends java.lang.annotation.Annotation> java.util.List<ConstraintValidatorDescriptor<A>> getAllValidatorDescriptors(java.lang.Class<A> annotationType)
Constraint.validatedBy()
,
ConstraintMapping.constraintDefinition(Class)
).A
- the type of the annotationannotationType
- The constraint annotation type.public <A extends java.lang.annotation.Annotation> java.util.List<ConstraintValidatorDescriptor<A>> findValidatorDescriptors(java.lang.Class<A> annotationType, javax.validation.constraintvalidation.ValidationTarget validationTarget)
A
- the type of the annotationannotationType
- The annotation of interest.validationTarget
- The target, either annotated element or parameters.public <A extends java.lang.annotation.Annotation> void putValidatorDescriptors(java.lang.Class<A> annotationType, java.util.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(java.lang.Class<? extends java.lang.annotation.Annotation> annotationType)
annotationType
- the annotation type to check.true
if the specified annotation is a multi value constraints, false
otherwise.public <A extends java.lang.annotation.Annotation> java.util.List<java.lang.annotation.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(java.lang.Class<? extends java.lang.annotation.Annotation> annotationType)
Constraint
annotationType
- The annotation type to test.true
if the annotation fulfills the above conditions, false
otherwise.public boolean isConstraintComposition(java.lang.Class<? extends java.lang.annotation.Annotation> annotationType)
public boolean isJdkAnnotation(java.lang.Class<? extends java.lang.annotation.Annotation> annotation)
public void clear()
Copyright © 2007-2022 Red Hat, Inc. All Rights Reserved