Class ReturnValueMethodOverrideCheck
java.lang.Object
org.hibernate.validator.ap.internal.classchecks.AbstractClassCheck
org.hibernate.validator.ap.internal.classchecks.AbstractMethodOverrideCheck
org.hibernate.validator.ap.internal.classchecks.ReturnValueMethodOverrideCheck
- All Implemented Interfaces:
ClassCheck
Checks if the return value of overridden and overriding methods respects the inheritance rules.
Return value constraints of a method must not be weakened in subtypes. One must not mark a method return value for cascaded validation more than once in a line of a class hierarchy. In other words, overriding methods on subtypes (be it sub classes/interfaces or interface implementations) cannot mark the return value for cascaded validation if the return value has already been marked on the overridden method of the super type or interface.
- Author:
- Marko Bekhta, Guillaume Smet
-
Field Summary
Fields inherited from class org.hibernate.validator.ap.internal.classchecks.AbstractMethodOverrideCheck
constraintHelper
-
Constructor Summary
ConstructorsConstructorDescriptionReturnValueMethodOverrideCheck
(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
-
ReturnValueMethodOverrideCheck
public ReturnValueMethodOverrideCheck(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
-