|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface Validator
Validates bean instances. Implementations of this interface must be thread-safe.
Method Summary | ||
---|---|---|
BeanDescriptor |
getConstraintsForClass(Class<?> clazz)
Return the descriptor object describing bean constraints. |
|
|
unwrap(Class<T> type)
Return an instance of the specified type allowing access to provider-specific APIs. |
|
|
validate(T object,
Class<?>... groups)
Validates all constraints on object . |
|
|
validateConstructorParameters(Constructor<T> constructor,
Object[] parameterValues,
Class<?>... groups)
Validates all constraints placed on the parameters of the given constructor. |
|
|
validateConstructorReturnValue(Constructor<T> constructor,
T createdObject,
Class<?>... groups)
Validates all return value constraints of the given constructor. |
|
|
validateParameters(T object,
Method method,
Object[] parameterValues,
Class<?>... groups)
Validates all constraints placed on the parameters of the given method. |
|
|
validateProperty(T object,
String propertyName,
Class<?>... groups)
Validates all constraints placed on the property of object
named propertyName . |
|
|
validateReturnValue(T object,
Method method,
Object returnValue,
Class<?>... groups)
Validates all return value constraints of the given method. |
|
|
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() |
Method Detail |
---|
<T> Set<ConstraintViolation<T>> validate(T object, Class<?>... groups)
object
.
object
- 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 groups
ValidationException
- if a non recoverable error happens
during the validation process<T> Set<ConstraintViolation<T>> validateProperty(T object, String propertyName, Class<?>... groups)
object
named propertyName
.
object
- object to validatepropertyName
- property to validate (ie field and getter constraints)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 groups
ValidationException
- if a non recoverable error happens
during the validation process<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()
beanType
- 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 groups
ValidationException
- if a non recoverable error happens
during the validation process<T> Set<ConstraintViolation<T>> validateParameters(T object, Method method, Object[] parameterValues, Class<?>... groups)
T
- The type hosting the method to validate.object
- The object on which the method to validate was invoked.method
- The method for which the parameter constraints shall be validated.parameterValues
- The values provided by the caller for the given method's
parameters.groups
- group or list of groups targeted for validation (default to
Default
)
ValidationException
- if a non recoverable error happens during the
validation process<T> Set<ConstraintViolation<T>> validateReturnValue(T object, Method method, Object returnValue, Class<?>... groups)
T
- The type hosting the method to validate.object
- The object on which the method to validate was invoked.method
- The method for which the return value constraints shall be validated.returnValue
- The value returned by the given method.groups
- group or list of groups targeted for validation (default to
Default
)
ValidationException
- if a non recoverable error happens during the
validation process<T> Set<ConstraintViolation<T>> validateConstructorParameters(Constructor<T> constructor, Object[] parameterValues, Class<?>... groups)
T
- The type hosting the constructor to validate.constructor
- The constructor for which the parameter constraints shall be validated.parameterValues
- The values provided by the caller for the given constructor's
parameters.groups
- group or list of groups targeted for validation (default to
Default
)
ValidationException
- if a non recoverable error happens during the
validation process<T> Set<ConstraintViolation<T>> validateConstructorReturnValue(Constructor<T> constructor, T createdObject, Class<?>... groups)
T
- The type hosting the constructor to validate.constructor
- The constructor for which the return value constraints shall be validated.createdObject
- The object instantiated by the given method.groups
- group or list of groups targeted for validation (default to
Default
)
ValidationException
- if a non recoverable error happens during the
validation processBeanDescriptor getConstraintsForClass(Class<?> clazz)
ConstraintDescriptors) are immutable.
- Parameters:
clazz
- class or interface type evaluated
- Returns:
- the bean descriptor for the specified class.
- Throws:
IllegalArgumentException
- if clazz is null
ValidationException
- if a non recoverable error happens
during the metadata discovery or if some
constraints are invalid.
<T> T unwrap(Class<T> type)
ValidationException
is thrown.
type
- the class of the object to be returned.
ValidationException
- if the provider does not support the call.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |