@Test public void testFindRefMethods() throws NoSuchMethodException, SecurityException{ Method[] findInterfaceMethods = httpMatch.findInterfaceMethods("login"); Assert.assertEquals(findInterfaceMethods.length, 2); Method[] findRefMethods = httpMatch.findRefMethods(findInterfaceMethods, null, "POST"); Assert.assertEquals(findRefMethods.length, 1); Assert.assertEquals(findRefMethods[0], InterfaceServiceImplTest.class.getDeclaredMethod("login", String.class)); findRefMethods = httpMatch.findRefMethods(findInterfaceMethods, "bypwd", "POST"); Assert.assertEquals(findRefMethods.length, 1); Assert.assertEquals(findRefMethods[0], InterfaceServiceImplTest.class.getDeclaredMethod("login", String.class, String.class)); findRefMethods = httpMatch.findRefMethods(findInterfaceMethods, "other", "POST"); Assert.assertEquals(findRefMethods.length, 0); findRefMethods = httpMatch.findRefMethods(findInterfaceMethods, null, "GET"); Assert.assertEquals(findRefMethods.length, 0); findInterfaceMethods = httpMatch.findInterfaceMethods("get"); Assert.assertEquals(findInterfaceMethods.length, 2); findRefMethods = httpMatch.findRefMethods(findInterfaceMethods, null, "POST"); Assert.assertEquals(findRefMethods.length, 2); }
public Method[] findRefMethods(Method[] interfaceMethods, String operationId, String requestMethod) { List<Method> ret = new ArrayList<Method>(); for (Method method : interfaceMethods) { Method m; try { m = refClass.getMethod(method.getName(), method.getParameterTypes()); final ApiOperation apiOperation = ReflectionUtils.getAnnotation(m, ApiOperation.class); String nickname = null == apiOperation ? null : apiOperation.nickname(); if (operationId != null) { if (!operationId.equals(nickname)) continue; } else { if (StringUtils.isNotBlank(nickname)) continue; } if (requestMethod != null) { String httpMethod = null == apiOperation ? null : apiOperation.httpMethod(); if (StringUtils.isNotBlank(httpMethod) && !requestMethod.equals(httpMethod)) continue; if (StringUtils.isBlank(httpMethod) && !requestMethod.equalsIgnoreCase(HttpMethod.POST.name())) continue; } ret.add(m); } catch (NoSuchMethodException e) { logger.error("NoSuchMethodException", e); } catch (SecurityException e) { logger.error("SecurityException", e); } } return ret.toArray(new Method[] {}); }
HttpMatch { public Method[] findRefMethods(Method[] interfaceMethods, String operationId, String requestMethod) { List<Method> ret = new ArrayList<Method>(); for (Method method : interfaceMethods) { Method m; try { m = refClass.getMethod(method.getName(), method.getParameterTypes()); final ApiOperation apiOperation = ReflectionUtils.getAnnotation(m, ApiOperation.class); String nickname = null == apiOperation ? null : apiOperation.nickname(); if (operationId != null) { if (!operationId.equals(nickname)) continue; } else { if (StringUtils.isNotBlank(nickname)) continue; } if (requestMethod != null) { String httpMethod = null == apiOperation ? null : apiOperation.httpMethod(); if (StringUtils.isNotBlank(httpMethod) && !requestMethod.equals(httpMethod)) continue; if (StringUtils.isBlank(httpMethod) && !requestMethod.equalsIgnoreCase(HttpMethod.POST.name())) continue; } ret.add(m); } catch (NoSuchMethodException e) { logger.error("NoSuchMethodException", e); } catch (SecurityException e) { logger.error("SecurityException", e); } } return ret.toArray(new Method[] {}); } }
HttpMatch { public Method[] findRefMethods(Method[] interfaceMethods, String operationId, String requestMethod) { List<Method> ret = new ArrayList<Method>(); for (Method method : interfaceMethods) { Method m; try { m = refClass.getMethod(method.getName(), method.getParameterTypes()); final ApiOperation apiOperation = ReflectionUtils.getAnnotation(m, ApiOperation.class); String nickname = null == apiOperation ? null : apiOperation.nickname(); if (operationId != null) { if (!operationId.equals(nickname)) continue; } else { if (StringUtils.isNotBlank(nickname)) continue; } if (requestMethod != null) { String httpMethod = null == apiOperation ? null : apiOperation.httpMethod(); if (StringUtils.isNotBlank(httpMethod) && !requestMethod.equals(httpMethod)) continue; if (StringUtils.isBlank(httpMethod) && !requestMethod.equalsIgnoreCase(HttpMethod.POST.name())) continue; } ret.add(m); } catch (NoSuchMethodException e) { logger.error("NoSuchMethodException", e); } catch (SecurityException e) { logger.error("SecurityException", e); } } return ret.toArray(new Method[] {}); } HttpMatch(Class<?> interfaceClass, Class<?> refClass); }
HttpMatch { public Method[] findRefMethods(Method[] interfaceMethods, String operationId, String requestMethod) { List<Method> ret = new ArrayList<Method>(); for (Method method : interfaceMethods) { Method m; try { m = refClass.getMethod(method.getName(), method.getParameterTypes()); final ApiOperation apiOperation = ReflectionUtils.getAnnotation(m, ApiOperation.class); String nickname = null == apiOperation ? null : apiOperation.nickname(); if (operationId != null) { if (!operationId.equals(nickname)) continue; } else { if (StringUtils.isNotBlank(nickname)) continue; } if (requestMethod != null) { String httpMethod = null == apiOperation ? null : apiOperation.httpMethod(); if (StringUtils.isNotBlank(httpMethod) && !requestMethod.equals(httpMethod)) continue; if (StringUtils.isBlank(httpMethod) && !requestMethod.equalsIgnoreCase(HttpMethod.POST.name())) continue; } ret.add(m); } catch (NoSuchMethodException e) { logger.error("NoSuchMethodException", e); } catch (SecurityException e) { logger.error("SecurityException", e); } } return ret.toArray(new Method[] {}); } HttpMatch(Class<?> interfaceClass, Class<?> refClass); Method[] findInterfaceMethods(String methodName); Method[] findRefMethods(Method[] interfaceMethods, String operationId,
			String requestMethod); Method matchRefMethod(Method[] refMethods, String methodName, Set<String> keySet); }
