public static Method getLambdaMethod(Serializable lambda) { return getLambdaMethod(lambda, "execute"); }
public NParamLambdaHandler(FastHttp http, HttpRoutes routes, RouteOptions options, NParamLambda lambda) { super(http, routes, options, Cls.getLambdaMethod(lambda), lambda); }
public static String[] getLambdaParameterNames(Serializable lambda) { Method lambdaMethod = getLambdaMethod(lambda); Class<?>[] lambdaTypes = lambdaMethod.getParameterTypes(); String[] names = getMethodParameterNames(lambdaMethod); List<Method> methods = U.list(); for (Class<?> interf : lambda.getClass().getInterfaces()) { for (Method m : interf.getMethods()) { Class<?>[] types = m.getParameterTypes(); if (types.length <= names.length) { int diff = names.length - types.length; boolean matching = true; for (int i = 0; i < types.length; i++) { if (!types[i].isAssignableFrom(lambdaTypes[i + diff])) { matching = false; } } if (matching) { methods.add(m); } } } } U.must(methods.size() > 0, "Cannot find the lambda target method of the functional interface!"); U.must(methods.size() == 1, "Found more than one lambda target method of the functional interface: " + methods); return Arr.sub(names, names.length - methods.get(0).getParameterTypes().length, names.length); }
Method method = Cls.getLambdaMethod(lambda); Class<?> paramType = method.getParameterTypes()[0]; Method method = Cls.getLambdaMethod(lambda); Class<?> param1Type = method.getParameterTypes()[0]; Class<?> param2Type = method.getParameterTypes()[1];
public NParamLambdaHandler(FastHttp http, HttpRoutes routes, RouteOptions options, NParamLambda lambda) { super(http, routes, options, Cls.getLambdaMethod(lambda), lambda); }
Method method = Cls.getLambdaMethod(lambda); Class<?> paramType = method.getParameterTypes()[0]; Method method = Cls.getLambdaMethod(lambda); Class<?> param1Type = method.getParameterTypes()[0]; Class<?> param2Type = method.getParameterTypes()[1];