private void serviceToString(Service service, StringBuilder sb) { appendLine(sb, "service %s {", service.getName()); for (ServiceMethod serviceMethod : service.getMethods()) { commentsToString(serviceMethod.getCommentLines(), sb, 2); appendLine(sb, " rpc %s (%s) returns (%s);\n", serviceMethod.getName(), serviceMethod.getArgTypeName(), serviceMethod.getReturnTypeName()); } if (!service.getMethods().isEmpty()) { sb.setLength(sb.length() - 1); } appendLine(sb, "}"); }
private void checkDuplicateServiceMethodNames(List<ServiceMethod> methods) { Map<String, ServiceMethod> methodsByName = new HashMap<>(); for (ServiceMethod method : methods) { String name = method.getName(); if (methodsByName.containsKey(name)) { throw new ParserException(method, "Duplicate service method name: '%s'", name); } methodsByName.put(name, method); } }
/** * Get a service method by it's name. */ public ServiceMethod getMethod(String name) { for (ServiceMethod serviceMethod : getMethods()) { if (serviceMethod.getName().equals(name)) { return serviceMethod; } } return null; }
/** * Get a service method by it's name. */ public ServiceMethod getMethod(String name) { for (ServiceMethod serviceMethod : getMethods()) { if (serviceMethod.getName().equals(name)) { return serviceMethod; } } return null; }
private void checkDuplicateServiceMethodNames(List<ServiceMethod> methods) { Map<String, ServiceMethod> methodsByName = new HashMap<>(); for (ServiceMethod method : methods) { String name = method.getName(); if (methodsByName.containsKey(name)) { throw new ParserException(method, "Duplicate service method name: '%s'", name); } methodsByName.put(name, method); } }
/** * Returns java method name for corresponding rpc method. */ public static String getMethodName(ServiceMethod serviceMethod) { String name = serviceMethod.getName(); String formattedName = Formatter.toCamelCase(name); if (isReservedKeyword(formattedName)) { return formattedName + '_'; } return formattedName; }
/** * Returns java method name for corresponding rpc method. */ public static String getMethodName(ServiceMethod serviceMethod) { String name = serviceMethod.getName(); String formattedName = Formatter.toCamelCase(name); if (isReservedKeyword(formattedName)) { return formattedName + '_'; } return formattedName; }
private void serviceToString(Service service, StringBuilder sb) { appendLine(sb, "service %s {", service.getName()); for (ServiceMethod serviceMethod : service.getMethods()) { if (!serviceMethod.getCommentLines().isEmpty()) { appendLine(sb, " //" + serviceMethod.getComments()); } appendLine(sb, " rpc %s (%s) returns (%s);\n", serviceMethod.getName(), serviceMethod.getArgTypeName(), serviceMethod.getReturnTypeName()); } if (!service.getMethods().isEmpty()) { sb.setLength(sb.length() - 1); } appendLine(sb, "}"); }
private void process(Module module, Service service) { ImmutableServiceDescriptor descriptor = ImmutableServiceDescriptor.builder() .type(NodeType.SERVICE) .name(service.getName()) .canonicalName(service.getCanonicalName()) .description(markdownProcessor.toHtml(service.getComments())) .options(service.getOptions().toMap()) .addAllMethods(service.getMethods().stream() .map(method -> ImmutableServiceMethod.builder() .name(method.getName()) .argTypeId(method.getArgType().getCanonicalName()) .argStream(method.isArgStream()) .returnTypeId(method.getReturnType().getCanonicalName()) .returnStream(method.isReturnStream()) .description(markdownProcessor.toHtml(method.getComments())) .options(method.getOptions().toMap()) .build()) .collect(Collectors.toList())) .build(); String output = "data/type/" + service.getCanonicalName() + ".json"; write(module, output, descriptor); }
private void process(Module module, Service service) { ImmutableServiceDescriptor descriptor = ImmutableServiceDescriptor.builder() .type(NodeType.SERVICE) .name(service.getName()) .canonicalName(service.getCanonicalName()) .description(markdownProcessor.toHtml(service.getComments())) .options(service.getOptions().toMap()) .addAllMethods(service.getMethods().stream() .map(method -> ImmutableServiceMethod.builder() .name(method.getName()) .argTypeId(method.getArgType().getCanonicalName()) .argStream(method.isArgStream()) .returnTypeId(method.getReturnType().getCanonicalName()) .returnStream(method.isReturnStream()) .description(markdownProcessor.toHtml(method.getComments())) .options(method.getOptions().toMap()) .build()) .collect(Collectors.toList())) .build(); String output = "data/type/" + service.getCanonicalName() + ".json"; write(module, output, descriptor); }