int numberOfViolationsBefore = validationContext.getFailingConstraints().size();
Method method = validationContext.getMethod();
BeanMetaData<T> beanMetaData = getBeanMetaData( validationContext.getRootBeanClass() );
AggregatedMethodMetaData methodMetaData = beanMetaData.getMetaDataFor( method );
// 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( object );
}
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 ( 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 = methodMetaData.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 );
numberOfViolationsOfCurrentGroup += validateParameterForGroup(
validationContext, valueContext, methodMetaData.getParameterMetaData( i )
);
if ( validationContext.shouldFailFast() ) {
return validationContext.getFailingConstraints().size() - numberOfViolationsBefore;
}
}
//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];
ParameterMetaData parameterMetaData = methodMetaData.getParameterMetaData( i );
String parameterName = parameterMetaData.getParameterName();
if ( parameterMetaData.isCascading() && value != null ) {
ValueContext<Object, ?> cascadingvalueContext = ValueContext.getLocalExecutionContext(