Top Description Inners Methods
org.hibernate.validator.internal.metadata.location

public Interface ConstraintLocation

Known Direct Implementers
org.hibernate.validator.internal.metadata.location.CrossParameterConstraintLocation, org.hibernate.validator.internal.metadata.location.ParameterConstraintLocation, org.hibernate.validator.internal.metadata.location.ReturnValueConstraintLocation, org.hibernate.validator.internal.metadata.location.TypeArgumentConstraintLocation, org.hibernate.validator.internal.metadata.location.AbstractPropertyConstraintLocation, org.hibernate.validator.internal.metadata.location.BeanConstraintLocation
Imports
java.lang.annotation.ElementType, java.lang.reflect.Type, .TypeVariable, org.hibernate.validator.internal.engine.path.PathImpl, org.hibernate.validator.internal.metadata.raw.ConstrainedElement.ConstrainedElementKind, org.hibernate.validator.internal.properties.Callable, .Constrainable, .Field, .Getter, org.hibernate.validator.internal.util.ExecutableParameterNameProvider, .StringHelper

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

Authors
Hardy Ferentschik, Gunnar Morling

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static enum

Method Summary

Modifier and TypeMethod and Description
public void
appendTo(ExecutableParameterNameProvider parameterNameProvider, PathImpl path)

Appends a node representing this location to the given property path.

public static ConstraintLocation
forClass(Class<?> declaringClass)

public static ConstraintLocation
public static ConstraintLocation
forField(Field field)

public static ConstraintLocation
forGetter(Getter getter)

public static ConstraintLocation
forParameter(Callable callable, int index)

public static ConstraintLocation
public static ConstraintLocation
forTypeArgument(ConstraintLocation delegate, TypeVariable<?> typeParameter, Type typeOfAnnotatedElement)

public Constrainable

Returns:

the member represented by this location. Will be null when this location represents a type.
getConstrainable
()

Returns the member represented by this location.

public Class<?>
getDeclaringClass()

Returns the class hosting this location.

public ConstraintLocation.ConstraintLocationKind
getKind()

Returns the nature of the constraint location.

public Type

Returns:

The type to be used when resolving constraint validators for constraints at this location
getTypeForValidatorResolution
()

Returns the type to be used when resolving constraint validators for constraints at this location.

public Object
getValue(Object parent)

Obtains the value of this location from the parent.

Method Detail

appendToback to summary
public void appendTo(ExecutableParameterNameProvider parameterNameProvider, PathImpl path)

Appends a node representing this location to the given property path.

forClassback to summary
public static ConstraintLocation forClass(Class<?> declaringClass)
forCrossParameterback to summary
public static ConstraintLocation forCrossParameter(Callable callable)
forFieldback to summary
public static ConstraintLocation forField(Field field)
forGetterback to summary
public static ConstraintLocation forGetter(Getter getter)
forParameterback to summary
public static ConstraintLocation forParameter(Callable callable, int index)
forReturnValueback to summary
public static ConstraintLocation forReturnValue(Callable callable)
forTypeArgumentback to summary
public static ConstraintLocation forTypeArgument(ConstraintLocation delegate, TypeVariable<?> typeParameter, Type typeOfAnnotatedElement)
getConstrainableback to summary
public Constrainable getConstrainable()

Returns the member represented by this location.

Returns:Constrainable

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

getDeclaringClassback to summary
public Class<?> getDeclaringClass()

Returns the class hosting this location.

getKindback to summary
public ConstraintLocation.ConstraintLocationKind getKind()

Returns the nature of the constraint location.

getTypeForValidatorResolutionback to summary
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:Type

The type to be used when resolving constraint validators for constraints at this location

getValueback to summary
public Object getValue(Object parent)

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 a AbstractPropertyConstraintLocation but an object array for a ParameterConstraintLocation.

org.hibernate.validator.internal.metadata.location back to summary

public final Enum ConstraintLocation.ConstraintLocationKind

extends Enum<ConstraintLocation.ConstraintLocationKind>
Class Inheritance

Field Summary

Modifier and TypeField and Description
public static final ConstraintLocation.ConstraintLocationKind
private final ElementType
public static final ConstraintLocation.ConstraintLocationKind
public static final ConstraintLocation.ConstraintLocationKind
public static final ConstraintLocation.ConstraintLocationKind
public static final ConstraintLocation.ConstraintLocationKind
public static final ConstraintLocation.ConstraintLocationKind
public static final ConstraintLocation.ConstraintLocationKind

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public ElementType
public boolean
public boolean
public static ConstraintLocation.ConstraintLocationKind
public static ConstraintLocation.ConstraintLocationKind
public static ConstraintLocation.ConstraintLocationKind[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

CONSTRUCTORback to summary
public static final ConstraintLocation.ConstraintLocationKind CONSTRUCTOR
elementTypeback to summary
private final ElementType elementType
FIELDback to summary
public static final ConstraintLocation.ConstraintLocationKind FIELD
GETTERback to summary
public static final ConstraintLocation.ConstraintLocationKind GETTER
METHODback to summary
public static final ConstraintLocation.ConstraintLocationKind METHOD
PARAMETERback to summary
public static final ConstraintLocation.ConstraintLocationKind PARAMETER
TYPEback to summary
public static final ConstraintLocation.ConstraintLocationKind TYPE
TYPE_USEback to summary
public static final ConstraintLocation.ConstraintLocationKind TYPE_USE

Constructor Detail

ConstraintLocationKindback to summary
private ConstraintLocationKind(ElementType elementType)

Method Detail

getElementTypeback to summary
public ElementType getElementType()
isExecutableback to summary
public boolean isExecutable()
isMethodback to summary
public boolean isMethod()
ofback to summary
public static ConstraintLocation.ConstraintLocationKind of(ConstrainedElement.ConstrainedElementKind constrainedElementKind)
valueOfback to summary
public static ConstraintLocation.ConstraintLocationKind valueOf(String name)
valuesback to summary
public static ConstraintLocation.ConstraintLocationKind[] values()