Top Description Methods
jakarta.validation.metadata

public Interface ConstraintDescriptor<T extends Annotation>

Type Parameters
<T>
the constraint's annotation type
Imports
java.lang.annotation.Annotation, java.util.List, .Map, .Set, jakarta.validation.ConstraintTarget, .ConstraintValidator, .Payload, .ReportAsSingleViolation, .ValidationException, jakarta.validation.groups.Default, jakarta.validation.valueextraction.Unwrapping

Describes a single constraint and its composing constraints.
Authors
Emmanuel Bernard, Hardy Ferentschik

Method Summary

Modifier and TypeMethod and Description
public T

Returns:

the annotation for this constraint
getAnnotation
()

Returns the annotation describing the constraint declaration.

public Map<String, Object>

Returns:

a map containing the annotation attribute names as keys and the annotation attribute values as value
getAttributes
()

Returns a map containing the annotation attribute names as keys and the annotation attribute values as value.

public Set<ConstraintDescriptor<?>>

Returns:

a set of ConstraintDescriptor objects or an empty set in case there are no composing constraints
getComposingConstraints
()

Return a set of composing ConstraintDescriptors where each descriptor describes a composing constraint.

public List<Class<? extends ConstraintValidator<T, ?>>>

Returns:

list of the constraint validation implementation classes
getConstraintValidatorClasses
()

List of the constraint validation implementation classes.

public Set<Class<?>>

Returns:

the groups the constraint is applied on
getGroups
()

The set of groups the constraint is applied on.

public String

Returns:

the non-interpolated error message
getMessageTemplate
()

The non-interpolated error message

public Set<Class<? extends Payload>>

Returns:

payload classes hosted on the constraint or an empty set if none
getPayload
()

The set of payload the constraint hosts.

public ConstraintTarget

Returns:

the ConstraintTarget value or null
getValidationAppliesTo
()

The ConstraintTarget value of validationAppliesTo if the constraint hosts it or null otherwise.

public ValidateUnwrappedValue

Returns:

a ValidateUnwrappedValue describing the unwrapping behavior as given via the Unwrapping constraint payloads.
getValueUnwrapping
()

public boolean

Returns:

true if the constraint is annotated with ReportAsSingleViolation
isReportAsSingleViolation
()

public <
the type of the object to be returned
U
>
U

Returns:

an instance of the specified class
unwrap
(Class<U>
the class of the object to be returned
type
)

Returns an instance of the specified type allowing access to provider-specific APIs.

Method Detail

getAnnotationback to summary
public 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:T

the annotation for this constraint

getAttributesback to summary
public Map<String, Object> 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:Map<String, Object>

a map containing the annotation attribute names as keys and the annotation attribute values as value

getComposingConstraintsback to summary
public Set<ConstraintDescriptor<?>> getComposingConstraints()

Return a set of composing ConstraintDescriptors where each descriptor describes a composing constraint. ConstraintDescriptor instances of composing constraints reflect overridden attribute values in getAttributes() and getAnnotation().

Returns:Set<ConstraintDescriptor<?>>

a set of ConstraintDescriptor objects or an empty set in case there are no composing constraints

getConstraintValidatorClassesback to summary
public List<Class<? extends ConstraintValidator<T, ?>>> getConstraintValidatorClasses()

List of the constraint validation implementation classes.

Returns:List<Class<? extends ConstraintValidator<T, ?>>>

list of the constraint validation implementation classes

getGroupsback to summary
public Set<Class<?>> getGroups()

The set of groups the constraint is applied on. If the constraint declares no group, a set with only the Default group is returned.

Returns:Set<Class<?>>

the groups the constraint is applied on

getMessageTemplateback to summary
public String getMessageTemplate()

The non-interpolated error message

Returns:String

the non-interpolated error message

Since
1.1
getPayloadback to summary
public Set<Class<? extends Payload>> getPayload()

The set of payload the constraint hosts.

Returns:Set<Class<? extends Payload>>

payload classes hosted on the constraint or an empty set if none

getValidationAppliesToback to summary
public ConstraintTarget getValidationAppliesTo()

The ConstraintTarget value of validationAppliesTo if the constraint hosts it or null otherwise.

Returns:ConstraintTarget

the ConstraintTarget value or null

Since
1.1
getValueUnwrappingback to summary
public ValidateUnwrappedValue getValueUnwrapping()
Returns:ValidateUnwrappedValue

a ValidateUnwrappedValue describing the unwrapping behavior as given via the Unwrapping constraint payloads.

Since
2.0
isReportAsSingleViolationback to summary
public boolean isReportAsSingleViolation()
Returns:boolean

true if the constraint is annotated with ReportAsSingleViolation

unwrapback to summary
public <U> U unwrap(Class<U> type)

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 ValidationException is thrown.

Parameters
<U>
the type of the object to be returned
type:Class<U>

the class of the object to be returned

Returns:U

an instance of the specified class

Exceptions
ValidationException:
if the provider does not support the call
Since
2.0