Class DefaultMethodOverrideCheck
overridesDefaultMethod(java.lang.Class<?>, java.lang.Class<?>, java.lang.String, java.lang.Class<?>...)), or a method a known
base class declares (declaresBelow(java.lang.Class<?>, java.lang.Class<?>, java.lang.String, java.lang.Class<?>...)). Shared by every org.dbunit.annotation/
org.dbunit.junit.jupiter call site that needs to fail fast (or otherwise react)
when a configured attribute cannot actually reach a non-overriding implementation, instead
of silently doing nothing.
Public so a binding outside org.dbunit.annotation.runtime - such as
DbUnitExtension - can reach it too.
- Since:
- 3.6.0
- Author:
- Jeff Jensen
-
Method Summary
Modifier and TypeMethodDescriptionstatic booleandeclaresBelow(Class<?> type, Class<?> ceiling, String methodName, Class<?>... parameterTypes) Returns whethertype, or any class between it andceiling(exclusive), declares the named method - the "does a concrete class redeclare this method below a known base class" question, as distinct fromoverridesDefaultMethod(java.lang.Class<?>, java.lang.Class<?>, java.lang.String, java.lang.Class<?>...)'s "does a type override an interface default".static booleanoverridesDefaultMethod(Class<?> implementationType, Class<?> declaringInterface, String methodName, Class<?>... parameterTypes) Returns whetherimplementationTypeoverrides the named default methoddeclaringInterfacedeclares, rather than inheriting that interface's own default body.
-
Method Details
-
overridesDefaultMethod
public static boolean overridesDefaultMethod(Class<?> implementationType, Class<?> declaringInterface, String methodName, Class<?>... parameterTypes) Returns whetherimplementationTypeoverrides the named default methoddeclaringInterfacedeclares, rather than inheriting that interface's own default body.Known limitation: this check only asks which class declares the method, so it cannot distinguish a real override from a dynamic proxy or a mocking-framework-generated subclass - an unstubbed Mockito mock, for instance - that mechanically redeclares every interface method, default ones included, no matter what its generated body actually does. Such an instance reports
truehere for every method, silently defeating a fail-fast check built on it. Narrow-audience: only reachable when a test injects such an instance directly, rather than a real implementation.- Parameters:
implementationType- The runtime type to check.declaringInterface- The interface whose default methodmethodNamenames.methodName- The method's name.parameterTypes- The method's parameter types.- Returns:
- True when
implementationTypeoverrides the method.
-
declaresBelow
public static boolean declaresBelow(Class<?> type, Class<?> ceiling, String methodName, Class<?>... parameterTypes) Returns whethertype, or any class between it andceiling(exclusive), declares the named method - the "does a concrete class redeclare this method below a known base class" question, as distinct fromoverridesDefaultMethod(java.lang.Class<?>, java.lang.Class<?>, java.lang.String, java.lang.Class<?>...)'s "does a type override an interface default". Walkstype's superclass chain, stopping beforeceilingand beforeObject.Unlike
overridesDefaultMethod(java.lang.Class<?>, java.lang.Class<?>, java.lang.String, java.lang.Class<?>...), aNoSuchMethodExceptionfor one class in the range is not an error: that class simply does not declare the method, and the walk continues to its superclass.- Parameters:
type- The concrete type to start the walk from.ceiling- The base class to stop before; a declaration onceilingitself does not count.methodName- The method's name.parameterTypes- The method's parameter types.- Returns:
- True when some class in
[type, ceiling)declares the method.
-