public class ValidatorImpl extends Object implements Validator, ExecutableValidator
Constructor and Description |
---|
ValidatorImpl(ConstraintValidatorFactory constraintValidatorFactory,
BeanMetaDataManager beanMetaDataManager,
ValueExtractorManager valueExtractorManager,
ConstraintValidatorManager constraintValidatorManager,
ValidationOrderGenerator validationOrderGenerator,
org.hibernate.validator.internal.engine.ValidatorFactoryImpl.ValidatorFactoryScopedContext validatorFactoryScopedContext) |
Modifier and Type | Method and Description |
---|---|
ExecutableValidator |
forExecutables()
Returns the contract for validating parameters and return values of methods
and constructors.
|
BeanDescriptor |
getConstraintsForClass(Class<?> clazz)
Returns the descriptor object describing bean constraints.
|
<T> T |
unwrap(Class<T> type)
Returns an instance of the specified type allowing access to
provider-specific APIs.
|
<T> Set<ConstraintViolation<T>> |
validate(T object,
Class<?>... groups)
Validates all constraints on
object . |
<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.
|
<T> Set<ConstraintViolation<T>> |
validateProperty(T object,
String propertyName,
Class<?>... groups)
Validates all constraints placed on the property of
object
named propertyName . |
<T> Set<ConstraintViolation<T>> |
validateReturnValue(T object,
Method method,
Object returnValue,
Class<?>... groups)
Validates all return value constraints of the given method.
|
<T> Set<ConstraintViolation<T>> |
validateValue(Class<T> beanType,
String propertyName,
Object value,
Class<?>... groups)
Validates all constraints placed on the property named
propertyName
of the class beanType would the property value be value . |
public ValidatorImpl(ConstraintValidatorFactory constraintValidatorFactory, BeanMetaDataManager beanMetaDataManager, ValueExtractorManager valueExtractorManager, ConstraintValidatorManager constraintValidatorManager, ValidationOrderGenerator validationOrderGenerator, org.hibernate.validator.internal.engine.ValidatorFactoryImpl.ValidatorFactoryScopedContext validatorFactoryScopedContext)
public final <T> Set<ConstraintViolation<T>> validate(T object, Class<?>... groups)
Validator
object
.public final <T> Set<ConstraintViolation<T>> validateProperty(T object, String propertyName, Class<?>... groups)
Validator
object
named propertyName
.validateProperty
in interface Validator
T
- the type of the object to validateobject
- object to validatepropertyName
- property to validate (i.e. field and getter constraints)groups
- the group or list of groups targeted for validation (defaults to
Default
)public final <T> Set<ConstraintViolation<T>> validateValue(Class<T> beanType, String propertyName, Object value, Class<?>... groups)
Validator
propertyName
of the class beanType
would the property value be value
.
ConstraintViolation
objects return null
for
ConstraintViolation.getRootBean()
and
ConstraintViolation.getLeafBean()
.
validateValue
in interface Validator
T
- the type of the object to validatebeanType
- the bean typepropertyName
- property to validatevalue
- property value to validategroups
- the group or list of groups targeted for validation (defaults to
Default
).public <T> Set<ConstraintViolation<T>> validateParameters(T object, Method method, Object[] parameterValues, Class<?>... groups)
ExecutableValidator
validateParameters
in interface ExecutableValidator
T
- the type hosting the method to validateobject
- 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 to
Default
)null
public <T> Set<ConstraintViolation<T>> validateConstructorParameters(Constructor<? extends T> constructor, Object[] parameterValues, Class<?>... groups)
ExecutableValidator
validateConstructorParameters
in interface ExecutableValidator
T
- the type hosting the constructor to validateconstructor
- 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 to
Default
)null
public <T> Set<ConstraintViolation<T>> validateConstructorReturnValue(Constructor<? extends T> constructor, T createdObject, Class<?>... groups)
ExecutableValidator
validateConstructorReturnValue
in interface ExecutableValidator
T
- the type hosting the constructor to validateconstructor
- 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 to
Default
)null
public <T> Set<ConstraintViolation<T>> validateReturnValue(T object, Method method, Object returnValue, Class<?>... groups)
ExecutableValidator
validateReturnValue
in interface ExecutableValidator
T
- the type hosting the method to validateobject
- 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 to
Default
)null
public final BeanDescriptor getConstraintsForClass(Class<?> clazz)
Validator
The returned object (and associated objects including
ConstraintDescriptor
s) are immutable.
getConstraintsForClass
in interface Validator
clazz
- class or interface type evaluatedpublic final <T> T unwrap(Class<T> type)
Validator
If the Jakarta Bean Validation provider implementation does not support
the specified class, ValidationException
is thrown.
public ExecutableValidator forExecutables()
Validator
forExecutables
in interface Validator
Copyright © 2021 JBoss by Red Hat. All rights reserved.