Java Code Examples for io.vertx.codegen.type.ClassTypeInfo#getName()
The following examples show how to use
io.vertx.codegen.type.ClassTypeInfo#getName() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DataObjectHelperGen.java From vertx-codegen with Apache License 2.0 | 6 votes |
private Case getCase(DataObjectModel model) { AnnotationValueInfo abc = model .getAnnotations() .stream().filter(ann -> ann.getName().equals(DataObject.class.getName())) .findFirst().get(); ClassTypeInfo cti = (ClassTypeInfo) abc.getMember("jsonPropertyNameFormatter"); switch (cti.getName()) { case "io.vertx.codegen.format.CamelCase": return CamelCase.INSTANCE; case "io.vertx.codegen.format.SnakeCase": return SnakeCase.INSTANCE; case "io.vertx.codegen.format.LowerCamelCase": return LowerCamelCase.INSTANCE; default: throw new UnsupportedOperationException("Todo"); } }
Example 2
Source File: MapperGenBase.java From vertx-sql-client with Apache License 2.0 | 5 votes |
private Case getCase(DataObjectModel model, String name) { AnnotationValueInfo abc = getAnnotation(model).get(); ClassTypeInfo cti = (ClassTypeInfo) abc.getMember(name); switch (cti.getName()) { case "io.vertx.codegen.format.CamelCase": return CamelCase.INSTANCE; case "io.vertx.codegen.format.SnakeCase": return SnakeCase.INSTANCE; case "io.vertx.codegen.format.LowerCamelCase": return LowerCamelCase.INSTANCE; default: throw new UnsupportedOperationException(); } }
Example 3
Source File: RxJava2Generator.java From vertx-rx with Apache License 2.0 | 5 votes |
@Override protected void genRxMethod(ClassModel model, MethodInfo method, List<String> cacheDecls, boolean genBody, PrintWriter writer) { MethodInfo futMethod = genFutureMethod(method); ClassTypeInfo raw = futMethod.getReturnType().getRaw(); String methodSimpleName = raw.getSimpleName(); String adapterType = "AsyncResult" + methodSimpleName + ".to" + methodSimpleName; String rxType = raw.getName(); startMethodTemplate(model.getType(), futMethod, "", writer); if (genBody) { writer.println(" { "); writer.print(" return "); writer.print(adapterType); writer.println("($handler -> {"); writer.print(" "); writer.print(method.getName()); writer.print("("); List<ParamInfo> params = futMethod.getParams(); writer.print(params.stream().map(ParamInfo::getName).collect(Collectors.joining(", "))); if (params.size() > 0) { writer.print(", "); } writer.println("$handler);"); writer.println(" });"); writer.println(" }"); } else { writer.println(";"); } writer.println(); }
Example 4
Source File: GroovyCodeBuilder.java From vertx-codetrans with Apache License 2.0 | 5 votes |
@Override public String render(RunnableCompilationUnit unit, RenderMode renderMode) { GroovyWriter writer = newWriter(); if (renderMode != RenderMode.SNIPPET) { if (unit.getFields().size() > 0) { writer.append("import groovy.transform.Field\n"); } for (ClassTypeInfo importedType : imports) { String fqn = importedType.getName(); writer.append("import ").append(fqn).append('\n'); } for (Map.Entry<String, StatementModel> field : unit.getFields().entrySet()) { writer.append("@Field "); field.getValue().render(writer); writer.append("\n"); } for (Map.Entry<String, MethodModel> method : unit.getMethods().entrySet()) { writer.append("def ").append(method.getKey()).append("("); for (Iterator<String> it = method.getValue().getParameterNames().iterator(); it.hasNext(); ) { String paramName = it.next(); writer.append(paramName); if (it.hasNext()) { writer.append(", "); } } writer.append(") {\n"); writer.indent(); method.getValue().render(writer); writer.unindent(); writer.append("}\n"); } } unit.getMain().render(writer); return writer.getBuffer().toString(); }
Example 5
Source File: KotlinCodeBuilder.java From vertx-codetrans with Apache License 2.0 | 5 votes |
private void addImport(ClassTypeInfo importedType) { String fqn = importedType.getName(); /* if (importedType instanceof ApiTypeInfo) { fqn = importedType.translateName("kotlin"); } */ imports.add(fqn); }
Example 6
Source File: RowMapperGen.java From vertx-sql-client with Apache License 2.0 | 4 votes |
private static String getter(TypeInfo type) { switch (type.getKind()) { case PRIMITIVE: PrimitiveTypeInfo pt = (PrimitiveTypeInfo) type; return getter(pt.getBoxed()); case BOXED_PRIMITIVE: return "get" + type.getSimpleName(); case STRING: return "getString"; case JSON_OBJECT: return "getJsonObject"; case JSON_ARRAY: return "getJsonArray"; } if (type instanceof ClassTypeInfo) { DataObjectInfo dataObject = type.getDataObject(); if (dataObject != null) { return getter(dataObject.getJsonType()); } ClassTypeInfo ct = (ClassTypeInfo) type; switch (ct.getName()) { case "java.time.LocalDateTime": return "getLocalDateTime"; case "java.time.LocalDate": return "getLocalDate"; case "java.time.LocalTime": return "getLocalTime"; case "java.time.OffsetTime": return "getOffsetTime"; case "java.time.OffsetDateTime": return "getOffsetDateTime"; case "java.time.temporal.Temporal": return "getTemporal"; case "java.util.UUID": return "getUUID"; case "io.vertx.core.buffer.Buffer": return "getBuffer"; } } return null; }