Top Description Inners Fields Constructors Methods
org.hibernate.validator.internal.engine

public Class ValidatorImpl

extends Object
implements Validator, ExecutableValidator
Class Inheritance
All Implemented Interfaces
jakarta.validation.executable.ExecutableValidator, jakarta.validation.Validator
Static Imports
org.hibernate.validator.internal.util.logging.Messages.MESSAGES

The main Bean Validation class. This is the core processing class of Hibernate Validator.
Authors
Emmanuel Bernard, Hardy Ferentschik, Gunnar Morling, Kevin Pollet <[email protected]> (C) 2011 SERLI, Guillaume Smet

Nested and Inner Type Summary

Modifier and TypeClass and Description
private class

Field Summary

Modifier and TypeField and Description
private final BeanMetaDataManager
beanMetaDataManager

Used to get access to the bean meta data.

private final ConstraintValidatorFactory
constraintValidatorFactory

Reference to shared ConstraintValidatorFactory.

private final HibernateConstraintValidatorInitializationContext
constraintValidatorInitializationContext

The constraint initialization context is stored at this level to prevent creating a new instance each time we initialize a new constraint validator as, for now, it only contains Validator scoped objects.

private final ConstraintValidatorManager
constraintValidatorManager

Manages the life cycle of constraint validator instances

private static final Collection<Class<?>>
DEFAULT_GROUPS

The default group array used in case any of the validate methods is called without a group.

private static final Log
private final TraversableResolver
traversableResolver

TraversableResolver as passed to the constructor of this instance.

private final transient ValidationOrderGenerator
validationOrderGenerator

Used to resolve the group execution order for a validate call.

private final ValidatorScopedContext
validatorScopedContext

Context containing all Validator level helpers and configuration properties.

private final ValueExtractorManager

Constructor Summary

AccessConstructor and Description
public
ValidatorImpl(ConstraintValidatorFactory constraintValidatorFactory, BeanMetaDataManager beanMetaDataManager, ValueExtractorManager valueExtractorManager, ConstraintValidatorManager constraintValidatorManager, ValidationOrderGenerator validationOrderGenerator, ValidatorFactoryScopedContext validatorFactoryScopedContext)

Method Summary

Modifier and TypeMethod and Description
private BeanValueContext<?, Object>
private ValidationOrder
public ExecutableValidator
forExecutables()

Implements jakarta.validation.Validator.forExecutables.

Returns the contract for validating parameters and return values of methods and constructors.
private PropertyMetaData
getBeanPropertyMetaData(BeanMetaData<?> beanMetaData, Path.Node propertyNode)

private Object
getCascadableValue(BaseBeanValidationContext<?> validationContext, Object object, Cascadable cascadable)

public final BeanDescriptor
getConstraintsForClass(Class<?>
class or interface type evaluated
clazz
)

Implements jakarta.validation.Validator.getConstraintsForClass.

Returns the descriptor object describing bean constraints.
private <T> ValueContext<T, Object>
getExecutableValueContext(T object, ExecutableMetaData executableMetaData, Validatable validatable, Class<?> group)

private ValidationContextBuilder
private <V> BeanValueContext<?, V>

Returns:

Returns an instance of ValueContext which describes the local validation context associated to the given property path.
getValueContextForPropertyValidation
(BaseBeanValidationContext<?>
The validation context.
validationContext
,
PathImpl
The property path for which constraints have to be collected.
propertyPath
)

Returns a value context pointing to the given property path relative to the specified root class for a given value.

private <V> BeanValueContext<?, V>

Returns:

Returns an instance of ValueContext which describes the local validation context associated to the given property path.
getValueContextForValueValidation
(Class<?>
The class of the root bean.
rootBeanClass
,
PathImpl
The property path for which constraints have to be collected.
propertyPath
)

Returns a value context pointing to the given property path relative to the specified root class without a value.

private boolean
isCascadeRequired(BaseBeanValidationContext<?> validationContext, Object traversableObject, PathImpl path, ConstraintLocation.ConstraintLocationKind constraintLocationKind)

private boolean
private boolean
private boolean
private boolean
isReachable(BaseBeanValidationContext<?> validationContext, Object traversableObject, PathImpl path, ConstraintLocation.ConstraintLocationKind constraintLocationKind)

private boolean
private boolean
isValidationRequired(BaseBeanValidationContext<?> validationContext, ValueContext<?, ?> valueContext, MetaConstraint<?> metaConstraint)

private boolean
private void
sanityCheckGroups(Class<?>[] groups)

private void
private boolean
public final <T> T
unwrap(Class<T>
the class of the object to be returned
type
)

Implements jakarta.validation.Validator.unwrap.

Returns an instance of the specified type allowing access to provider-specific APIs.
public final <T> Set<ConstraintViolation<T>>
validate(T
object to validate
object
,
Class<?>...
the group or list of groups targeted for validation (defaults to Default)
groups
)

Implements jakarta.validation.Validator.validate.

Validates all constraints on object.
private void
private void
validateCascadedConstraints(BaseBeanValidationContext<?>
The execution context
validationContext
,
ValueContext<?, Object>
Collected information for single validation
valueContext
)

Validates all cascaded constraints for the given bean using the current group set in the execution context.

private void
validateCascadedContainerElementsForCurrentGroup(Object value, BaseBeanValidationContext<?> validationContext, ValueContext<?, ?> valueContext, List<ContainerCascadingMetaData> containerElementTypesCascadingMetaData)

