Class GeneratorNames


  • public final class GeneratorNames
    extends java.lang.Object
    Class containing helper methods for predicting names of generated java classes.
    • Constructor Detail

      • GeneratorNames

        private GeneratorNames()
    • Method Detail

      • getFileJavaPackage

        public static java.lang.String getFileJavaPackage​(Descriptors.FileDescriptor file)
        Returns the generated package for the given file descriptor.
      • getDefaultJavaPackage

        static java.lang.String getDefaultJavaPackage​(DescriptorProtos.FileOptions fileOptions,
                                                      java.lang.String filePackage)
        Returns the default java package for the given file.
      • joinPackage

        static java.lang.String joinPackage​(java.lang.String a,
                                            java.lang.String b)
        Joins two package segments into a single package name with a dot separator.
      • getProto2ApiDefaultJavaPackage

        static java.lang.String getProto2ApiDefaultJavaPackage​(DescriptorProtos.FileOptions fileOptions,
                                                               java.lang.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

        public static java.lang.String getFileClassName​(Descriptors.FileDescriptor file)
        Returns the generated unqualified outer file class name for the given file descriptor.
      • getDefaultFileClassName

        static java.lang.String getDefaultFileClassName​(DescriptorProtos.FileDescriptorProtoOrBuilder file,
                                                        boolean useOldOuterClassnameDefault)
        Returns the default unqualified file class name for the given file.
        Parameters:
        file - the file descriptor proto
        useOldOuterClassnameDefault - whether to use the old default for the outer classname
      • stripProto

        private static java.lang.String stripProto​(java.lang.String filename)
      • hasConflictingClassName

        private static boolean hasConflictingClassName​(DescriptorProtos.DescriptorProto messageDesc,
                                                       java.lang.String name)
        Used by the other overload, descends recursively into messages.
      • underscoresToCamelCase

        static java.lang.String underscoresToCamelCase​(java.lang.String input,
                                                       boolean capitalizeNextLetter)
        Converts a name to camel-case.
        Parameters:
        input - the input string to convert
        capitalizeNextLetter - whether to capitalize the first letter
      • underscoresToCamelCase

        static java.lang.String underscoresToCamelCase​(java.lang.String input)
      • getBytecodeClassName

        public static java.lang.String getBytecodeClassName​(Descriptors.Descriptor message)
        Returns the fully qualified Java bytecode class name for the given message descriptor.

        Nested classes will use '$' as the separator, rather than '.'.

      • getBytecodeClassName

        public static java.lang.String getBytecodeClassName​(Descriptors.EnumDescriptor enm)
        Returns the fully qualified Java bytecode class name for the given enum descriptor.

        Nested classes will use '$' as the separator, rather than '.'.

      • getBytecodeClassName

        static java.lang.String getBytecodeClassName​(Descriptors.ServiceDescriptor service)
        Returns the fully qualified Java bytecode class name for the given service descriptor.

        Nested classes will use '$' as the separator, rather than '.'.

      • getQualifiedFromBytecodeClassName

        static java.lang.String getQualifiedFromBytecodeClassName​(java.lang.String bytecodeClassName)
      • getQualifiedClassName

        public static java.lang.String getQualifiedClassName​(Descriptors.Descriptor message)
        Returns the fully qualified Java class name for the given message descriptor.

        Nested classes will use '.' as the separator, rather than '$'.

      • getQualifiedClassName

        public static java.lang.String getQualifiedClassName​(Descriptors.EnumDescriptor enm)
        Returns the fully qualified Java class name for the given enum descriptor.

        Nested classes will use '.' as the separator, rather than '$'.

      • getQualifiedClassName

        public static java.lang.String getQualifiedClassName​(Descriptors.ServiceDescriptor service)
        Returns the fully qualified Java class name for the given service descriptor.

        Nested classes will use '.' as the separator, rather than '$'.

      • getClassFullName

        private static java.lang.String getClassFullName​(java.lang.String nameWithoutPackage,
                                                         Descriptors.FileDescriptor file,
                                                         boolean isOwnFile)
      • stripPackageName

        static java.lang.String stripPackageName​(java.lang.String fullName,
                                                 Descriptors.FileDescriptor file)
        Returns the name of the given descriptor without the package name prefix.
      • getClassNameWithoutPackage

        static java.lang.String getClassNameWithoutPackage​(Descriptors.Descriptor message)
        Returns the name of the given message descriptor without the package name prefix.
      • getClassNameWithoutPackage

        static java.lang.String getClassNameWithoutPackage​(Descriptors.EnumDescriptor enm)
        Returns the name of the given enum descriptor without the package name prefix.
      • getClassNameWithoutPackage

        static java.lang.String getClassNameWithoutPackage​(Descriptors.ServiceDescriptor service)
        Returns the name of the given service descriptor without the package name prefix.