if (parentDesc != null) {
final Iterator<ParameterDescriptor> parentPd = parentDesc.getParameterDescriptors().iterator();
for (final ParameterDescriptor pd : methodDesc.getParameterDescriptors()) {
final ParameterDescriptor next = parentPd.next();
if (pd.getConstraintDescriptors().size() != next.getConstraintDescriptors().size()) {
throw new ConstraintDeclarationException("child shouldn't get more constraint than parent");
}
if (pd.isCascaded() != next.isCascaded()) { // @Valid
throw new ConstraintDeclarationException("child shouldn't get more constraint than parent");
}
}
} else {
ensureMethodDoesntDefineParameterConstraint(methodDesc);
}
}
final Class<?>[] interfaces = method.getDeclaringClass().getInterfaces();
final Collection<Method> itfWithThisMethod = new ArrayList<Method>();
for (final Class<?> i : interfaces) {
final Method m = Reflection.INSTANCE.getDeclaredMethod(i, method.getName(), method.getParameterTypes());
if (m != null) {
itfWithThisMethod.add(m);
}
}
if (itfWithThisMethod.size() > 1) {
for (final Method m : itfWithThisMethod) {
ensureNoConvertGroup(m, "ConvertGroup can't be used in parallel interfaces");
}
} else if (itfWithThisMethod.size() == 1) {
ensureNoConvertGroup(itfWithThisMethod.iterator().next(), "ConvertGroup can't be used in interface AND parent class");
}
int returnValid = 0;
if (method.getAnnotation(Valid.class) != null) {
returnValid++;
}
for (final Class<?> clazz : classHierarchy) {
final Method overriden = Reflection.INSTANCE.getDeclaredMethod(clazz, method.getName(), method.getParameterTypes());
if (overriden != null) {
if (overriden.getAnnotation(Valid.class) != null) {
returnValid++;
}
}
}
if (returnValid > 1 && !(interfaces.length == returnValid && method.getAnnotation(Valid.class) == null)) {
throw new ConstraintDeclarationException("@Valid on returned value can't be set more than once");
}
}
if (getter) {
final MetaProperty prop = metaBean.getProperty(Introspector.decapitalize(method.getName().substring(3)));
if (prop != null && prop.getFeature(Features.Property.REF_CASCADE) != null) {
methodDesc.setCascaded(true);
}
}
if (!methodDesc.getGroupConversions().isEmpty() && !methodDesc.isCascaded()) {
throw new ConstraintDeclarationException("@Valid is needed to define a group conversion");
}
}
for (final Class<?> parent : classHierarchy) {
final BeanDescriptorImpl desc = BeanDescriptorImpl.class.cast(factoryContext.getValidator().getConstraintsForClass(parent));