public class ClassValidator extends Object implements CascadingPropertyValidator, ExecutableValidator
| Modifier and Type | Class and Description |
|---|---|
protected class |
ClassValidator.JsrValidationCallback
Dispatches a call from
ClassValidator.JsrValidationCallback.validate() to validateBeanNet(GroupValidationContext) with
the current context set. |
| Modifier and Type | Field and Description |
|---|---|
protected ApacheFactoryContext |
factoryContext
ApacheFactoryContext used |
protected GroupsComputer |
groupsComputer
GroupsComputer used |
| Constructor and Description |
|---|
ClassValidator(ApacheFactoryContext factoryContext)
Create a new ClassValidator instance.
|
| Modifier and Type | Method and Description |
|---|---|
protected BeanDescriptorImpl |
createBeanDescriptor(MetaBean metaBean)
Create a
BeanDescriptorImpl |
protected <T> GroupValidationContext<T> |
createContext(MetaBean metaBean,
T object,
Class<T> objectClass,
Class<?>... groups)
Create a
GroupValidationContext. |
protected <T> GroupValidationContext<T> |
createInvocableContext(MetaBean metaBean,
T object,
Class<T> objectClass,
Class<?>... groups) |
protected ValidationContextTraversal |
createValidationContextTraversal(GroupValidationContext<?> validationContext)
Create a
ValidationContextTraversal instance for this ClassValidator. |
ExecutableValidator |
forExecutables() |
BeanDescriptor |
getConstraintsForClass(Class<?> clazz)
Return the descriptor object describing bean constraints.
|
protected static RuntimeException |
unrecoverableValidationError(RuntimeException ex,
Object object)
Generate an unrecoverable validation error
|
<T> T |
unwrap(Class<T> type)
Return 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. |
protected void |
validateBeanNet(GroupValidationContext<?> context)
Validates a bean and all its cascaded related beans for the currently defined group.
|
<T> Set<ConstraintViolation<T>> |
validateConstructorParameters(Constructor<? extends T> constructor,
Object[] parameterValues,
Class<?>... gps) |
<T> Set<ConstraintViolation<T>> |
validateConstructorReturnValue(Constructor<? extends T> constructor,
T createdObject,
Class<?>... gps) |
<T> Set<ConstraintViolation<T>> |
validateParameters(T object,
Method method,
Object[] parameterValues,
Class<?>... groups) |
<T> Set<ConstraintViolation<T>> |
validateProperty(T object,
String propertyName,
boolean cascade,
Class<?>... groups)
Validates all constraints placed on
object's
propertyName property, with optional validation cascading. |
<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) |
<T> Set<ConstraintViolation<T>> |
validateValue(Class<T> beanType,
String propertyName,
Object value,
boolean cascade,
Class<?>... groups)
Validates all constraints placed on
object's
propertyName property, with optional validation cascading,
given a hypothetical property value. |
<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
ConstraintViolation objects return null for ConstraintViolation.getRootBean() and
ConstraintViolation.getLeafBean() |
protected final ApacheFactoryContext factoryContext
ApacheFactoryContext usedprotected final GroupsComputer groupsComputer
GroupsComputer usedpublic ClassValidator(ApacheFactoryContext factoryContext)
factoryContext - public <T> Set<ConstraintViolation<T>> validate(T object, Class<?>... groups)
object.validate in interface Validatorobject - object to validategroups - group or list of groups targeted for validation (default to
Default)IllegalArgumentException - if object is null or if null is passed to the varargs groupsValidationException - if a non recoverable error happens during the validation
processpublic <T> Set<ConstraintViolation<T>> validateProperty(T object, String propertyName, Class<?>... groups)
object named
propertyName.validateProperty in interface Validatorobject - object to validatepropertyName - property to validate (ie field and getter constraints). Nested
properties may be referenced (e.g. prop[2].subpropA.subpropB)groups - group or list of groups targeted for validation (default to
Default)IllegalArgumentException - if object is null, if propertyName
null, empty or not a valid object property or if null is
passed to the varargs groupsValidationException - if a non recoverable error happens during the validation
processpublic <T> Set<ConstraintViolation<T>> validateProperty(T object, String propertyName, boolean cascade, Class<?>... groups)
object's
propertyName property, with optional validation cascading.validateProperty in interface CascadingPropertyValidatorSet of ConstraintViolations.public <T> Set<ConstraintViolation<T>> validateValue(Class<T> beanType, String propertyName, Object value, Class<?>... groups)
propertyName of the class
beanType would the property value be value
ConstraintViolation objects return null for ConstraintViolation.getRootBean() and
ConstraintViolation.getLeafBean()validateValue in interface ValidatorbeanType - the bean typepropertyName - property to validatevalue - property value to validategroups - group or list of groups targeted for validation (default to
Default)IllegalArgumentException - if beanType is null, if
propertyName null, empty or not a valid object
property or if null is passed to the varargs groupsValidationException - if a non recoverable error happens during the validation
processpublic <T> Set<ConstraintViolation<T>> validateValue(Class<T> beanType, String propertyName, Object value, boolean cascade, Class<?>... groups)
object's
propertyName property, with optional validation cascading,
given a hypothetical property value.validateValue in interface CascadingPropertyValidatorSet of ConstraintViolations.public BeanDescriptor getConstraintsForClass(Class<?> clazz)
ConstraintDescriptors) are immutable.getConstraintsForClass in interface Validatorclazz - class or interface type evaluatedIllegalArgumentException - if clazz is nullValidationException - if a non recoverable error happens during the metadata
discovery or if some constraints are invalid.public <T> T unwrap(Class<T> type)
ValidationException is
thrown.unwrap in interface Validatortype - the class of the object to be returned.ValidationException - if the provider does not support the call.public ExecutableValidator forExecutables()
forExecutables in interface Validatorprotected void validateBeanNet(GroupValidationContext<?> context)
Default group.context - The current context of this validation call. Must have its
GroupValidationContext.getCurrentGroup() field set.protected static RuntimeException unrecoverableValidationError(RuntimeException ex, Object object)
ex - object - RuntimeException of the appropriate typeprotected <T> GroupValidationContext<T> createContext(MetaBean metaBean, T object, Class<T> objectClass, Class<?>... groups)
GroupValidationContext.T - metaBean - object - objectClass - groups - GroupValidationContext instanceprotected <T> GroupValidationContext<T> createInvocableContext(MetaBean metaBean, T object, Class<T> objectClass, Class<?>... groups)
protected BeanDescriptorImpl createBeanDescriptor(MetaBean metaBean)
BeanDescriptorImplmetaBean - BeanDescriptorImpl instancepublic <T> Set<ConstraintViolation<T>> validateConstructorParameters(Constructor<? extends T> constructor, Object[] parameterValues, Class<?>... gps)
validateConstructorParameters in interface ExecutableValidatorpublic <T> Set<ConstraintViolation<T>> validateConstructorReturnValue(Constructor<? extends T> constructor, T createdObject, Class<?>... gps)
validateConstructorReturnValue in interface ExecutableValidatorpublic <T> Set<ConstraintViolation<T>> validateParameters(T object, Method method, Object[] parameterValues, Class<?>... groups)
validateParameters in interface ExecutableValidatorpublic <T> Set<ConstraintViolation<T>> validateReturnValue(T object, Method method, Object returnValue, Class<?>... groups)
validateReturnValue in interface ExecutableValidatorprotected ValidationContextTraversal createValidationContextTraversal(GroupValidationContext<?> validationContext)
ValidationContextTraversal instance for this ClassValidator.validationContext - ValidationContextTraversalCopyright © 2010–2024 The Apache Software Foundation. All rights reserved.