BeanMetaData<?> beanMetaData = getBeanMetaData( method.getDeclaringClass() );
Map<Class<?>, MethodMetaData> methodMetaDataByType = beanMetaData.getMetaDataForMethod( method );
//used for retrieval of parameter names; we'll take the names from the lowest method in the hierarchy
MethodMetaData methodMetaDataOfDeclaringType = methodMetaDataByType.get( method.getDeclaringClass() );
// TODO GM: define behavior with respect to redefined default sequences. Should only the
// sequence from the validated bean be honored or also default sequence definitions up in
// the inheritance tree?
// For now a redefined default sequence will only be considered if specified at the bean
// hosting the validated itself, but no other default sequence from parent types
List<Class<?>> groupList;
if ( group.isDefaultGroup() ) {
groupList = beanMetaData.getDefaultGroupSequence();
}
else {
groupList = Arrays.<Class<?>>asList( group.getGroup() );
}
//the only case where we can have multiple groups here is a redefined default group sequence
for ( Class<?> oneGroup : groupList ) {
int numberOfViolationsOfCurrentGroup = 0;
for ( Entry<Class<?>, MethodMetaData> constraintsOfOneClass : methodMetaDataByType.entrySet() ) {
for ( int i = 0; i < parameterValues.length; i++ ) {
//ignore this parameter if this validation is for a single parameter and this is not the right one
if ( validationContext.getParameterIndex() != null && !validationContext.getParameterIndex()
.equals( i ) ) {
continue;
}
Object value = parameterValues[i];
String parameterName = methodMetaDataOfDeclaringType.getParameterMetaData( i ).getParameterName();
// validate constraints at parameter itself
ValueContext<T, Object> valueContext = ValueContext.getLocalExecutionContext(
object, PathImpl.createPathForMethodParameter( method, parameterName ), i, parameterName
);
valueContext.setCurrentValidatedValue( value );
valueContext.setCurrentGroup( oneGroup );
ParameterMetaData parameterMetaData = constraintsOfOneClass.getValue()
.getParameterMetaData( valueContext.getParameterIndex() );
numberOfViolationsOfCurrentGroup += validateParameterForGroup(
validationContext, valueContext, parameterMetaData
);
}
}
//stop processing after first group with errors occurred
if ( numberOfViolationsOfCurrentGroup > 0 ) {
break;
}
}
// validate parameter beans annotated with @Valid if required
for ( int i = 0; i < parameterValues.length; i++ ) {
//ignore this parameter if this validation is for a single parameter and this is not the right one
if ( validationContext.getParameterIndex() != null && !validationContext.getParameterIndex().equals( i ) ) {
continue;
}
Object value = parameterValues[i];
String parameterName = methodMetaDataOfDeclaringType.getParameterMetaData( i ).getParameterName();
if ( isCascadeRequired( method, i ) && value != null ) {
ValueContext<Object, ?> cascadingvalueContext = ValueContext.getLocalExecutionContext(
value, PathImpl.createPathForMethodParameter( method, parameterName ), i, parameterName