public interface ConstraintLocation
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
Modifier and Type | Method and Description |
---|---|
void |
appendTo(ExecutableParameterNameProvider parameterNameProvider,
PathImpl path)
Appends a node representing this location to the given property path.
|
static ConstraintLocation |
forClass(Class<?> declaringClass) |
static ConstraintLocation |
forCrossParameter(Executable executable) |
static ConstraintLocation |
forField(Field field) |
static ConstraintLocation |
forGetter(Class<?> declaringClass,
Method getter)
Create a new
GetterConstraintLocation for the given declaring class and getter method. |
static ConstraintLocation |
forGetter(Method getter)
Create a new
GetterConstraintLocation for the given getter method. |
static ConstraintLocation |
forParameter(Executable executable,
int index) |
static ConstraintLocation |
forReturnValue(Executable executable) |
static ConstraintLocation |
forTypeArgument(ConstraintLocation delegate,
TypeVariable<?> typeParameter,
Type typeOfAnnotatedElement) |
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.
|
Object |
getValue(Object parent)
Obtains the value of this location from the parent.
|
static ConstraintLocation forClass(Class<?> declaringClass)
static ConstraintLocation forField(Field field)
static ConstraintLocation forGetter(Method getter)
GetterConstraintLocation
for the given getter method.getter
- The getter method being constrainedstatic ConstraintLocation forGetter(Class<?> declaringClass, Method getter)
GetterConstraintLocation
for the given declaring class and getter method.
This provides an alternative to forGetter(Method)
where the given declaring class is usually a sub-class of the
actual class on which the getter method is declared. This is provided to support XML mapping configurations used to specify constraints on
subclasses for inherited getter methods.
declaringClass
- The class on which the constraint is defined.getter
- The getter method being constrained.static ConstraintLocation forTypeArgument(ConstraintLocation delegate, TypeVariable<?> typeParameter, Type typeOfAnnotatedElement)
static ConstraintLocation forReturnValue(Executable executable)
static ConstraintLocation forCrossParameter(Executable executable)
static ConstraintLocation forParameter(Executable executable, int index)
Class<?> getDeclaringClass()
Member getMember()
null
when this location represents a type.Type getTypeForValidatorResolution()
void appendTo(ExecutableParameterNameProvider parameterNameProvider, PathImpl path)
Object getValue(Object parent)
FieldConstraintLocation
or GetterConstraintLocation
but an
object array for a ParameterConstraintLocation
.Copyright © 2021 JBoss by Red Hat. All rights reserved.