org.hibernate.validator.engine
Class ValidatorImpl

java.lang.Object
  extended by org.hibernate.validator.engine.ValidatorImpl
All Implemented Interfaces:
Validator, MethodValidator

public class ValidatorImpl
extends Object
implements Validator, MethodValidator

The main Bean Validation class. This is the core processing class of Hibernate Validator.

Author:
Emmanuel Bernard, Hardy Ferentschik, Gunnar Morling, Kevin Pollet - SERLI - (kevin.pollet@serli.com)

Constructor Summary
ValidatorImpl(ConstraintValidatorFactory constraintValidatorFactory, MessageInterpolator messageInterpolator, TraversableResolver traversableResolver, ConstraintHelper constraintHelper, BeanMetaDataCache beanMetaDataCache, boolean failFast)
           
 
Method Summary
 BeanDescriptor getConstraintsForClass(Class<?> clazz)
           
 TypeDescriptor getConstraintsForType(Class<?> clazz)
          Returns a descriptor providing access to constraint-related meta data for the given type.
<T> T
unwrap(Class<T> type)
           
<T> Set<ConstraintViolation<T>>
validate(T object, Class<?>... groups)
           
<T> Set<MethodConstraintViolation<T>>
validateAllParameters(T object, Method method, Object[] parameterValues, Class<?>... groups)
          Validates all parameters of a given method.
<T> Set<MethodConstraintViolation<T>>
validateParameter(T object, Method method, Object parameterValue, int parameterIndex, Class<?>... groups)
          Validates a given parameter of a given method.
<T> Set<ConstraintViolation<T>>
validateProperty(T object, String propertyName, Class<?>... groups)
           
<T> Set<MethodConstraintViolation<T>>
validateReturnValue(T object, Method method, Object returnValue, Class<?>... groups)
          Validates the return value of a given method.
<T> Set<ConstraintViolation<T>>
validateValue(Class<T> beanType, String propertyName, Object value, Class<?>... groups)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ValidatorImpl

public ValidatorImpl(ConstraintValidatorFactory constraintValidatorFactory,
                     MessageInterpolator messageInterpolator,
                     TraversableResolver traversableResolver,
                     ConstraintHelper constraintHelper,
                     BeanMetaDataCache beanMetaDataCache,
                     boolean failFast)
Method Detail

validate

public final <T> Set<ConstraintViolation<T>> validate(T object,
                                                      Class<?>... groups)
Specified by:
validate in interface Validator

validateProperty

public final <T> Set<ConstraintViolation<T>> validateProperty(T object,
                                                              String propertyName,
                                                              Class<?>... groups)
Specified by:
validateProperty in interface Validator

validateValue

public final <T> Set<ConstraintViolation<T>> validateValue(Class<T> beanType,
                                                           String propertyName,
                                                           Object value,
                                                           Class<?>... groups)
Specified by:
validateValue in interface Validator

validateParameter

public final <T> Set<MethodConstraintViolation<T>> validateParameter(T object,
                                                                     Method method,
                                                                     Object parameterValue,
                                                                     int parameterIndex,
                                                                     Class<?>... groups)
Description copied from interface: MethodValidator
Validates a given parameter of a given method.

Specified by:
validateParameter in interface MethodValidator
Type Parameters:
T - The type hosting the invoked method.
Parameters:
object - The object on which the given method was invoked.
method - The invoked method for which the given parameter shall be validated.
parameterValue - The value provided by the caller for the given method.
parameterIndex - The index of the parameter to be validated within the given method's parameter array.
groups - A - potentially empty - number of validation groups for which the validation shall be performed. The @link Default group will be validated if no group is given.
Returns:
A set with the constraint violations caused by this validation. Will be empty, of no error occurs, but never null.

validateAllParameters

public final <T> Set<MethodConstraintViolation<T>> validateAllParameters(T object,
                                                                         Method method,
                                                                         Object[] parameterValues,
                                                                         Class<?>... groups)
Description copied from interface: MethodValidator
Validates all parameters of a given method.

Specified by:
validateAllParameters in interface MethodValidator
Type Parameters:
T - The type hosting the invoked method.
Parameters:
object - The object on which the given method was invoked.
method - The invoked method for which the given parameter shall be validated.
parameterValues - The values provided by the caller for the given method's parameters.
groups - A - potentially empty - number of validation groups for which the validation shall be performed. The @link Default group will be validated if no group is given.
Returns:
A set with the constraint violations caused by this validation. Will be empty, of no error occurs, but never null.

validateReturnValue

public <T> Set<MethodConstraintViolation<T>> validateReturnValue(T object,
                                                                 Method method,
                                                                 Object returnValue,
                                                                 Class<?>... groups)
Description copied from interface: MethodValidator
Validates the return value of a given method.

Specified by:
validateReturnValue in interface MethodValidator
Type Parameters:
T - The type hosting the invoked method.
Parameters:
object - The object on which the given method was invoked.
method - The invoked method for which the given return value shall be validated.
returnValue - The value returned by the invoked method.
groups - A - potentially empty - number of validation groups for which the validation shall be performed. The @link Default group will be validated if no group is given.
Returns:
A set with the constraint violations caused by this validation. Will be empty, of no error occurs, but never null.

getConstraintsForClass

public final BeanDescriptor getConstraintsForClass(Class<?> clazz)
Specified by:
getConstraintsForClass in interface Validator

getConstraintsForType

public final TypeDescriptor getConstraintsForType(Class<?> clazz)
Description copied from interface: MethodValidator
Returns a descriptor providing access to constraint-related meta data for the given type.

Specified by:
getConstraintsForType in interface MethodValidator
Parameters:
clazz - The type of interest.
Returns:
A descriptor for the given type, will never be null.

unwrap

public final <T> T unwrap(Class<T> type)
Specified by:
unwrap in interface Validator


Copyright © 2007-2011 Red Hat Middleware, LLC. All Rights Reserved