I have been struggling in a problem that when i have tried to use the Hibernate Validator Annotation Processor to enhance my project’s type safety, i’ve received the message that any constrains on the parameters of override method besides the origin should not be put on.
But In the configuration, Hibernate Validator allow us alter parameter constraints on the override method by set the HibernateValidatorConfiguration.allowOverridingMethodAlterParameterConstraint to be true.
And then i have checked the source code in https://github.com/hibernate/hibernate-validator/blob/master/annotation-processor/src/main/java/org/hibernate/validator/ap/internal/classchecks/ParametersMethodOverrideCheck.java, but what a pity the constrain can’t be altered or configured.
// you can't define a constraint on a parameter of an overriding/implementing method or mark it for cascaded validation
if ( hasAnnotationsOnParameters( currentMethod ) ) {
Set<ExecutableElement> overriddenMethods = methodInheritanceTree.getOverriddenMethods();
return CollectionHelper.asSet( ConstraintCheckIssue.error(
currentMethod,
null,
"INCORRECT_METHOD_PARAMETERS_OVERRIDING",
getEnclosingTypeElementQualifiedNames( overriddenMethods )
) );
}
I’m aspiring that anyone can handle it.