Class ValidatorImpl
java.lang.Object
org.hibernate.validator.internal.engine.ValidatorImpl
- All Implemented Interfaces:
ExecutableValidator,Validator
The main Bean Validation class. This is the core processing class of Hibernate Validator.
- Author:
- Emmanuel Bernard, Hardy Ferentschik, Gunnar Morling, Kevin Pollet <kevin.pollet@serli.com> (C) 2011 SERLI, Guillaume Smet
-
Constructor Summary
ConstructorsConstructorDescriptionValidatorImpl(ConstraintValidatorFactory constraintValidatorFactory, BeanMetaDataManager beanMetaDataManager, ValueExtractorManager valueExtractorManager, ConstraintValidatorManager constraintValidatorManager, ValidationOrderGenerator validationOrderGenerator, ValidatorFactoryScopedContext validatorFactoryScopedContext) -
Method Summary
Modifier and TypeMethodDescriptionReturns the contract for validating parameters and return values of methods and constructors.final BeanDescriptorgetConstraintsForClass(Class<?> clazz) Returns the descriptor object describing bean constraints.final <T> TReturns an instance of the specified type allowing access to provider-specific APIs.final <T> Set<ConstraintViolation<T>>Validates all constraints onobject.<T> Set<ConstraintViolation<T>>validateConstructorParameters(Constructor<? extends T> constructor, Object[] parameterValues, Class<?>... groups) Validates all constraints placed on the parameters of the given constructor.<T> Set<ConstraintViolation<T>>validateConstructorReturnValue(Constructor<? extends T> constructor, T createdObject, Class<?>... groups) Validates all return value constraints of the given constructor.<T> Set<ConstraintViolation<T>>validateParameters(T object, Method method, Object[] parameterValues, Class<?>... groups) Validates all constraints placed on the parameters of the given method.final <T> Set<ConstraintViolation<T>>validateProperty(T object, String propertyName, Class<?>... groups) Validates all constraints placed on the property ofobjectnamedpropertyName.<T> Set<ConstraintViolation<T>>validateReturnValue(T object, Method method, Object returnValue, Class<?>... groups) Validates all return value constraints of the given method.final <T> Set<ConstraintViolation<T>>validateValue(Class<T> beanType, String propertyName, Object value, Class<?>... groups) Validates all constraints placed on the property namedpropertyNameof the classbeanTypewould the property value bevalue.
-
Constructor Details
-
ValidatorImpl
public ValidatorImpl(ConstraintValidatorFactory constraintValidatorFactory, BeanMetaDataManager beanMetaDataManager, ValueExtractorManager valueExtractorManager, ConstraintValidatorManager constraintValidatorManager, ValidationOrderGenerator validationOrderGenerator, ValidatorFactoryScopedContext validatorFactoryScopedContext)
-
-
Method Details
-
validate
Description copied from interface:ValidatorValidates all constraints onobject. -
validateProperty
public final <T> Set<ConstraintViolation<T>> validateProperty(T object, String propertyName, Class<?>... groups) Description copied from interface:ValidatorValidates all constraints placed on the property ofobjectnamedpropertyName.- Specified by:
validatePropertyin interfaceValidator- Type Parameters:
T- the type of the object to validate- Parameters:
object- object to validatepropertyName- property to validate (i.e. field and getter constraints)groups- the group or list of groups targeted for validation (defaults toDefault)- Returns:
- constraint violations or an empty set if none
-
validateValue
public final <T> Set<ConstraintViolation<T>> validateValue(Class<T> beanType, String propertyName, Object value, Class<?>... groups) Description copied from interface:ValidatorValidates all constraints placed on the property namedpropertyNameof the classbeanTypewould the property value bevalue.ConstraintViolationobjects returnnullforConstraintViolation.getRootBean()andConstraintViolation.getLeafBean().- Specified by:
validateValuein interfaceValidator- Type Parameters:
T- the type of the object to validate- Parameters:
beanType- the bean typepropertyName- property to validatevalue- property value to validategroups- the group or list of groups targeted for validation (defaults toDefault).- Returns:
- constraint violations or an empty set if none
-
validateParameters
public <T> Set<ConstraintViolation<T>> validateParameters(T object, Method method, Object[] parameterValues, Class<?>... groups) Description copied from interface:ExecutableValidatorValidates all constraints placed on the parameters of the given method.- Specified by:
validateParametersin interfaceExecutableValidator- Type Parameters:
T- the type hosting the method to validate- Parameters:
object- the object on which the method to validate is invokedmethod- the method for which the parameter constraints is validatedparameterValues- the values provided by the caller for the given method's parametersgroups- the group or list of groups targeted for validation (defaults toDefault)- Returns:
- a set with the constraint violations caused by this validation;
will be empty if no error occurs, but never
null
-
validateConstructorParameters
public <T> Set<ConstraintViolation<T>> validateConstructorParameters(Constructor<? extends T> constructor, Object[] parameterValues, Class<?>... groups) Description copied from interface:ExecutableValidatorValidates all constraints placed on the parameters of the given constructor.- Specified by:
validateConstructorParametersin interfaceExecutableValidator- Type Parameters:
T- the type hosting the constructor to validate- Parameters:
constructor- the constructor for which the parameter constraints is validatedparameterValues- the values provided by the caller for the given constructor's parametersgroups- the group or list of groups targeted for validation (defaults toDefault)- Returns:
- a set with the constraint violations caused by this validation;
Will be empty if no error occurs, but never
null
-
validateConstructorReturnValue
public <T> Set<ConstraintViolation<T>> validateConstructorReturnValue(Constructor<? extends T> constructor, T createdObject, Class<?>... groups) Description copied from interface:ExecutableValidatorValidates all return value constraints of the given constructor.- Specified by:
validateConstructorReturnValuein interfaceExecutableValidator- Type Parameters:
T- the type hosting the constructor to validate- Parameters:
constructor- the constructor for which the return value constraints is validatedcreatedObject- the object instantiated by the given methodgroups- the group or list of groups targeted for validation (defaults toDefault)- Returns:
- a set with the constraint violations caused by this validation;
will be empty, if no error occurs, but never
null
-
validateReturnValue
public <T> Set<ConstraintViolation<T>> validateReturnValue(T object, Method method, Object returnValue, Class<?>... groups) Description copied from interface:ExecutableValidatorValidates all return value constraints of the given method.- Specified by:
validateReturnValuein interfaceExecutableValidator- Type Parameters:
T- the type hosting the method to validate- Parameters:
object- the object on which the method to validate is invokedmethod- the method for which the return value constraints is validatedreturnValue- the value returned by the given methodgroups- the group or list of groups targeted for validation (defaults toDefault)- Returns:
- a set with the constraint violations caused by this validation;
will be empty if no error occurs, but never
null
-
getConstraintsForClass
Description copied from interface:ValidatorReturns the descriptor object describing bean constraints.The returned object (and associated objects including
ConstraintDescriptors) are immutable.- Specified by:
getConstraintsForClassin interfaceValidator- Parameters:
clazz- class or interface type evaluated- Returns:
- the bean descriptor for the specified class
-
unwrap
Description copied from interface:ValidatorReturns an instance of the specified type allowing access to provider-specific APIs.If the Jakarta Bean Validation provider implementation does not support the specified class,
ValidationExceptionis thrown. -
forExecutables
Description copied from interface:ValidatorReturns the contract for validating parameters and return values of methods and constructors.- Specified by:
forExecutablesin interfaceValidator- Returns:
- contract for method and constructor validation
-