Interface ConstraintDescriptor<T extends Annotation>
- Type Parameters:
T- the constraint's annotation type
public interface ConstraintDescriptor<T extends Annotation>
Describes a single constraint and its composing constraints.
- Author:
- Emmanuel Bernard, Hardy Ferentschik
-
Method Summary
Modifier and TypeMethodDescriptionReturns the annotation describing the constraint declaration.<V> VgetAttribute(String name, Class<V> type) Returns the value of the annotation attribute.Returns a map containing the annotation attribute names as keys and the annotation attribute values as value.Return a set of composingConstraintDescriptors where each descriptor describes a composing constraint.List<Class<? extends ConstraintValidator<T, ?>>> List of the constraint validation implementation classes.The set of groups the constraint is applied on.The non-interpolated error messageThe set of payload the constraint hosts.boolean<U> UReturns an instance of the specified type allowing access to provider-specific APIs.
-
Method Details
-
getAnnotation
T getAnnotation()Returns the annotation describing the constraint declaration. If a composing constraint, attribute values are reflecting the overridden attributes of the composing constraint- Returns:
- the annotation for this constraint
-
getMessageTemplate
String getMessageTemplate()The non-interpolated error message- Returns:
- the non-interpolated error message
- Since:
- 1.1
-
getGroups
-
getPayload
-
getValidationAppliesTo
ConstraintTarget getValidationAppliesTo()- Returns:
- the
ConstraintTargetvalue ornull - Since:
- 1.1
-
getConstraintValidatorClasses
List<Class<? extends ConstraintValidator<T,?>>> getConstraintValidatorClasses()List of the constraint validation implementation classes.- Returns:
- list of the constraint validation implementation classes
-
getAttributes
Returns 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.
- Returns:
- a map containing the annotation attribute names as keys and the annotation attribute values as value
-
getAttribute
Returns the value of the annotation attribute.Serves as a shortcut to
(V) getAttributes().get(attrName);.If this constraint is used as part of a composed constraint, attribute values are reflecting the overridden attribute of the composing constraint.
- Type Parameters:
V- the type of the attribute to be returned- Parameters:
name- the name of the constraint attribute to retrievetype- the class of the attribute to be returned- Returns:
- the value of a requested attribute, or
nullif such attribute is not defined. - Throws:
ClassCastException- if the actual attribute value cannot be cast to the requested type.- Since:
- 4.0
- See Also:
-
getComposingConstraints
Set<ConstraintDescriptor<?>> getComposingConstraints()Return a set of composingConstraintDescriptors where each descriptor describes a composing constraint.ConstraintDescriptorinstances of composing constraints reflect overridden attribute values ingetAttributes()andgetAnnotation().- Returns:
- a set of
ConstraintDescriptorobjects or an empty set in case there are no composing constraints
-
isReportAsSingleViolation
boolean isReportAsSingleViolation()- Returns:
trueif the constraint is annotated withReportAsSingleViolation
-
getValueUnwrapping
ValidateUnwrappedValue getValueUnwrapping()- Returns:
- a
ValidateUnwrappedValuedescribing the unwrapping behavior as given via theUnwrappingconstraint payloads. - Since:
- 2.0
-
unwrap
Returns an instance of the specified type allowing access to provider-specific APIs.If the Jakarta Validation provider implementation does not support the specified class, a
ValidationExceptionis thrown.- 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
- Throws:
ValidationException- if the provider does not support the call- Since:
- 2.0
-