for ( ConstrainedExecutable constrainedExecutable : executablesWithParameterConstraints ) {
definingTypes.add( constrainedExecutable.getLocation().getBeanClass() );
}
if ( definingTypes.size() > 1 ) {
return new ConstraintDeclarationException(
"Only the root method of an overridden method in an inheritance hierarchy may be annotated with parameter constraints, " +
"but there are parameter constraints defined at all of the following overridden methods: " +
executablesWithParameterConstraints
);
}
ConstrainedExecutable constrainedExecutable = executablesWithParameterConstraints.iterator()
.next();
for ( ConstrainedExecutable oneExecutable : constrainedExecutables ) {
if ( !constrainedExecutable.getLocation().getBeanClass()
.isAssignableFrom( oneExecutable.getLocation().getBeanClass() ) ) {
return new ConstraintDeclarationException(
"Only the root method of an overridden method in an inheritance hierarchy may be annotated with parameter constraints. " +
"The following method itself has no parameter constraints but it is not defined on a sub-type of " +
constrainedExecutable.getLocation()
.getBeanClass() + ": " + oneExecutable
);