Class ParametersMethodOverrideCheck
java.lang.Object
org.hibernate.validator.ap.internal.classchecks.AbstractClassCheck
org.hibernate.validator.ap.internal.classchecks.AbstractMethodOverrideCheck
org.hibernate.validator.ap.internal.classchecks.ParametersMethodOverrideCheck
- All Implemented Interfaces:
ClassCheck
Checks if the parameters of overridden and overriding methods have correctly placed annotations.
Parameter constraints must not be strengthened in subtypes. The two rules implemented in this check are:
- In subtypes (be it sub classes/interfaces or interface implementations), no parameter constraints may be declared on overridden or implemented methods, nor may parameters be marked for cascaded validation. This would pose a strengthening of preconditions to be fulfilled by the caller.
- If a subtype overrides/implements a method originally defined in several parallel types of the hierarchy (e.g. two interfaces not extending each other, or a class and an interface not implemented by said class), no parameter constraints may be declared for that method at all nor parameters be marked for cascaded validation. This again is to avoid an unexpected strengthening of preconditions to be fulfilled by the caller.
- Author:
- Marko Bekhta
-
Field Summary
Fields inherited from class org.hibernate.validator.ap.internal.classchecks.AbstractMethodOverrideCheck
constraintHelper
-
Constructor Summary
ConstructorDescriptionParametersMethodOverrideCheck
(Elements elementUtils, Types typeUtils, ConstraintHelper constraintHelper) -
Method Summary
Modifier and TypeMethodDescriptionprotected Set<ConstraintCheckIssue>
checkMethodInternal
(ExecutableElement currentMethod, MethodInheritanceTree methodInheritanceTree) Performs the check of a method.protected boolean
needToPerformAnyChecks
(ExecutableElement currentMethod) There can be situations in which no checks should be performed.Methods inherited from class org.hibernate.validator.ap.internal.classchecks.AbstractMethodOverrideCheck
checkMethod, getEnclosingTypeElementQualifiedName
Methods inherited from class org.hibernate.validator.ap.internal.classchecks.AbstractClassCheck
execute
-
Constructor Details
-
ParametersMethodOverrideCheck
public ParametersMethodOverrideCheck(Elements elementUtils, Types typeUtils, ConstraintHelper constraintHelper)
-
-
Method Details
-
checkMethodInternal
protected Set<ConstraintCheckIssue> checkMethodInternal(ExecutableElement currentMethod, MethodInheritanceTree methodInheritanceTree) Description copied from class:AbstractMethodOverrideCheck
Performs the check of a method.- Specified by:
checkMethodInternal
in classAbstractMethodOverrideCheck
- Parameters:
currentMethod
- a method to checkmethodInheritanceTree
- theMethodInheritanceTree
of the method to check- Returns:
- a set of issues if there are any, an empty set otherwise
-
needToPerformAnyChecks
Description copied from class:AbstractMethodOverrideCheck
There can be situations in which no checks should be performed. In such cases we will not perform any work at all.- Specified by:
needToPerformAnyChecks
in classAbstractMethodOverrideCheck
- Parameters:
currentMethod
- the method under investigation- Returns:
true
if we should proceed with checks andfalse
otherwise
-