org.hibernate.validator.internal.metadata.location

## Class ConstraintLocation

- java.lang.Object
- - org.hibernate.validator.internal.metadata.location.ConstraintLocation

-     public class ConstraintLocation
      extends Object

  Provides information related to the location a constraint is declared on (e.g. a bean, field or method parameter).

  Note that while the validation engine works on the aggregated meta-model (which e.g. provides a unified view for properties, be them represented via fields or getter methods) most of the time, in some situations the physical element which hosts a constraint is relevant. This includes

  - retrieval of property values to be validated (either field or getter access)
  - constraint validator resolution; a field and the corresponding getter method may have different types, causing potentially different validators to kick in for the constraints declared on either element
  - determination of a constraint's scope (locally defined or up in the hierarchy)
  Author:
    Hardy Ferentschik, Gunnar Morling

- - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `static ConstraintLocation` | `forClass(Class<?> declaringClass)`
    `static ConstraintLocation` | `forCrossParameter(ExecutableElement executable)`
    `static ConstraintLocation` | `forParameter(ExecutableElement executable, int index)`
    `static ConstraintLocation` | `forProperty(Member member)`
    `static ConstraintLocation` | `forReturnValue(ExecutableElement executable)`
    `Class<?>` | `getDeclaringClass()` Returns the class hosting this location.
    `Member` | `getMember()` Returns the member represented by this location.
    `Type` | `getTypeForValidatorResolution()` Returns the type to be used when resolving constraint validators for constraints at this location.
    `String` | `toString()`

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

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

- - ### Method Detail

    - #### forClass

          public static ConstraintLocation forClass(Class<?> declaringClass)

    - #### forProperty

          public static ConstraintLocation forProperty(Member member)

    - #### forReturnValue

          public static ConstraintLocation forReturnValue(ExecutableElement executable)

    - #### forCrossParameter

          public static ConstraintLocation forCrossParameter(ExecutableElement executable)

    - #### forParameter

          public static ConstraintLocation forParameter(ExecutableElement executable,
                                        int index)

    - #### getDeclaringClass

          public Class<?> getDeclaringClass()

      Returns the class hosting this location.
      Returns:
        the class hosting this location

    - #### getMember

          public Member getMember()

      Returns the member represented by this location.
      Returns:
        the member represented by this location. Will be `null` when this location represents a type.

    - #### getTypeForValidatorResolution

          public Type getTypeForValidatorResolution()

      Returns the type to be used when resolving constraint validators for constraints at this location. Note that this is not always the same type as the type of the element described by this location; E.g. the wrapper type will is used for constraint validator resolution, if a constraint is declared in an element with a primitive type.
      Returns:
        The type to be used when resolving constraint validators for constraints at this location

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`

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