Java Code Examples for com.google.protobuf.DescriptorProtos.FileDescriptorProto#getPackage()
The following examples show how to use
com.google.protobuf.DescriptorProtos.FileDescriptorProto#getPackage() .
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: FileDescriptor.java From servicetalk with Apache License 2.0 | 6 votes |
FileDescriptor(final FileDescriptorProto protoFile) { this.protoFile = protoFile; sanitizedProtoFileName = sanitizeFileName(protoFile.getName()); protoPackageName = protoFile.hasPackage() ? protoFile.getPackage() : null; if (protoFile.hasOptions()) { final FileOptions fileOptions = protoFile.getOptions(); deprecated = fileOptions.hasDeprecated() && fileOptions.getDeprecated(); multipleClassFiles = fileOptions.hasJavaMultipleFiles() && fileOptions.getJavaMultipleFiles(); javaPackageName = fileOptions.hasJavaPackage() ? fileOptions.getJavaPackage() : null; outerClassName = fileOptions.hasJavaOuterClassname() ? fileOptions.getJavaOuterClassname() : null; } else { deprecated = false; multipleClassFiles = false; javaPackageName = null; outerClassName = null; } serviceClassBuilders = new ArrayList<>(protoFile.getServiceCount()); }
Example 2
Source File: ProtobufDecompiler.java From sql-layer with GNU Affero General Public License v3.0 | 6 votes |
public void decompile(FileDescriptorProto fileDescriptor) throws IOException { if (fileDescriptor.hasPackage()) { indentedFormat("package %s;", fileDescriptor.getPackage()); absolutePackage = "." + fileDescriptor.getPackage() + "."; } for (String dependency : fileDescriptor.getDependencyList()) { indentedFormat("import \"%s\";", dependency); } if (fileDescriptor.hasOptions()) { decompileOptions(fileDescriptor.getOptions()); } decompileMembers(fileDescriptor.getEnumTypeList(), fileDescriptor.getMessageTypeList(), Collections.<FieldDescriptorProto>emptyList(), Collections.<DescriptorProto.ExtensionRange>emptyList(), fileDescriptor.getExtensionList()); for (ServiceDescriptorProto serviceDescriptor : fileDescriptor.getServiceList()) { decompile(serviceDescriptor); } newline(); flush(); }
Example 3
Source File: GrpcDocStringExtractor.java From armeria with Apache License 2.0 | 6 votes |
@Nullable private static String getFullName(FileDescriptorProto descriptor, List<Integer> path) { String fullNameSoFar = descriptor.getPackage(); switch (path.get(0)) { case FileDescriptorProto.MESSAGE_TYPE_FIELD_NUMBER: final DescriptorProto message = descriptor.getMessageType(path.get(1)); return appendMessageToFullName(message, path, fullNameSoFar); case FileDescriptorProto.ENUM_TYPE_FIELD_NUMBER: final EnumDescriptorProto enumDescriptor = descriptor.getEnumType(path.get(1)); return appendEnumToFullName(enumDescriptor, path, fullNameSoFar); case FileDescriptorProto.SERVICE_FIELD_NUMBER: final ServiceDescriptorProto serviceDescriptor = descriptor.getService(path.get(1)); fullNameSoFar = appendNameComponent(fullNameSoFar, serviceDescriptor.getName()); if (path.size() > 2) { fullNameSoFar = appendFieldComponent( fullNameSoFar, serviceDescriptor.getMethod(path.get(3)).getName()); } return fullNameSoFar; default: return null; } }