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 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

      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:
      the groups the constraint is applied on
    • getPayload

      Set<Class<? extends Payload>> getPayload()
      The set of payload the constraint hosts.
      Returns:
      payload classes hosted on the constraint or an empty set if none
    • getValidationAppliesTo

      ConstraintTarget getValidationAppliesTo()
      The ConstraintTarget value of validationAppliesTo if the constraint hosts it or null otherwise.
      Returns:
      the ConstraintTarget value or null
      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

      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:
      a map containing the annotation attribute names as keys and the annotation attribute values as value
    • getComposingConstraints

      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:
      a set of ConstraintDescriptor objects or an empty set in case there are no composing constraints
    • isReportAsSingleViolation

      boolean isReportAsSingleViolation()
      Returns:
      true if the constraint is annotated with ReportAsSingleViolation
    • getValueUnwrapping

      ValidateUnwrappedValue getValueUnwrapping()
      Returns:
      a ValidateUnwrappedValue describing the unwrapping behavior as given via the Unwrapping constraint payloads.
      Since:
      2.0
    • unwrap

      <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.

      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