org.hibernate.validator.engine
Class ValidatorImpl

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

public class ValidatorImpl
extends java.lang.Object
implements javax.validation.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(javax.validation.ConstraintValidatorFactory constraintValidatorFactory, javax.validation.MessageInterpolator messageInterpolator, javax.validation.TraversableResolver traversableResolver, ConstraintHelper constraintHelper, BeanMetaDataCache beanMetaDataCache, boolean failFast)
           
 
Method Summary
 javax.validation.metadata.BeanDescriptor getConstraintsForClass(java.lang.Class<?> clazz)
           
 TypeDescriptor getConstraintsForType(java.lang.Class<?> clazz)
          Returns a descriptor providing access to constraint-related meta data for the given type.
<T> T
unwrap(java.lang.Class<T> type)
           
<T> java.util.Set<javax.validation.ConstraintViolation<T>>
validate(T object, java.lang.Class<?>... groups)
           
<T> java.util.Set<MethodConstraintViolation<T>>
validateAllParameters(T object, java.lang.reflect.Method method, java.lang.Object[] parameterValues, java.lang.Class<?>... groups)
          Validates all parameters of a given method.
<T> java.util.Set<MethodConstraintViolation<T>>
validateParameter(T object, java.lang.reflect.Method method, java.lang.Object parameterValue, int parameterIndex, java.lang.Class<?>... groups)
          Validates a given parameter of a given method.
<T> java.util.Set<javax.validation.ConstraintViolation<T>>
validateProperty(T object, java.lang.String propertyName, java.lang.Class<?>... groups)
           
<T> java.util.Set<MethodConstraintViolation<T>>
validateReturnValue(T object, java.lang.reflect.Method method, java.lang.Object returnValue, java.lang.Class<?>... groups)
          Validates the return value of a given method.
<T> java.util.Set<javax.validation.ConstraintViolation<T>>
validateValue(java.lang.Class<T> beanType, java.lang.String propertyName, java.lang.Object value, java.lang.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(javax.validation.ConstraintValidatorFactory constraintValidatorFactory,
                     javax.validation.MessageInterpolator messageInterpolator,
                     javax.validation.TraversableResolver traversableResolver,
                     ConstraintHelper constraintHelper,
                     BeanMetaDataCache beanMetaDataCache,
                     boolean failFast)
Method Detail

validate

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

validateProperty

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

validateValue

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

validateParameter

public final <T> java.util.Set<MethodConstraintViolation<T>> validateParameter(T object,
                                                                               java.lang.reflect.Method method,
                                                                               java.lang.Object parameterValue,
                                                                               int parameterIndex,
                                                                               java.lang.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> java.util.Set<MethodConstraintViolation<T>> validateAllParameters(T object,
                                                                                   java.lang.reflect.Method method,
                                                                                   java.lang.Object[] parameterValues,
                                                                                   java.lang.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> java.util.Set<MethodConstraintViolation<T>> validateReturnValue(T object,
                                                                           java.lang.reflect.Method method,
                                                                           java.lang.Object returnValue,
                                                                           java.lang.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 javax.validation.metadata.BeanDescriptor getConstraintsForClass(java.lang.Class<?> clazz)
Specified by:
getConstraintsForClass in interface javax.validation.Validator

getConstraintsForType

public final TypeDescriptor getConstraintsForType(java.lang.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(java.lang.Class<T> type)
Specified by:
unwrap in interface javax.validation.Validator


Copyright © 2011 Oracle Corporation. All Rights Reserved.