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
ConstructorsConstructorDescriptionParametersMethodOverrideCheck(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 booleanneedToPerformAnyChecks(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, getEnclosingTypeElementQualifiedNameMethods 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:AbstractMethodOverrideCheckPerforms the check of a method.- Specified by:
checkMethodInternalin classAbstractMethodOverrideCheck- Parameters:
currentMethod- a method to checkmethodInheritanceTree- theMethodInheritanceTreeof the method to check- Returns:
- a set of issues if there are any, an empty set otherwise
-
needToPerformAnyChecks
Description copied from class:AbstractMethodOverrideCheckThere can be situations in which no checks should be performed. In such cases we will not perform any work at all.- Specified by:
needToPerformAnyChecksin classAbstractMethodOverrideCheck- Parameters:
currentMethod- the method under investigation- Returns:
trueif we should proceed with checks andfalseotherwise
-