protected final void genMethod(ClassModel model, MethodInfo method, List<String> cacheDecls, PrintWriter writer) { genSimpleMethod(model, method, cacheDecls, writer); if (method.getKind() == MethodKind.FUTURE) { genRxMethod(model, method, writer); } }
protected final void genMethod(ClassModel model, MethodInfo method, List<String> cacheDecls, PrintWriter writer) { genSimpleMethod(model, method, cacheDecls, writer); if (method.getKind() == MethodKind.FUTURE) { genRxMethod(model, method, writer); } }
private void generateImport(ClassModel model, CodeWriter writer, Map<Boolean, List<MethodInfo>> methodGroupMap, boolean hasStatic) { Set<String> imports = new TreeSet<>(); ClassTypeInfo type = model.getType(); String simpleName = type.getSimpleName(); imports.add(type.getPackageName() + "." + simpleName + (!hasStatic ? "" : (" as " + vertxSimpleNameWrapper(type.getSimpleName(), true)))); methodGroupMap.values().stream().flatMap(List::stream).forEach(m -> { List<ParamInfo> params = m.getParams(); if (params.size() > 0) { params.stream().limit(params.size() - 1).forEach(p -> addImport(type, imports, p.getType())); ParameterizedTypeInfo param = (ParameterizedTypeInfo) params.get(params.size() - 1).getType(); TypeInfo arg = param.getArg(0); if (arg.getKind() == ClassKind.ASYNC_RESULT) { addImport(type, imports, ((ParameterizedTypeInfo) arg).getArg(0)); } else { addImport(type, imports, arg); } } if (m.getKind() == MethodKind.HANDLER) { imports.add("io.vertx.kotlin.coroutines.awaitEvent"); } else if (m.getKind() == MethodKind.FUTURE) { imports.add("io.vertx.kotlin.coroutines.awaitResult"); } }); for (String temp : imports) { writer.print("import "); writer.println(temp); } }
private boolean generateFilter(MethodInfo it) { MethodKind methodKind = it.getKind(); return !it.isDeprecated() && (it.isFluent() || it.getReturnType().isVoid()) && methodKind == MethodKind.FUTURE; }
@Test public void testValidCloseWithFuture() throws Exception { ProxyModel model = generateProxyModel(ValidProxyCloseWithFuture.class); assertEquals(1, model.getMethods().size()); assertEquals(MethodKind.FUTURE, model.getMethods().get(0).getKind()); ParameterizedTypeInfo handlerType = (ParameterizedTypeInfo) model.getMethods().get(0).getParams().get(0).getType(); ParameterizedTypeInfo asyncResultType = (ParameterizedTypeInfo) handlerType.getArgs().get(0); assertEquals(ClassKind.VOID, asyncResultType.getArgs().get(0).getKind()); }
void checkMethod(MethodInfo meth, String name, int numParams, String returnType, MethodKind kind, Doc comment, MethodCheck... checks) { EnumSet<MethodCheck> checkSet = EnumSet.noneOf(MethodCheck.class); Collections.addAll(checkSet, checks); assertEquals(name, meth.getName()); if (comment != null) { assertNotNull(meth.getComment()); assertEquals(comment.getFirstSentence(), meth.getDoc().getFirstSentence()); assertEquals(comment.getBody(), meth.getDoc().getBody()); assertEquals(comment.getBlockTags(), meth.getDoc().getBlockTags()); } else { assertNull(meth.getComment()); } assertEquals(kind, meth.getKind()); assertEquals(returnType, meth.getReturnType().toString()); assertEquals(checkSet.contains(MethodCheck.CACHE_RETURN), meth.isCacheReturn()); assertEquals(checkSet.contains(MethodCheck.FLUENT), meth.isFluent()); assertEquals(checkSet.contains(MethodCheck.STATIC), meth.isStaticMethod()); assertEquals(numParams, meth.getParams().size()); }