Class FileDescriptorUtils
java.lang.Object
io.apicurio.registry.utils.protobuf.schema.FileDescriptorUtils
- Author:
- Fabian Martinez, Ravindranath Kakarla, Carles Arnal
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classstatic final classstatic final class -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic com.google.protobuf.Descriptors.FileDescriptor[]static StringextractProtoFileName(String protoFullName) Extract the proto file name out of a full proto file name, which is in the form ofpackageName/fileName.static com.squareup.wire.schema.internal.parser.ProtoFileElementfileDescriptorToProtoFile(com.google.protobuf.DescriptorProtos.FileDescriptorProto file) static com.squareup.wire.schema.internal.parser.ProtoFileElementfileDescriptorWithDepsToProtoFile(com.google.protobuf.Descriptors.FileDescriptor file, Map<String, com.squareup.wire.schema.internal.parser.ProtoFileElement> dependencies) static Optional<com.squareup.wire.schema.internal.parser.OptionElement>findOption(String name, List<com.squareup.wire.schema.internal.parser.OptionElement> options) static com.squareup.wire.schema.internal.parser.MessageElementfirstMessage(com.squareup.wire.schema.internal.parser.ProtoFileElement fileElement) static com.google.protobuf.Descriptors.FileDescriptorparseProtoFileWithDependencies(FileDescriptorUtils.ProtobufSchemaContent mainProtoFile, Collection<FileDescriptorUtils.ProtobufSchemaContent> dependencies) Same asparseProtoFileWithDependencies(ProtobufSchemaContent, Collection, Map, boolean), but withfailFastset totrueandrequiredSchemaDepsset tonull.static com.google.protobuf.Descriptors.FileDescriptorparseProtoFileWithDependencies(FileDescriptorUtils.ProtobufSchemaContent mainProtoFile, Collection<FileDescriptorUtils.ProtobufSchemaContent> dependencies, Map<String, String> requiredSchemaDeps, boolean failFast) Parse a proto file with its dependencies to produce aDescriptors.FileDescriptorof it, trying to resolve any transitive dependency.
Both the dependencies and the main proto file must be provided asFileDescriptorUtils.ProtobufSchemaContent, still unparsed, and whichFileDescriptorUtils.ProtobufSchemaContent.fileName()doesn't require to specify the package name, automatically later resolved by parsingFileDescriptorUtils.ProtobufSchemaContent.schemaDefinition().
During the resolution of dependencies process, depending onfailFast, the process will fail as soon as any parsing error happen in the list of provided dependencies, regardless been required or not, or it will proceed until a required dependency cannot be resolved.
IfrequiredSchemaDepsis provided, it will be populated with the required dependencies, which keys are in the form ofpackageName/fileNameand the value is the schema definition of the dependency.static com.google.protobuf.Descriptors.FileDescriptorparseProtoFileWithDependencies(File mainProtoFile, Set<File> dependencies) static com.google.protobuf.Descriptors.FileDescriptorparseProtoFileWithDependencies(File mainProtoFile, Set<File> dependencies, Map<String, String> requiredSchemaDeps) Same asparseProtoFileWithDependencies(File, Set, Map, boolean), but withfailFastset totrueandrequiredSchemaDepsset tonull.static com.google.protobuf.Descriptors.FileDescriptorparseProtoFileWithDependencies(File mainProtoFile, Set<File> dependencies, Map<String, String> requiredSchemaDeps, boolean failFast) Parse a proto file with its dependencies to produce aDescriptors.FileDescriptorof it, trying to resolve any transitive dependency.
During the resolution of dependencies process, depending onfailFast, the process will fail as soon as any parsing error happen in the list of provided dependencies, regardless been required or not, or it will proceed until a required dependency cannot be resolved.
IfrequiredSchemaDepsis provided, it will be populated with the required dependencies, which keys are in the form ofpackageName/fileNameand the value is the schema definition of the dependency.static com.google.protobuf.Descriptors.FileDescriptorprotoFileToFileDescriptor(com.google.protobuf.DescriptorProtos.FileDescriptorProto descriptorProto) static com.google.protobuf.Descriptors.FileDescriptorprotoFileToFileDescriptor(com.squareup.wire.schema.internal.parser.ProtoFileElement element) static com.google.protobuf.Descriptors.FileDescriptorprotoFileToFileDescriptor(com.squareup.wire.schema.internal.parser.ProtoFileElement element, String protoFileName) static com.google.protobuf.Descriptors.FileDescriptorprotoFileToFileDescriptor(String schemaDefinition, String protoFileName, Optional<String> optionalPackageName) static com.google.protobuf.Descriptors.FileDescriptorprotoFileToFileDescriptor(String schemaDefinition, String protoFileName, Optional<String> optionalPackageName, Map<String, String> schemaDefs, Map<String, com.google.protobuf.Descriptors.FileDescriptor> dependencies) static com.google.protobuf.Descriptors.DescriptortoDescriptor(String name, com.squareup.wire.schema.internal.parser.ProtoFileElement protoFileElement, Map<String, com.squareup.wire.schema.internal.parser.ProtoFileElement> dependencies) static com.google.protobuf.DescriptorProtos.FileDescriptorPrototoFileDescriptorProto(String schemaDefinition, String protoFileName, Optional<String> optionalPackageName, Map<String, String> deps) static StringtoMapField(String s)
-
Field Details
-
DEFAULT_LOCATION
public static final com.squareup.wire.schema.Location DEFAULT_LOCATION
-
-
Constructor Details
-
FileDescriptorUtils
public FileDescriptorUtils()
-
-
Method Details
-
baseDependencies
public static com.google.protobuf.Descriptors.FileDescriptor[] baseDependencies() -
protoFileToFileDescriptor
public static com.google.protobuf.Descriptors.FileDescriptor protoFileToFileDescriptor(com.google.protobuf.DescriptorProtos.FileDescriptorProto descriptorProto) throws com.google.protobuf.Descriptors.DescriptorValidationException - Throws:
com.google.protobuf.Descriptors.DescriptorValidationException
-
protoFileToFileDescriptor
public static com.google.protobuf.Descriptors.FileDescriptor protoFileToFileDescriptor(com.squareup.wire.schema.internal.parser.ProtoFileElement element) throws com.google.protobuf.Descriptors.DescriptorValidationException - Throws:
com.google.protobuf.Descriptors.DescriptorValidationException
-
protoFileToFileDescriptor
public static com.google.protobuf.Descriptors.FileDescriptor protoFileToFileDescriptor(com.squareup.wire.schema.internal.parser.ProtoFileElement element, String protoFileName) throws com.google.protobuf.Descriptors.DescriptorValidationException - Throws:
com.google.protobuf.Descriptors.DescriptorValidationException
-
protoFileToFileDescriptor
public static com.google.protobuf.Descriptors.FileDescriptor protoFileToFileDescriptor(String schemaDefinition, String protoFileName, Optional<String> optionalPackageName) throws com.google.protobuf.Descriptors.DescriptorValidationException - Throws:
com.google.protobuf.Descriptors.DescriptorValidationException
-
protoFileToFileDescriptor
public static com.google.protobuf.Descriptors.FileDescriptor protoFileToFileDescriptor(String schemaDefinition, String protoFileName, Optional<String> optionalPackageName, Map<String, String> schemaDefs, Map<String, throws com.google.protobuf.Descriptors.DescriptorValidationExceptioncom.google.protobuf.Descriptors.FileDescriptor> dependencies) - Throws:
com.google.protobuf.Descriptors.DescriptorValidationException
-
parseProtoFileWithDependencies
public static com.google.protobuf.Descriptors.FileDescriptor parseProtoFileWithDependencies(File mainProtoFile, Set<File> dependencies) throws com.google.protobuf.Descriptors.DescriptorValidationException, FileDescriptorUtils.ReadSchemaException, FileDescriptorUtils.ParseSchemaException - Throws:
com.google.protobuf.Descriptors.DescriptorValidationExceptionFileDescriptorUtils.ReadSchemaExceptionFileDescriptorUtils.ParseSchemaException
-
parseProtoFileWithDependencies
public static com.google.protobuf.Descriptors.FileDescriptor parseProtoFileWithDependencies(File mainProtoFile, Set<File> dependencies, Map<String, String> requiredSchemaDeps) throws FileDescriptorUtils.ReadSchemaException, com.google.protobuf.Descriptors.DescriptorValidationException, FileDescriptorUtils.ParseSchemaExceptionSame asparseProtoFileWithDependencies(File, Set, Map, boolean), but withfailFastset totrueandrequiredSchemaDepsset tonull.- Throws:
FileDescriptorUtils.ReadSchemaExceptioncom.google.protobuf.Descriptors.DescriptorValidationExceptionFileDescriptorUtils.ParseSchemaException
-
parseProtoFileWithDependencies
public static com.google.protobuf.Descriptors.FileDescriptor parseProtoFileWithDependencies(File mainProtoFile, Set<File> dependencies, Map<String, String> requiredSchemaDeps, boolean failFast) throws com.google.protobuf.Descriptors.DescriptorValidationException, FileDescriptorUtils.ReadSchemaException, FileDescriptorUtils.ParseSchemaExceptionParse a proto file with its dependencies to produce aDescriptors.FileDescriptorof it, trying to resolve any transitive dependency.
During the resolution of dependencies process, depending onfailFast, the process will fail as soon as any parsing error happen in the list of provided dependencies, regardless been required or not, or it will proceed until a required dependency cannot be resolved.
IfrequiredSchemaDepsis provided, it will be populated with the required dependencies, which keys are in the form ofpackageName/fileNameand the value is the schema definition of the dependency.- Throws:
com.google.protobuf.Descriptors.DescriptorValidationExceptionFileDescriptorUtils.ReadSchemaExceptionFileDescriptorUtils.ParseSchemaException
-
parseProtoFileWithDependencies
public static com.google.protobuf.Descriptors.FileDescriptor parseProtoFileWithDependencies(FileDescriptorUtils.ProtobufSchemaContent mainProtoFile, Collection<FileDescriptorUtils.ProtobufSchemaContent> dependencies) throws com.google.protobuf.Descriptors.DescriptorValidationException, FileDescriptorUtils.ParseSchemaException Same asparseProtoFileWithDependencies(ProtobufSchemaContent, Collection, Map, boolean), but withfailFastset totrueandrequiredSchemaDepsset tonull.- Throws:
com.google.protobuf.Descriptors.DescriptorValidationExceptionFileDescriptorUtils.ParseSchemaException
-
parseProtoFileWithDependencies
public static com.google.protobuf.Descriptors.FileDescriptor parseProtoFileWithDependencies(FileDescriptorUtils.ProtobufSchemaContent mainProtoFile, Collection<FileDescriptorUtils.ProtobufSchemaContent> dependencies, Map<String, String> requiredSchemaDeps, boolean failFast) throws com.google.protobuf.Descriptors.DescriptorValidationException, FileDescriptorUtils.ParseSchemaExceptionParse a proto file with its dependencies to produce aDescriptors.FileDescriptorof it, trying to resolve any transitive dependency.
Both the dependencies and the main proto file must be provided asFileDescriptorUtils.ProtobufSchemaContent, still unparsed, and whichFileDescriptorUtils.ProtobufSchemaContent.fileName()doesn't require to specify the package name, automatically later resolved by parsingFileDescriptorUtils.ProtobufSchemaContent.schemaDefinition().
During the resolution of dependencies process, depending onfailFast, the process will fail as soon as any parsing error happen in the list of provided dependencies, regardless been required or not, or it will proceed until a required dependency cannot be resolved.
IfrequiredSchemaDepsis provided, it will be populated with the required dependencies, which keys are in the form ofpackageName/fileNameand the value is the schema definition of the dependency.- Throws:
com.google.protobuf.Descriptors.DescriptorValidationExceptionFileDescriptorUtils.ParseSchemaException
-
extractProtoFileName
Extract the proto file name out of a full proto file name, which is in the form ofpackageName/fileName. -
toFileDescriptorProto
-
fileDescriptorWithDepsToProtoFile
-
fileDescriptorToProtoFile
public static com.squareup.wire.schema.internal.parser.ProtoFileElement fileDescriptorToProtoFile(com.google.protobuf.DescriptorProtos.FileDescriptorProto file) -
toDescriptor
-
firstMessage
public static com.squareup.wire.schema.internal.parser.MessageElement firstMessage(com.squareup.wire.schema.internal.parser.ProtoFileElement fileElement) -
findOption
-
toMapField
-