@Test public void backgroundFunctionTypeArgument_simple() { assertThat(backgroundFunctionTypeArgument(PubSubFunction.class)).hasValue(PubSubMessage.class); }
static Optional<Type> backgroundFunctionTypeArgument( Class<? extends BackgroundFunction<?>> functionClass) { return Arrays.stream(functionClass.getMethods()) .filter(m -> m.getName().equals("accept") && m.getParameterCount() == 2 && m.getParameterTypes()[1] == Context.class && m.getParameterTypes()[0] != Object.class) .map(m -> m.getGenericParameterTypes()[0]) .findFirst(); }
BackgroundFunctionExecutor extends HttpServlet { static Optional<Type> backgroundFunctionTypeArgument( Class<? extends BackgroundFunction<?>> functionClass) { return Arrays.stream(functionClass.getMethods()) .filter(m -> m.getName().equals("accept") && m.getParameterCount() == 2 && m.getParameterTypes()[1] == Context.class && m.getParameterTypes()[0] != Object.class) .map(m -> m.getGenericParameterTypes()[0]) .findFirst(); } }
BackgroundFunctionExecutor extends HttpServlet { static Optional<Type> backgroundFunctionTypeArgument( Class<? extends BackgroundFunction<?>> functionClass) { return Arrays.stream(functionClass.getMethods()) .filter(m -> m.getName().equals("accept") && m.getParameterCount() == 2 && m.getParameterTypes()[1] == Context.class && m.getParameterTypes()[0] != Object.class) .map(m -> m.getGenericParameterTypes()[0]) .findFirst(); } private  BackgroundFunctionExecutor(FunctionExecutor<?> functionExecutor); }
BackgroundFunctionExecutor extends HttpServlet { static Optional<Type> backgroundFunctionTypeArgument( Class<? extends BackgroundFunction<?>> functionClass) { return Arrays.stream(functionClass.getMethods()) .filter(m -> m.getName().equals("accept") && m.getParameterCount() == 2 && m.getParameterTypes()[1] == Context.class && m.getParameterTypes()[0] != Object.class) .map(m -> m.getGenericParameterTypes()[0]) .findFirst(); } private  BackgroundFunctionExecutor(FunctionExecutor<?> functionExecutor); static Optional<BackgroundFunctionExecutor> maybeForClass(Class<?> functionClass); static BackgroundFunctionExecutor forClass(Class<?> functionClass); @Override void service(HttpServletRequest req, HttpServletResponse res); }
BackgroundFunctionExecutor extends HttpServlet { static Optional<Type> backgroundFunctionTypeArgument( Class<? extends BackgroundFunction<?>> functionClass) { return Arrays.stream(functionClass.getMethods()) .filter(m -> m.getName().equals("accept") && m.getParameterCount() == 2 && m.getParameterTypes()[1] == Context.class && m.getParameterTypes()[0] != Object.class) .map(m -> m.getGenericParameterTypes()[0]) .findFirst(); } private  BackgroundFunctionExecutor(FunctionExecutor<?> functionExecutor); static Optional<BackgroundFunctionExecutor> maybeForClass(Class<?> functionClass); static BackgroundFunctionExecutor forClass(Class<?> functionClass); @Override void service(HttpServletRequest req, HttpServletResponse res);  }