Class GeneralValidatorImpl
java.lang.Object
org.jboss.resteasy.plugins.validation.GeneralValidatorImpl
- All Implemented Interfaces:
GeneralValidator
,GeneralValidatorCDI
- Version:
- $Revision: 1.1 $ Copyright May 23, 2013
- Author:
- Ron Sigal
-
Nested Class Summary
Modifier and TypeClassDescriptionprotected static class
protected static class
A filter implementation filtering methods matching given methods. -
Field Summary
-
Constructor Summary
ConstructorDescriptionGeneralValidatorImpl
(jakarta.validation.ValidatorFactory validatorFactory, boolean isExecutableValidationEnabled, Set<jakarta.validation.executable.ExecutableType> defaultValidatedExecutableTypes) -
Method Summary
Modifier and TypeMethodDescriptionvoid
checkForConstraintViolations
(HttpRequest request, Exception e) Throws a ResteasyViolationException if either a ConstraintViolationException or a ResteasyConstraintViolationException is embedded in the cause hierarchy of e.void
checkViolations
(HttpRequest request) Throws a ResteasyViolationException if any validation violations have been detected.void
checkViolationsfromCDI
(HttpRequest request) Throws a ResteasyViolationException if any validation violations have been detected.protected static String
protected static jakarta.validation.executable.ExecutableType[]
getExecutableTypesOnMethod
(Method method) protected List
<jakarta.validation.executable.ExecutableType[]> protected List
<jakarta.validation.executable.ExecutableType[]> getExecutableTypesOnMethodInInterfaces
(Class<?> clazz, Method method) protected Method
getSuperMethod
(Method method, Class<?> clazz) Returns a super method, if any, of a method in a class.protected jakarta.validation.Validator
getValidator
(HttpRequest request) protected SimpleViolationsContainer
getViolationsContainer
(HttpRequest request, Object target) protected static boolean
boolean
Indicates if validation is turned on for a method.boolean
isValidatable
(Class<?> clazz) Indicates if validation is turned on for a class.boolean
isValidatable
(Class<?> clazz, InjectorFactory injectorFactory) Indicates if validation is turned on for a class.boolean
isValidatableFromCDI
(Class<?> clazz) Indicates if validation is turned on for a class.protected boolean
Checks, whethersubTypeMethod
overridessuperTypeMethod
.protected boolean
parametersResolveToSameTypes
(Method subTypeMethod, Method superTypeMethod) Taken from Hibernate Validatorvoid
validate
(HttpRequest request, Object object, Class<?>... groups) Validates all constraints onobject
.void
validateAllParameters
(HttpRequest request, Object object, Method method, Object[] parameterValues, Class<?>... groups) Validates all constraints placed on the parameters of the given method.void
validateReturnValue
(HttpRequest request, Object object, Method method, Object returnValue, Class<?>... groups) Validates all return value constraints of the given method.
-
Field Details
-
SUPPRESS_VIOLATION_PATH
- See Also:
-
-
Constructor Details
-
GeneralValidatorImpl
public GeneralValidatorImpl(jakarta.validation.ValidatorFactory validatorFactory, boolean isExecutableValidationEnabled, Set<jakarta.validation.executable.ExecutableType> defaultValidatedExecutableTypes)
-
-
Method Details
-
validate
Description copied from interface:GeneralValidator
Validates all constraints onobject
.- Specified by:
validate
in interfaceGeneralValidator
- Parameters:
request
- http requestobject
- object to validategroups
- the group or list of groups targeted for validation (defaults toDefault
)
-
checkViolations
Description copied from interface:GeneralValidator
Throws a ResteasyViolationException if any validation violations have been detected.- Specified by:
checkViolations
in interfaceGeneralValidator
- Parameters:
request
- http request
-
checkViolationsfromCDI
Description copied from interface:GeneralValidatorCDI
Throws a ResteasyViolationException if any validation violations have been detected. The method should be called only from the resteasy-cdi module.- Specified by:
checkViolationsfromCDI
in interfaceGeneralValidatorCDI
- Parameters:
request
- http request
-
validateAllParameters
public void validateAllParameters(HttpRequest request, Object object, Method method, Object[] parameterValues, Class<?>... groups) Description copied from interface:GeneralValidator
Validates all constraints placed on the parameters of the given method.- Specified by:
validateAllParameters
in interfaceGeneralValidator
- Parameters:
request
- http requestobject
- 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 toDefault
)
-
validateReturnValue
public void validateReturnValue(HttpRequest request, Object object, Method method, Object returnValue, Class<?>... groups) Description copied from interface:GeneralValidator
Validates all return value constraints of the given method.- Specified by:
validateReturnValue
in interfaceGeneralValidator
- Parameters:
request
- http requestobject
- 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 toDefault
)
-
isValidatable
Description copied from interface:GeneralValidator
Indicates if validation is turned on for a class.- Specified by:
isValidatable
in interfaceGeneralValidator
- Parameters:
clazz
- Class to be examined- Returns:
- true if and only if validation is turned on for clazz
-
isValidatable
Description copied from interface:GeneralValidatorCDI
Indicates if validation is turned on for a class. This method should be called from the resteasy-jaxrs module. It should test if injectorFactor is an instance of CdiInjectorFactory, which indicates that CDI is active. If so, it should return false. Otherwise, it should return the same value returned by GeneralValidator.isValidatable().- Specified by:
isValidatable
in interfaceGeneralValidatorCDI
- Parameters:
clazz
- Class to be examinedinjectorFactory
- the InjectorFactory used for clazz- Returns:
- true if and only if validation is turned on for clazz
-
isValidatableFromCDI
Description copied from interface:GeneralValidatorCDI
Indicates if validation is turned on for a class. This method should be called only from the resteasy-cdi module.- Specified by:
isValidatableFromCDI
in interfaceGeneralValidatorCDI
- Parameters:
clazz
- Class to be examined- Returns:
- true if and only if validation is turned on for clazz
-
isMethodValidatable
Description copied from interface:GeneralValidator
Indicates if validation is turned on for a method.- Specified by:
isMethodValidatable
in interfaceGeneralValidator
- Parameters:
m
- method to be examined- Returns:
- true if and only if validation is turned on for method
-
getExecutableTypesOnMethodInHierarchy
-
getExecutableTypesOnMethodInInterfaces
-
getExecutableTypesOnMethod
protected static jakarta.validation.executable.ExecutableType[] getExecutableTypesOnMethod(Method method) -
isGetter
-
convertArrayToString
-
getSuperMethod
-
overrides
Checks, whethersubTypeMethod
overridessuperTypeMethod
. N.B. "Override" here is reflexive. I.e., a method overrides itself.- Parameters:
subTypeMethod
- The sub type method (cannot benull
).superTypeMethod
- The super type method (cannot benull
).- Returns:
- Returns
true
ifsubTypeMethod
overridessuperTypeMethod
,false
otherwise. Taken from Hibernate Validator
-
parametersResolveToSameTypes
-
checkForConstraintViolations
Description copied from interface:GeneralValidatorCDI
Throws a ResteasyViolationException if either a ConstraintViolationException or a ResteasyConstraintViolationException is embedded in the cause hierarchy of e.- Specified by:
checkForConstraintViolations
in interfaceGeneralValidatorCDI
- Parameters:
request
- http requeste
- exception
-
getValidator
-
getViolationsContainer
-