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
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionvoid
appendTo
(ExecutableParameterNameProvider parameterNameProvider, PathImpl path) Appends a node representing this location to the given property path.static ConstraintLocation
static ConstraintLocation
forCrossParameter
(Callable callable) static ConstraintLocation
static ConstraintLocation
static ConstraintLocation
forParameter
(Callable callable, int index) static ConstraintLocation
forReturnValue
(Callable callable) static ConstraintLocation
forTypeArgument
(ConstraintLocation delegate, TypeVariable<?> typeParameter, Type typeOfAnnotatedElement) Returns the member represented by this location.Class<?>
Returns the class hosting this location.getKind()
Returns the nature of the constraint location.Returns the type to be used when resolving constraint validators for constraints at this location.Obtains the value of this location from the parent.
-
Method Details
-
forClass
-
forField
-
forGetter
-
forTypeArgument
static ConstraintLocation forTypeArgument(ConstraintLocation delegate, TypeVariable<?> typeParameter, Type typeOfAnnotatedElement) -
forReturnValue
-
forCrossParameter
-
forParameter
-
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
-
appendTo
Appends a node representing this location to the given property path. -
getValue
Obtains the value of this location from the parent. The type of the passed parent depends on the location type, e.g. a bean would be passed for aAbstractPropertyConstraintLocation
but an object array for aParameterConstraintLocation
. -
getKind
Returns the nature of the constraint location.
-