Class ConstraintDescriptorImpl<T extends Annotation>
- java.lang.Object
-
- org.hibernate.validator.internal.metadata.descriptor.ConstraintDescriptorImpl<T>
-
- All Implemented Interfaces:
ConstraintDescriptor<T>,Serializable
public class ConstraintDescriptorImpl<T extends Annotation> extends Object implements ConstraintDescriptor<T>, Serializable
Describes a single constraint (including its composing constraints).- Author:
- Emmanuel Bernard, Hardy Ferentschik, Federico Mancini, Dag Hovland, Guillaume Smet
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classConstraintDescriptorImpl.ConstraintTypeThe type of a constraint.
-
Constructor Summary
Constructors Constructor Description ConstraintDescriptorImpl(ConstraintHelper constraintHelper, Constrainable constrainable, ConstraintAnnotationDescriptor<T> annotationDescriptor, ConstraintLocation.ConstraintLocationKind constraintLocationKind)ConstraintDescriptorImpl(ConstraintHelper constraintHelper, Constrainable constrainable, ConstraintAnnotationDescriptor<T> annotationDescriptor, ConstraintLocation.ConstraintLocationKind constraintLocationKind, Class<?> implicitGroup, ConstraintOrigin definedOn, ConstraintDescriptorImpl.ConstraintType externalConstraintType)ConstraintDescriptorImpl(ConstraintHelper constraintHelper, Constrainable constrainable, ConstraintAnnotationDescriptor<T> annotationDescriptor, ConstraintLocation.ConstraintLocationKind constraintLocationKind, ConstraintDescriptorImpl.ConstraintType constraintType)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(Object o)TgetAnnotation()Returns the annotation describing the constraint declaration.ConstraintAnnotationDescriptor<T>getAnnotationDescriptor()Class<T>getAnnotationType()Map<String,Object>getAttributes()Returns a map containing the annotation attribute names as keys and the annotation attribute values as value.Set<ConstraintDescriptorImpl<?>>getComposingConstraintImpls()Set<ConstraintDescriptor<?>>getComposingConstraints()Return a set of composingConstraintDescriptors where each descriptor describes a composing constraint.CompositionTypegetCompositionType()ConstraintLocation.ConstraintLocationKindgetConstraintLocationKind()ConstraintDescriptorImpl.ConstraintTypegetConstraintType()List<Class<? extends ConstraintValidator<T,?>>>getConstraintValidatorClasses()List of the constraint validation implementation classes.ConstraintOrigingetDefinedOn()Set<Class<?>>getGroups()The set of groups the constraint is applied on.List<ConstraintValidatorDescriptor<T>>getMatchingConstraintValidatorDescriptors()Return all constraint validator descriptors (either generic or cross-parameter) which are registered for the constraint of this descriptor.StringgetMessageTemplate()The non-interpolated error messageSet<Class<? extends Payload>>getPayload()The set of payload the constraint hosts.ConstraintTargetgetValidationAppliesTo()ValidateUnwrappedValuegetValueUnwrapping()inthashCode()booleanisReportAsSingleViolation()StringtoString()<U> Uunwrap(Class<U> type)Returns an instance of the specified type allowing access to provider-specific APIs.
-
-
-
Constructor Detail
-
ConstraintDescriptorImpl
public ConstraintDescriptorImpl(ConstraintHelper constraintHelper, Constrainable constrainable, ConstraintAnnotationDescriptor<T> annotationDescriptor, ConstraintLocation.ConstraintLocationKind constraintLocationKind, Class<?> implicitGroup, ConstraintOrigin definedOn, ConstraintDescriptorImpl.ConstraintType externalConstraintType)
-
ConstraintDescriptorImpl
public ConstraintDescriptorImpl(ConstraintHelper constraintHelper, Constrainable constrainable, ConstraintAnnotationDescriptor<T> annotationDescriptor, ConstraintLocation.ConstraintLocationKind constraintLocationKind)
-
ConstraintDescriptorImpl
public ConstraintDescriptorImpl(ConstraintHelper constraintHelper, Constrainable constrainable, ConstraintAnnotationDescriptor<T> annotationDescriptor, ConstraintLocation.ConstraintLocationKind constraintLocationKind, ConstraintDescriptorImpl.ConstraintType constraintType)
-
-
Method Detail
-
getAnnotationDescriptor
public ConstraintAnnotationDescriptor<T> getAnnotationDescriptor()
-
getAnnotation
public T getAnnotation()
Description copied from interface:ConstraintDescriptorReturns the annotation describing the constraint declaration. If a composing constraint, attribute values are reflecting the overridden attributes of the composing constraint- Specified by:
getAnnotationin interfaceConstraintDescriptor<T extends Annotation>- Returns:
- the annotation for this constraint
-
getMessageTemplate
public String getMessageTemplate()
Description copied from interface:ConstraintDescriptorThe non-interpolated error message- Specified by:
getMessageTemplatein interfaceConstraintDescriptor<T extends Annotation>- Returns:
- the non-interpolated error message
-
getGroups
public Set<Class<?>> getGroups()
Description copied from interface:ConstraintDescriptorThe set of groups the constraint is applied on. If the constraint declares no group, a set with only theDefaultgroup is returned.- Specified by:
getGroupsin interfaceConstraintDescriptor<T extends Annotation>- Returns:
- the groups the constraint is applied on
-
getPayload
public Set<Class<? extends Payload>> getPayload()
Description copied from interface:ConstraintDescriptorThe set of payload the constraint hosts.- Specified by:
getPayloadin interfaceConstraintDescriptor<T extends Annotation>- Returns:
- payload classes hosted on the constraint or an empty set if none
-
getValidationAppliesTo
public ConstraintTarget getValidationAppliesTo()
Description copied from interface:ConstraintDescriptor- Specified by:
getValidationAppliesToin interfaceConstraintDescriptor<T extends Annotation>- Returns:
- the
ConstraintTargetvalue ornull
-
getValueUnwrapping
public ValidateUnwrappedValue getValueUnwrapping()
- Specified by:
getValueUnwrappingin interfaceConstraintDescriptor<T extends Annotation>- Returns:
- a
ValidateUnwrappedValuedescribing the unwrapping behavior as given via theUnwrappingconstraint payloads.
-
getConstraintValidatorClasses
public List<Class<? extends ConstraintValidator<T,?>>> getConstraintValidatorClasses()
Description copied from interface:ConstraintDescriptorList of the constraint validation implementation classes.- Specified by:
getConstraintValidatorClassesin interfaceConstraintDescriptor<T extends Annotation>- Returns:
- list of the constraint validation implementation classes
-
getMatchingConstraintValidatorDescriptors
public List<ConstraintValidatorDescriptor<T>> getMatchingConstraintValidatorDescriptors()
Return all constraint validator descriptors (either generic or cross-parameter) which are registered for the constraint of this descriptor.- Returns:
- The constraint validator descriptors applying to type of this constraint.
-
getAttributes
public Map<String,Object> getAttributes()
Description copied from interface:ConstraintDescriptorReturns a map containing the annotation attribute names as keys and the annotation attribute values as value.If this constraint is used as part of a composed constraint, attribute values are reflecting the overridden attribute of the composing constraint.
- Specified by:
getAttributesin interfaceConstraintDescriptor<T extends Annotation>- Returns:
- a map containing the annotation attribute names as keys and the annotation attribute values as value
-
getComposingConstraints
public Set<ConstraintDescriptor<?>> getComposingConstraints()
Description copied from interface:ConstraintDescriptorReturn a set of composingConstraintDescriptors where each descriptor describes a composing constraint.ConstraintDescriptorinstances of composing constraints reflect overridden attribute values inConstraintDescriptor.getAttributes()andConstraintDescriptor.getAnnotation().- Specified by:
getComposingConstraintsin interfaceConstraintDescriptor<T extends Annotation>- Returns:
- a set of
ConstraintDescriptorobjects or an empty set in case there are no composing constraints
-
getComposingConstraintImpls
public Set<ConstraintDescriptorImpl<?>> getComposingConstraintImpls()
-
isReportAsSingleViolation
public boolean isReportAsSingleViolation()
- Specified by:
isReportAsSingleViolationin interfaceConstraintDescriptor<T extends Annotation>- Returns:
trueif the constraint is annotated withReportAsSingleViolation
-
getConstraintLocationKind
public ConstraintLocation.ConstraintLocationKind getConstraintLocationKind()
-
getDefinedOn
public ConstraintOrigin getDefinedOn()
-
getConstraintType
public ConstraintDescriptorImpl.ConstraintType getConstraintType()
-
unwrap
public <U> U unwrap(Class<U> type)
Description copied from interface:ConstraintDescriptorReturns an instance of the specified type allowing access to provider-specific APIs.If the Jakarta Bean Validation provider implementation does not support the specified class, a
ValidationExceptionis thrown.- Specified by:
unwrapin interfaceConstraintDescriptor<T extends Annotation>- Type Parameters:
U- the type of the object to be returned- Parameters:
type- the class of the object to be returned- Returns:
- an instance of the specified class
-
getCompositionType
public CompositionType getCompositionType()
- Returns:
- the compositionType
-
-