HttpMatch { public Method[] findRefMethods(Method[] interfaceMethods, String operationId, String requestMethod) { List<Method> ret = new ArrayList<Method>(); for (Method method : interfaceMethods) { Method m; try { m = refClass.getMethod(method.getName(), method.getParameterTypes()); final ApiOperation apiOperation = ReflectionUtils.getAnnotation(m, ApiOperation.class); String nickname = null == apiOperation ? null : apiOperation.nickname(); if (operationId != null) { if (!operationId.equals(nickname)) continue; } else { if (StringUtils.isNotBlank(nickname)) continue; } if (requestMethod != null) { String httpMethod = null == apiOperation ? null : apiOperation.httpMethod(); if (StringUtils.isNotBlank(httpMethod) && !requestMethod.equals(httpMethod)) continue; if (StringUtils.isBlank(httpMethod) && !requestMethod.equalsIgnoreCase(HttpMethod.POST.name())) continue; } ret.add(m); } catch (NoSuchMethodException e) { logger.error("NoSuchMethodException", e); } catch (SecurityException e) { logger.error("SecurityException", e); } } return ret.toArray(new Method[] {}); } HttpMatch(Class<?> interfaceClass, Class<?> refClass); Method[] findInterfaceMethods(String methodName); Method[] findRefMethods(Method[] interfaceMethods, String operationId,
			String requestMethod); Method matchRefMethod(Method[] refMethods, String methodName, Set<String> keySet);  }