br.com.anteros.bean.validation.extensions.MethodValidator Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of Anteros-Bean-Validation Show documentation
Show all versions of Anteros-Bean-Validation Show documentation
Anteros Bean Validation for Java.
/*******************************************************************************
* Copyright 2012 Anteros Tecnologia
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*******************************************************************************/
package br.com.anteros.bean.validation.extensions;
import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
import java.util.Set;
import br.com.anteros.validation.api.ConstraintViolation;
import br.com.anteros.validation.api.Validator;
/**
* Description: Appendix C. Proposal for method-level validation.
* This interface contains the APIs added to javax.validation.Validator.
* It can be removed as soon as the Validator interface contains these methods.
* The extension is not a part of the JSR303 core specification yet, but could
* be in a future revision.
* You can access the extension via the use of the Validator.unwrap() method.
*/
public interface MethodValidator extends Validator {
/**
* Validate each parameter value based on the constraints described on
* the parameters of method
.
*
* @param clazz class hosting the method
* @param method the method whose parameters are currectly validated
* @param parameterValues the parameter values passed to the method for invocation
* @param groups groups targeted for validation
* @return set of constraint violations
* @throws IllegalArgumentException if the method does not belong to T
* or if the Object[] does not match the method signature
*/
Set> validateParameters(Class clazz, Method method,
Object[] parameterValues,
Class>... groups);
/**
* Validate the parameter value based on the constraints described on
* the parameterIndex-th parameter of method
.
*
* @param clazz class hosting the method
* @param method the method whose parameters are currectly validated
* @param parameterValue the parameter value passed to the parameterIndex-t parameter of method
* @param parameterIndex parameter index of the parameter validated in method
* @param groups groups targeted for validation
* @return set of constraint violations
* @throws IllegalArgumentException if the method does not belong to T
* or if parameterIndex is out of bound
*/
Set> validateParameter(Class clazz, Method method,
Object parameterValue,
int parameterIndex,
Class>... groups);
/**
* Validate each parameter value based on the constraints described on
* method
.
*
* @param clazz class hosting the method
* @param method the method whose result is validated
* @param returnedValue the value returned by the method invocation
* @param groups groups targeted for validation
* @return set of constraint violations
* @throws IllegalArgumentException if the method does not belong to T
*/
Set> validateReturnedValue(Class clazz, Method method,
Object returnedValue,
Class>... groups);
/**
* Validate each parameter value based on the constraints described on
* the parameters of constructor
.
*
* @param clazz class hosting the constructor
* @param constructor the constructor whose parameters are correctly validated
* @param parameterValues the parameter values passed to the constructor for invocation
* @param groups groups targeted for validation
* @return set of constraint violations
* @throws IllegalArgumentException if the constructor does not belong to T
* or if the Object[] does not match the constructor signature
*/
Set> validateParameters(Class clazz,
Constructor constructor,
Object[] parameterValues,
Class>... groups);
/**
* Validate the parameter value based on the constraints described on
* the parameterIndex-th parameter of constructor
.
*
* @param clazz class hosting the constructor
* @param constructor the method whose parameters are correctly validated
* @param parameterValue the parameter value passed to the
* parameterIndex-th parameter of constructor
* @param parameterIndex parameter index of the parameter validated in constructor
* @param groups groups targeted for validation
* @return set of constraint violations
* @throws IllegalArgumentException if the constructor does not belong to T
* or if prameterIndex is out of bound
*/
Set> validateParameter(Class clazz,
Constructor constructor,
Object parameterValue,
int parameterIndex,
Class>... groups);
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy