}
@SuppressWarnings("unchecked")
private <U extends DefaultGroupSequenceProvider<?>> DefaultGroupSequenceProvider<T> newGroupSequenceProviderInstance(Class<U> providerClass) {
if ( providerClass.isInterface() ) {
throw new GroupDefinitionException(
"The default group sequence provider defined for " + beanClass.getName() + " must be an implementation of the DefaultGroupSequenceProvider interface"
);
}
Method[] providerMethods = getMethods( providerClass );
for ( Method method : providerMethods ) {
Class<?>[] paramTypes = method.getParameterTypes();
if ( "getValidationGroups".equals( method.getName() ) && !method.isBridge()
&& paramTypes.length == 1 && paramTypes[0].isAssignableFrom( beanClass ) ) {
return (DefaultGroupSequenceProvider<T>) newInstance(
providerClass, "the default group sequence provider"
);
}
}
throw new GroupDefinitionException(
"The default group sequence provider defined for " + beanClass.getName() + " has the wrong type"
);
}