use of com.google.protobuf.DescriptorProtos.ServiceDescriptorProto in project dubbo by alibaba.
the class AbstractGenerator method buildServiceContext.
private ServiceContext buildServiceContext(ServiceDescriptorProto serviceProto, ProtoTypeMap typeMap, List<Location> locations, int serviceNumber) {
ServiceContext serviceContext = new ServiceContext();
serviceContext.fileName = getClassPrefix() + serviceProto.getName() + getClassSuffix() + ".java";
serviceContext.className = getClassPrefix() + serviceProto.getName() + getClassSuffix();
serviceContext.serviceName = serviceProto.getName();
serviceContext.deprecated = serviceProto.getOptions() != null && serviceProto.getOptions().getDeprecated();
List<Location> allLocationsForService = locations.stream().filter(location -> location.getPathCount() >= 2 && location.getPath(0) == FileDescriptorProto.SERVICE_FIELD_NUMBER && location.getPath(1) == serviceNumber).collect(Collectors.toList());
Location serviceLocation = allLocationsForService.stream().filter(location -> location.getPathCount() == SERVICE_NUMBER_OF_PATHS).findFirst().orElseGet(Location::getDefaultInstance);
serviceContext.javaDoc = getJavaDoc(getComments(serviceLocation), getServiceJavaDocPrefix());
for (int methodNumber = 0; methodNumber < serviceProto.getMethodCount(); methodNumber++) {
MethodContext methodContext = buildMethodContext(serviceProto.getMethod(methodNumber), typeMap, locations, methodNumber);
serviceContext.methods.add(methodContext);
serviceContext.methodTypes.add(methodContext.inputType);
serviceContext.methodTypes.add(methodContext.outputType);
}
return serviceContext;
}
Aggregations