Class ProtobufClassName
- java.lang.Object
-
- com.amazonaws.services.schemaregistry.deserializers.protobuf.ProtobufClassName
-
public class ProtobufClassName extends Object
-
-
Constructor Summary
Constructors Constructor Description ProtobufClassName()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Stringfrom(com.google.protobuf.Descriptors.Descriptor messageDescriptor)Derives the Protobuf generated Java class name using the Descriptor.static Stringnormalize(String fileDescriptorName)Normalizes the fileDescriptorName to class name.
-
-
-
Method Detail
-
from
public static String from(@NonNull com.google.protobuf.Descriptors.Descriptor messageDescriptor)
Derives the Protobuf generated Java class name using the Descriptor. This logic is reverse-engineered from how the Protobuf compiler generates the Java classes. Below method generates the class name from given sample schema, ``` //File name: Sample.proto package foo.bar.com; message abc { message def {} } ``` Class name: `foo.bar.com.Sample$abc$def` Reference: https://github.com/protocolbuffers/protobuf/blob/4e0a1119c0c5cdfe89b54b9d66cb76223f17861a/src/google/protobuf/compiler/java/java_name_resolver.cc#L157- Parameters:
messageDescriptor- Protobuf message descriptor- Returns:
- inferred class name.
-
normalize
public static String normalize(String fileDescriptorName)
Normalizes the fileDescriptorName to class name. Protobuf compiler replaces special characters and camel cases it to generate the class name. Reference: https://github.com/protocolbuffers/protobuf/blob/4e0a1119c0c5cdfe89b54b9d66cb76223f17861a/src/google/protobuf/compiler/java/java_helpers.cc#L159
-
-