/** * Returns the given target class' method if the given method (declared in the repository interface) was also declared * at the target class. Returns the given method if the given base class does not declare the method given. Takes * generics into account. * * @param method must not be {@literal null} * @param baseClass * @return */ Method getTargetClassMethod(Method method, Class<?> baseClass) { if (baseClass == null) { return method; } for (Method baseClassMethod : baseClass.getMethods()) { // Wrong name if (!method.getName().equals(baseClassMethod.getName())) { continue; } // Wrong number of arguments if (!(method.getParameterTypes().length == baseClassMethod.getParameterTypes().length)) { continue; } // Check whether all parameters match if (!parametersMatch(method, baseClassMethod)) { continue; } return baseClassMethod; } return method; }