当前位置: 首页>>代码示例>>Java>>正文


Java ServiceDescriptorProto.getName方法代码示例

本文整理汇总了Java中com.google.protobuf.DescriptorProtos.ServiceDescriptorProto.getName方法的典型用法代码示例。如果您正苦于以下问题:Java ServiceDescriptorProto.getName方法的具体用法?Java ServiceDescriptorProto.getName怎么用?Java ServiceDescriptorProto.getName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.protobuf.DescriptorProtos.ServiceDescriptorProto的用法示例。


在下文中一共展示了ServiceDescriptorProto.getName方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: buildServiceContext

import com.google.protobuf.DescriptorProtos.ServiceDescriptorProto; //导入方法依赖的package包/类
private ServiceContext buildServiceContext(ServiceDescriptorProto serviceProto, ProtoTypeMap typeMap, List<Location> locations, int serviceNumber) {
    ServiceContext serviceContext = new ServiceContext();
    serviceContext.fileName = getClassPrefix() + serviceProto.getName() + "Grpc.java";
    serviceContext.className = getClassPrefix() + serviceProto.getName() + "Grpc";
    serviceContext.serviceName = serviceProto.getName();
    serviceContext.deprecated = serviceProto.getOptions() != null && serviceProto.getOptions().getDeprecated();

    locations.stream()
            .filter(location -> location.getPathCount() == METHOD_NUMBER_OF_PATHS &&
                    location.getPath(0) == FileDescriptorProto.SERVICE_FIELD_NUMBER &&
                    location.getPath(1) == serviceNumber &&
                    location.getPath(2) == ServiceDescriptorProto.METHOD_FIELD_NUMBER)
            .forEach(location -> {
                int methodNumber = location.getPath(METHOD_NUMBER_OF_PATHS - 1);
                MethodContext methodContext = buildMethodContext(serviceProto.getMethod(methodNumber), typeMap);
                methodContext.methodNumber = methodNumber;
                methodContext.javaDoc = getJavaDoc(getComments(location), getMethodJavaDocPrefix());
                serviceContext.methods.add(methodContext);
            });
    return serviceContext;
}
 
开发者ID:salesforce,项目名称:reactive-grpc,代码行数:22,代码来源:ReactiveGrpcGenerator.java

示例2: printService

import com.google.protobuf.DescriptorProtos.ServiceDescriptorProto; //导入方法依赖的package包/类
private void printService(List<ServiceDescriptorProto> serviceDescList, String javaPackage) {
  for (ServiceDescriptorProto serviceDesc : serviceDescList) {
    PrintServiceFile serviceFile =
        new PrintServiceFile(generatePath, javaPackage, serviceDesc.getName());
    try {
      serviceFile.setServiceMethods(serviceDesc.getMethodList());
      serviceFile.setPojoTypeCache(pojoTypes);
    } finally {
      serviceFile.print();
    }
  }
}
 
开发者ID:venus-boot,项目名称:saluki,代码行数:13,代码来源:CommonProto2Java.java

示例3: Interface

import com.google.protobuf.DescriptorProtos.ServiceDescriptorProto; //导入方法依赖的package包/类
private Interface(ProtoFile parent, ServiceDescriptorProto proto, String path) {
  super(parent, proto.getName(), path);
  this.proto = proto;

  // Build methods.
  ImmutableList.Builder<Method> methodsBuilder = ImmutableList.builder();
  List<MethodDescriptorProto> methodProtos = proto.getMethodList();
  for (int i = 0; i < methodProtos.size(); i++) {
    String childPath = buildPath(path, ServiceDescriptorProto.METHOD_FIELD_NUMBER, i);
    methodsBuilder.add(Method.create(this, methodProtos.get(i), childPath));
  }

  methods = methodsBuilder.build();
}
 
开发者ID:googleapis,项目名称:api-compiler,代码行数:15,代码来源:Interface.java

示例4: handle

import com.google.protobuf.DescriptorProtos.ServiceDescriptorProto; //导入方法依赖的package包/类
public void handle(ServiceDescriptorProto service) throws IOException {
  ImmutableList.Builder<ServiceHandlerData.Method> methods = ImmutableList.builder();
  for (MethodDescriptorProto method : service.getMethodList()) {
    ServiceHandlerData.Method methodData = new ServiceHandlerData.Method(
        method.getName(),
        CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_CAMEL, method.getName()),
        types.lookup(method.getInputType()).toString(),
        types.lookup(method.getOutputType()).toString());
    methods.add(methodData);
  }

  String fullName = Joiner.on('.').skipNulls().join(protoPackage, service.getName());

  ServiceHandlerData.Service serviceData = new ServiceHandlerData.Service(
      service.getName(), fullName, methods.build());
  ServiceHandlerData data = new ServiceHandlerData(javaPackage, multipleFiles, serviceData);

  String template = Resources.toString(Resources.getResource(this.getClass(),
      "service_class.mvel"), Charsets.UTF_8);
  String serviceFile = (String) TemplateRuntime.eval(template,
      ImmutableMap.<String, Object>of("handler", data));

  CodeGeneratorResponse.Builder response = CodeGeneratorResponse.newBuilder();
  CodeGeneratorResponse.File.Builder file = CodeGeneratorResponse.File.newBuilder();
  file.setContent(serviceFile);
  file.setName(javaPackage.replace('.', '/') + '/' + service.getName() + ".java");
  if (!multipleFiles) {
    file.setName(javaPackage.replace('.', '/') + '/' + outerClassName + ".java");
    file.setInsertionPoint("outer_class_scope");
  }
  response.addFile(file);
  response.build().writeTo(output);
}
 
开发者ID:jsilland,项目名称:piezo,代码行数:34,代码来源:ProtoServiceHandler.java


注:本文中的com.google.protobuf.DescriptorProtos.ServiceDescriptorProto.getName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。