Class GeneratorNames
java.lang.Object
com.google.protobuf.GeneratorNames
Class containing helper methods for predicting names of generated java classes.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringReturns the fully qualified Java bytecode class name for the given message descriptor.static StringReturns the fully qualified Java bytecode class name for the given enum descriptor.(package private) static StringReturns the fully qualified Java bytecode class name for the given service descriptor.private static StringgetClassFullName(String nameWithoutPackage, Descriptors.FileDescriptor file, boolean isOwnFile) (package private) static StringReturns the name of the given message descriptor without the package name prefix.(package private) static StringReturns the name of the given enum descriptor without the package name prefix.(package private) static StringReturns the name of the given service descriptor without the package name prefix.(package private) static StringgetDefaultFileClassName(DescriptorProtos.FileDescriptorProtoOrBuilder file, boolean useOldOuterClassnameDefault) Returns the default unqualified file class name for the given file.(package private) static StringgetDefaultJavaPackage(DescriptorProtos.FileOptions fileOptions, String filePackage) Returns the default java package for the given file.static StringReturns the generated unqualified outer file class name for the given file descriptor proto.static StringReturns the generated unqualified outer file class name for the given file descriptor.private static StringgetFileClassNameImpl(DescriptorProtos.FileDescriptorProtoOrBuilder file, JavaFeaturesProto.JavaFeatures resolvedFeatures) static StringReturns the generated package for the given file descriptor proto.static StringReturns the generated package for the given file descriptor.static booleangetNestInFileClass(Descriptors.Descriptor descriptor) static booleangetNestInFileClass(Descriptors.EnumDescriptor descriptor) private static booleangetNestInFileClass(Descriptors.FileDescriptor file, JavaFeaturesProto.JavaFeatures resolvedFeatures) Returns the nest_in_file_class behavior for a given set of features in a specific file.private static booleangetNestInFileClass(Descriptors.ServiceDescriptor descriptor) (package private) static StringgetProto2ApiDefaultJavaPackage(DescriptorProtos.FileOptions fileOptions, String filePackage) Returns the package name to use for a file that is being compiled as proto2-API.static StringReturns the fully qualified Java class name for the given message descriptor.static StringReturns the fully qualified Java class name for the given enum descriptor.static StringReturns the fully qualified Java class name for the given service descriptor.(package private) static StringgetQualifiedFromBytecodeClassName(String bytecodeClassName) (package private) static <T extends Message>
TgetResolvedFileFeatures(GeneratedMessage.GeneratedExtension<DescriptorProtos.FeatureSet, T> ext, DescriptorProtos.FileDescriptorProtoOrBuilder file) Returns the resolved features for the given descriptor proto.private static booleanhasConflictingClassName(DescriptorProtos.DescriptorProto messageDesc, String name) Used by the other overload, descends recursively into messages.private static booleanChecks whether any generated classes conflict with the given name.(package private) static StringjoinPackage(String a, String b) Joins two package segments into a single package name with a dot separator.(package private) static StringstripPackageName(String fullName, Descriptors.FileDescriptor file) Returns the name of the given descriptor without the package name prefix.private static StringstripProto(String filename) (package private) static StringunderscoresToCamelCase(String input) (package private) static StringunderscoresToCamelCase(String input, boolean capitalizeNextLetter) Converts a name to camel-case.
-
Constructor Details
-
GeneratorNames
private GeneratorNames()
-
-
Method Details
-
getFileJavaPackage
Returns the generated package for the given file descriptor proto. -
getFileJavaPackage
Returns the generated package for the given file descriptor. -
getDefaultJavaPackage
Returns the default java package for the given file. -
joinPackage
-
getProto2ApiDefaultJavaPackage
static String getProto2ApiDefaultJavaPackage(DescriptorProtos.FileOptions fileOptions, String filePackage) Returns the package name to use for a file that is being compiled as proto2-API. If the file is declared as proto1-API, this may involve using the alternate package name. -
getFileClassName
Returns the generated unqualified outer file class name for the given file descriptor proto. -
getFileClassName
Returns the generated unqualified outer file class name for the given file descriptor. -
getFileClassNameImpl
private static String getFileClassNameImpl(DescriptorProtos.FileDescriptorProtoOrBuilder file, JavaFeaturesProto.JavaFeatures resolvedFeatures) -
getResolvedFileFeatures
static <T extends Message> T getResolvedFileFeatures(GeneratedMessage.GeneratedExtension<DescriptorProtos.FeatureSet, T> ext, DescriptorProtos.FileDescriptorProtoOrBuilder file) Returns the resolved features for the given descriptor proto.This method isn't actually naming-specific, but lives here for now because it's the only place it's needed. Once we have a better home for dealing with features in code generators, this should move.
-
getDefaultFileClassName
static String getDefaultFileClassName(DescriptorProtos.FileDescriptorProtoOrBuilder file, boolean useOldOuterClassnameDefault) Returns the default unqualified file class name for the given file.- Parameters:
file- the file descriptor protouseOldOuterClassnameDefault- whether to use the old default for the outer classname
-
stripProto
-
hasConflictingClassName
private static boolean hasConflictingClassName(DescriptorProtos.FileDescriptorProtoOrBuilder file, String name) Checks whether any generated classes conflict with the given name. -
hasConflictingClassName
private static boolean hasConflictingClassName(DescriptorProtos.DescriptorProto messageDesc, String name) Used by the other overload, descends recursively into messages. -
underscoresToCamelCase
-
underscoresToCamelCase
-
getBytecodeClassName
Returns the fully qualified Java bytecode class name for the given message descriptor.Nested classes will use '$' as the separator, rather than '.'.
-
getBytecodeClassName
Returns the fully qualified Java bytecode class name for the given enum descriptor.Nested classes will use '$' as the separator, rather than '.'.
-
getBytecodeClassName
Returns the fully qualified Java bytecode class name for the given service descriptor.Nested classes will use '$' as the separator, rather than '.'.
-
getQualifiedFromBytecodeClassName
-
getQualifiedClassName
Returns the fully qualified Java class name for the given message descriptor.Nested classes will use '.' as the separator, rather than '$'.
-
getQualifiedClassName
Returns the fully qualified Java class name for the given enum descriptor.Nested classes will use '.' as the separator, rather than '$'.
-
getQualifiedClassName
Returns the fully qualified Java class name for the given service descriptor.Nested classes will use '.' as the separator, rather than '$'.
-
getClassFullName
private static String getClassFullName(String nameWithoutPackage, Descriptors.FileDescriptor file, boolean isOwnFile) -
getNestInFileClass
private static boolean getNestInFileClass(Descriptors.FileDescriptor file, JavaFeaturesProto.JavaFeatures resolvedFeatures) Returns the nest_in_file_class behavior for a given set of features in a specific file. -
getNestInFileClass
-
getNestInFileClass
-
getNestInFileClass
-
stripPackageName
Returns the name of the given descriptor without the package name prefix. -
getClassNameWithoutPackage
Returns the name of the given message descriptor without the package name prefix. -
getClassNameWithoutPackage
Returns the name of the given enum descriptor without the package name prefix. -
getClassNameWithoutPackage
Returns the name of the given service descriptor without the package name prefix.
-