本文整理汇总了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;
}
示例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();
}
}
}
示例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();
}
示例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);
}