ensureNotNullDescriptors(method.getReturnType(), methodDesc);
if (parents != null) {
if (parents.size() > 1) {
for (final Method parent : parents) {
final MethodDescriptor parentDec = factoryContext.getValidator().getConstraintsForClass(parent.getDeclaringClass()).getConstraintsForMethod(parent.getName(), parent.getParameterTypes());
if (parentDec != null) {
ensureNoParameterConstraint(InvocableElementDescriptor.class.cast(parentDec), "Parameter constraints can't be defined for parallel interfaces/parents");
} else {
ensureMethodDoesntDefineParameterConstraint(methodDesc);
}
ensureNoReturnValueAddedInChild(methodDesc.getReturnValueDescriptor(), parentDec, "Return value constraints should be the same for parent and children");
}
} else if (!parents.isEmpty()) {
final Method parent = parents.iterator().next();
final MethodDescriptor parentDesc = factoryContext.getValidator().getConstraintsForClass(parent.getDeclaringClass()).getConstraintsForMethod(parent.getName(), parent.getParameterTypes());
ensureNoReturnValueAddedInChild(methodDesc.getReturnValueDescriptor(), parentDesc, "Return value constraints should be at least the same for parent and children");
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");
}