org.hibernate.validator.ap.util

## Class ConstraintHelper

- java.lang.Object
- - org.hibernate.validator.ap.util.ConstraintHelper

-     public class ConstraintHelper
      extends Object

  Helper class that deals with all constraint-related stuff, such as determining whether a given annotation represents a constraint annotation or whether a given annotation is allowed to be declared at a given element.
  Author:
    Gunnar Morling, Kevin Pollet (C) 2011 SERLI

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `ConstraintHelper.AnnotationType` The type of an annotation with respect to the BV API.
    `static class` | `ConstraintHelper.ConstraintCheckResult` Possible results of a constraint check as returned by `checkConstraint(DeclaredType, TypeMirror)`.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `ConstraintHelper(Types typeUtils, AnnotationApiHelper annotationApiHelper)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `ConstraintHelper.ConstraintCheckResult` | `checkConstraint(DeclaredType constraintAnnotationType, TypeMirror typeOfAnnotatedElement)` Checks whether the given annotation type (which must be a constraint annotation type) may be specified at elements of the specified type.
    `ConstraintHelper.AnnotationType` | `getAnnotationType(AnnotationMirror annotationMirror)` Returns the `ConstraintHelper.AnnotationType` of the given annotation.
    `List<AnnotationMirror>` | `getPartsOfMultiValuedConstraint(AnnotationMirror annotationMirror)` Returns a list with the constraint annotations contained in the given array-valued annotation mirror.
    `boolean` | `isComposedConstraint(TypeElement element)` Checks, whether the given type element represents a composed constraint or not.
    `boolean` | `isConstraintAnnotation(Element element)` Checks, whether the given type element represents a constraint annotation or not.

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

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

- - ### Constructor Detail

    - #### ConstraintHelper

          public ConstraintHelper(Types typeUtils,
                          AnnotationApiHelper annotationApiHelper)

  - ### Method Detail

    - #### isConstraintAnnotation

          public boolean isConstraintAnnotation(Element element)

      Checks, whether the given type element represents a constraint annotation or not. That's the case, if the given element is annotated with the `@Constraint` meta-annotation (which is only allowed at annotation declarations).
      Parameters:
        `element` - The element of interest.
      Returns:
        True, if the given element is a constraint annotation type, false otherwise.

    - #### getAnnotationType

          public ConstraintHelper.AnnotationType getAnnotationType(AnnotationMirror annotationMirror)

      Returns the `ConstraintHelper.AnnotationType` of the given annotation.
      Parameters:
        `annotationMirror` - The annotation mirror of interest.
      Returns:
        The given mirror's annotation type.

    - #### getPartsOfMultiValuedConstraint

          public List<AnnotationMirror> getPartsOfMultiValuedConstraint(AnnotationMirror annotationMirror)

      Returns a list with the constraint annotations contained in the given array-valued annotation mirror.
      Parameters:
        `annotationMirror` - An array-valued annotation mirror (meaning it has an array-typed attribute with name "value").
      Returns:
        A list with the constraint annotations part of the given multi-valued constraint annotation. Will return an empty list if the given annotation is no multi-valued annotation or if no constraint annotations are contained within the given array-valued annotation.

    - #### checkConstraint

          public ConstraintHelper.ConstraintCheckResult checkConstraint(DeclaredType constraintAnnotationType,
                                                               TypeMirror typeOfAnnotatedElement)

      Checks whether the given annotation type (which must be a constraint annotation type) may be specified at elements of the specified type.
      Parameters:
        `constraintAnnotationType` - A constraint annotation type.
        `typeOfAnnotatedElement` - A type which with an element is annotated.
      Returns:
        Whether the given constraint annotation may be specified at elements of the given type.

    - #### isComposedConstraint

          public boolean isComposedConstraint(TypeElement element)

      Checks, whether the given type element represents a composed constraint or not.
      Parameters:
        `element` - The type element of interest. Must not be null.
      Returns:
        True if the given element represents a composed constraint, false otherwise.

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