org.hibernate.validator.internal.metadata.core

## Class ConstraintHelper

- java.lang.Object
- - org.hibernate.validator.internal.metadata.core.ConstraintHelper

-     public class ConstraintHelper
      extends Object

  Keeps track of builtin constraints and their validator implementations, as well as already resolved validator definitions.
  Author:
    Hardy Ferentschik, Alaa Nassef, Gunnar Morling

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static String` | `GROUPS`
    `static String` | `MESSAGE`
    `static String` | `PAYLOAD`
    `static String` | `VALIDATION_APPLIES_TO`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `ConstraintHelper()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `<A extends Annotation> List<Class<? extends ConstraintValidator<A,?>>>` | `findValidatorClasses(Class<A> annotationType, ValidationTarget validationTarget)` Returns those validator classes for the given constraint annotation matching the given target.
    `<A extends Annotation> List<Class<? extends ConstraintValidator<A,?>>>` | `getAllValidatorClasses(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 and XML configuration. The result is cached internally.
    `<A extends Annotation> List<Annotation>` | `getConstraintsFromMultiValueConstraint(A multiValueConstraint)` Returns the constraints which are part of the given multi-value constraint.
    `boolean` | `isConstraintAnnotation(Class<? extends Annotation> annotationType)` Checks whether the specified annotation is a valid constraint annotation.
    `boolean` | `isConstraintComposition(Class<? extends Annotation> annotationType)`
    `boolean` | `isMultiValueConstraint(Class<? extends Annotation> annotationType)` Checks whether a given annotation is a multi value constraint or not.
    `<A extends Annotation> void` | `putValidatorClasses(Class<A> annotationType, List<Class<? extends ConstraintValidator<A,?>>> definitionClasses, boolean keepDefaultClasses)` Registers the given validator classes with the given constraint annotation type.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### GROUPS

          public static final String GROUPS

      See Also:
        Constant Field Values

    - #### PAYLOAD

          public static final String PAYLOAD

      See Also:
        Constant Field Values

    - #### MESSAGE

          public static final String MESSAGE

      See Also:
        Constant Field Values

    - #### VALIDATION_APPLIES_TO

          public static final String VALIDATION_APPLIES_TO

      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### ConstraintHelper

          public ConstraintHelper()

  - ### Method Detail

    - #### getAllValidatorClasses

          public <A extends Annotation> List<Class<? extends ConstraintValidator<A,?>>> getAllValidatorClasses(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 and
      - XML configuration.
      The result is cached internally.
      Parameters:
        `annotationType` - The constraint annotation type.
      Returns:
        The validator classes for the given type.

    - #### findValidatorClasses

          public <A extends Annotation> List<Class<? extends ConstraintValidator<A,?>>> findValidatorClasses(Class<A> annotationType,
                                                                                                    ValidationTarget validationTarget)

      Returns those validator classes for the given constraint annotation matching the given target.
      Parameters:
        `annotationType` - The annotation of interest.
        `validationTarget` - The target, either annotated element or parameters.
      Returns:
        A list with matching validator classes.

    - #### putValidatorClasses

          public <A extends Annotation> void putValidatorClasses(Class<A> annotationType,
                                                        List<Class<? extends ConstraintValidator<A,?>>> definitionClasses,
                                                        boolean keepDefaultClasses)

      Registers the given validator classes with the given constraint annotation type.
      Parameters:
        `annotationType` - The constraint annotation type
        `definitionClasses` - The validators to register
        `keepDefaultClasses` - Whether any default validators should be kept or not

    - #### isMultiValueConstraint

          public boolean isMultiValueConstraint(Class<? extends Annotation> annotationType)

      Checks whether a given annotation is a multi value constraint or not.
      Parameters:
        `annotationType` - the annotation type to check.
      Returns:
        `true` if the specified annotation is a multi value constraints, `false` otherwise.

    - #### getConstraintsFromMultiValueConstraint

          public <A extends Annotation> List<Annotation> getConstraintsFromMultiValueConstraint(A multiValueConstraint)

      Returns the constraints which are part of the given multi-value constraint.

      Invoke `isMultiValueConstraint(Class)` prior to calling this method to check whether a given constraint actually is a multi-value constraint.

      Parameters:
        `multiValueConstraint` - the multi-value constraint annotation from which to retrieve the contained constraints
      Returns:
        A list of constraint annotations, may be empty but never `null`.

    - #### isConstraintAnnotation

          public boolean isConstraintAnnotation(Class<? extends Annotation> annotationType)

      Checks whether the specified annotation is a valid constraint annotation. A constraint annotation has to fulfill the following conditions:
      - Must be annotated with `Constraint`
      - Define a message parameter
      - Define a group parameter
      - Define a payload parameter
      Parameters:
        `annotationType` - The annotation type to test.
      Returns:
        `true` if the annotation fulfills the above conditions, `false` otherwise.

    - #### isConstraintComposition

          public boolean isConstraintComposition(Class<? extends Annotation> annotationType)

Copyright © 2007-2014 Red Hat, Inc. All Rights Reserved