private void
validateCascadedContainerElementsInContext(Object value, BaseBeanValidationContext<?> validationContext, ValueContext<?, ?> valueContext, ContainerCascadingMetaData cascadingMetaData, ValidationOrder validationOrder)

private void
private <U> void
private void
private <U> boolean
validateConstraintsForSingleDefaultGroupElement(BaseBeanValidationContext<?> validationContext, ValueContext<U, Object> valueContext, final Map<Class<?>, Class<?>> validatedInterfaces, Class<? super U> clazz, Set<MetaConstraint<?>> metaConstraints, Group defaultSequenceMember)

public <T> Set<ConstraintViolation<T>>
validateConstructorParameters(Constructor<? extends T>
the constructor for which the parameter constraints is validated
constructor
,
Object[]
the values provided by the caller for the given constructor's parameters
parameterValues
,
Class<?>...
the group or list of groups targeted for validation (defaults to Default)
groups
)

Implements jakarta.validation.executable.ExecutableValidator.validateConstructorParameters.

Validates all constraints placed on the parameters of the given constructor.
public <T> Set<ConstraintViolation<T>>
validateConstructorReturnValue(Constructor<? extends T>
the constructor for which the return value constraints is validated
constructor
,
T
the object instantiated by the given method
createdObject
,
Class<?>...
the group or list of groups targeted for validation (defaults to Default)
groups
)

Implements jakarta.validation.executable.ExecutableValidator.validateConstructorReturnValue.

Validates all return value constraints of the given constructor.
private <
The root bean type
T
, U>
Set<ConstraintViolation<T>>

Returns:

Set of constraint violations or the empty set if there were no violations.
validateInContext
(BaseBeanValidationContext<T>
the global validation context
validationContext
,
BeanValueContext<U, Object>
the current validation context
valueContext
,
ValidationOrder
Contains the information which and in which order groups have to be executed
validationOrder
)

Validates the given object using the available context information.

private boolean
validateMetaConstraint(BaseBeanValidationContext<?> validationContext, ValueContext<?, Object> valueContext, Object parent, MetaConstraint<?> metaConstraint)

private void
validateMetaConstraints(BaseBeanValidationContext<?> validationContext, ValueContext<?, Object> valueContext, Object parent, Iterable<MetaConstraint<?>> constraints)

public <T> Set<ConstraintViolation<T>>
validateParameters(T
the object on which the method to validate is invoked
object
,
Method
the method for which the parameter constraints is validated
method
,
Object[]
the values provided by the caller for the given method's parameters
parameterValues
,
Class<?>...
the group or list of groups targeted for validation (defaults to Default)
groups
)

Implements jakarta.validation.executable.ExecutableValidator.validateParameters.

Validates all constraints placed on the parameters of the given method.
private <T> Set<ConstraintViolation<T>>
validateParameters(T object, Executable executable, Object[] parameterValues, Class<?>... groups)

private <T> void
validateParametersForGroup(ExecutableValidationContext<T> validationContext, ExecutableMetaData executableMetaData, Object[] parameterValues, Group group)

private <T> void
validateParametersForSingleGroup(ExecutableValidationContext<T> validationContext, Object[] parameterValues, ExecutableMetaData executableMetaData, Class<?> currentValidatedGroup)

private <T> void
validateParametersInContext(ExecutableValidationContext<T> validationContext, Object[] parameterValues, ValidationOrder validationOrder)

public final <T> Set<ConstraintViolation<T>>
validateProperty(T
object to validate
object
,
String
property to validate (i.e. field and getter constraints)
propertyName
,
Class<?>...
the group or list of groups targeted for validation (defaults to Default)
groups
)

Implements jakarta.validation.Validator.validateProperty.

Validates all constraints placed on the property of object named propertyName.
public <T> Set<ConstraintViolation<T>>
validateReturnValue(T
the object on which the method to validate is invoked
object
,
Method
the method for which the return value constraints is validated
method
,
Object
the value returned by the given method
returnValue
,
Class<?>...
the group or list of groups targeted for validation (defaults to Default)
groups
)

Implements jakarta.validation.executable.ExecutableValidator.validateReturnValue.

Validates all return value constraints of the given method.
private <T> Set<ConstraintViolation<T>>
validateReturnValue(T object, Executable executable, Object returnValue, Class<?>... groups)

private <T> void
validateReturnValueForGroup(BaseBeanValidationContext<T> validationContext, ExecutableMetaData executableMetaData, T bean, Object value, Group group)

private <T> void
validateReturnValueForSingleGroup(BaseBeanValidationContext<T> validationContext, ExecutableMetaData executableMetaData, T bean, Object value, Class<?> oneGroup)

private <V, T> void
validateReturnValueInContext(ExecutableValidationContext<T> validationContext, T bean, V value, ValidationOrder validationOrder)

public final <T> Set<ConstraintViolation<T>>
validateValue(Class<T>
the bean type
beanType
,
String
property to validate
propertyName
,
Object
property value to validate
value
,
Class<?>...
the group or list of groups targeted for validation (defaults to Default).
groups
)

Implements jakarta.validation.Validator.validateValue.

Validates all constraints placed on the property named propertyName of the class beanType would the property value be value.
private <T> Set<ConstraintViolation<T>>
validateValueInContext(BaseBeanValidationContext<T> validationContext, Object value, PathImpl propertyPath, ValidationOrder validationOrder)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait