Interface ConstraintLocation

  • All Known Implementing Classes:
    AbstractPropertyConstraintLocation, FieldConstraintLocation, GetterConstraintLocation, ParameterConstraintLocation, TypeArgumentConstraintLocation

    public interface ConstraintLocation
    Represents the location (e.g. a bean, field or method parameter) of a constraint and provides logic related to it, e.g. for appending the location to a given property path.

    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 Detail

      • getDeclaringClass

        Class<?> getDeclaringClass()
        Returns the class hosting this location.
      • getConstrainable

        Constrainable getConstrainable()
        Returns the member represented by this location.
        Returns:
        the member represented by this location. Will be null when this location represents a type.
      • getTypeForValidatorResolution

        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