@Test public void genClassName() throws Exception { assertThat(ProtobufDescriptorJavaUtil.genClassName(TestRequest.getDescriptor())) .isEqualTo("com.fullcontact.rpc.TestRequest"); assertThat(ProtobufDescriptorJavaUtil.genClassName(Test2.TestMessage2.getDescriptor())) .isEqualTo("com.fullcontact.rpc.Test2.TestMessage2"); assertThat(ProtobufDescriptorJavaUtil.genClassName(Test3Protos.TestMessage3.getDescriptor())) .isEqualTo("com.fullcontact.rpc.Test3Protos.TestMessage3"); }
public static String genClassName(Descriptors.Descriptor descriptor) { String pkg = descriptor.getFile().getOptions().getJavaPackage(); String outerClassName = descriptor.getFile().getOptions().getJavaOuterClassname(); boolean multipleFiles = descriptor.getFile().getOptions().getJavaMultipleFiles(); StringBuilder sb = new StringBuilder(pkg); sb.append("."); if (multipleFiles) { sb.append(descriptor.getName()); } else { String baseClassName; if (!outerClassName.isEmpty()) { baseClassName = outerClassName; } else { String baseName = descriptor.getFile().getName(); baseName = baseName.substring(baseName.lastIndexOf('/') + 1); baseName = baseName.replace(".proto", "").replace(".protodevel", ""); baseClassName = CaseFormat.LOWER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, baseName); } sb.append(baseClassName) .append(".") .append(descriptor.getName()); } return sb.toString(); }
ProtobufDescriptorJavaUtil { public static String genClassName(Descriptors.Descriptor descriptor) { String pkg = descriptor.getFile().getOptions().getJavaPackage(); String outerClassName = descriptor.getFile().getOptions().getJavaOuterClassname(); boolean multipleFiles = descriptor.getFile().getOptions().getJavaMultipleFiles(); StringBuilder sb = new StringBuilder(pkg); sb.append("."); if (multipleFiles) { sb.append(descriptor.getName()); } else { String baseClassName; if (!outerClassName.isEmpty()) { baseClassName = outerClassName; } else { String baseName = descriptor.getFile().getName(); baseName = baseName.substring(baseName.lastIndexOf('/') + 1); baseName = baseName.replace(".proto", "").replace(".protodevel", ""); baseClassName = CaseFormat.LOWER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, baseName); } sb.append(baseClassName) .append(".") .append(descriptor.getName()); } return sb.toString(); } }
ProtobufDescriptorJavaUtil { public static String genClassName(Descriptors.Descriptor descriptor) { String pkg = descriptor.getFile().getOptions().getJavaPackage(); String outerClassName = descriptor.getFile().getOptions().getJavaOuterClassname(); boolean multipleFiles = descriptor.getFile().getOptions().getJavaMultipleFiles(); StringBuilder sb = new StringBuilder(pkg); sb.append("."); if (multipleFiles) { sb.append(descriptor.getName()); } else { String baseClassName; if (!outerClassName.isEmpty()) { baseClassName = outerClassName; } else { String baseName = descriptor.getFile().getName(); baseName = baseName.substring(baseName.lastIndexOf('/') + 1); baseName = baseName.replace(".proto", "").replace(".protodevel", ""); baseClassName = CaseFormat.LOWER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, baseName); } sb.append(baseClassName) .append(".") .append(descriptor.getName()); } return sb.toString(); } private  ProtobufDescriptorJavaUtil(); }
ProtobufDescriptorJavaUtil { public static String genClassName(Descriptors.Descriptor descriptor) { String pkg = descriptor.getFile().getOptions().getJavaPackage(); String outerClassName = descriptor.getFile().getOptions().getJavaOuterClassname(); boolean multipleFiles = descriptor.getFile().getOptions().getJavaMultipleFiles(); StringBuilder sb = new StringBuilder(pkg); sb.append("."); if (multipleFiles) { sb.append(descriptor.getName()); } else { String baseClassName; if (!outerClassName.isEmpty()) { baseClassName = outerClassName; } else { String baseName = descriptor.getFile().getName(); baseName = baseName.substring(baseName.lastIndexOf('/') + 1); baseName = baseName.replace(".proto", "").replace(".protodevel", ""); baseClassName = CaseFormat.LOWER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, baseName); } sb.append(baseClassName) .append(".") .append(descriptor.getName()); } return sb.toString(); } private  ProtobufDescriptorJavaUtil(); static String javaPackage(DescriptorProtos.FileDescriptorProto fd); static String grpcImplBaseClass(DescriptorProtos.FileDescriptorProto fd,
            DescriptorProtos.ServiceDescriptorProto sdp); static String grpcStubClass(DescriptorProtos.FileDescriptorProto fd,
            DescriptorProtos.ServiceDescriptorProto sdp); static String jerseyResourceClassName(DescriptorProtos.ServiceDescriptorProto sdp); static String genClassName(Descriptors.Descriptor descriptor); static ImmutableList<Descriptors.FieldDescriptor> fieldPath(Descriptors.Descriptor root, String path); }
ProtobufDescriptorJavaUtil { public static String genClassName(Descriptors.Descriptor descriptor) { String pkg = descriptor.getFile().getOptions().getJavaPackage(); String outerClassName = descriptor.getFile().getOptions().getJavaOuterClassname(); boolean multipleFiles = descriptor.getFile().getOptions().getJavaMultipleFiles(); StringBuilder sb = new StringBuilder(pkg); sb.append("."); if (multipleFiles) { sb.append(descriptor.getName()); } else { String baseClassName; if (!outerClassName.isEmpty()) { baseClassName = outerClassName; } else { String baseName = descriptor.getFile().getName(); baseName = baseName.substring(baseName.lastIndexOf('/') + 1); baseName = baseName.replace(".proto", "").replace(".protodevel", ""); baseClassName = CaseFormat.LOWER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, baseName); } sb.append(baseClassName) .append(".") .append(descriptor.getName()); } return sb.toString(); } private  ProtobufDescriptorJavaUtil(); static String javaPackage(DescriptorProtos.FileDescriptorProto fd); static String grpcImplBaseClass(DescriptorProtos.FileDescriptorProto fd,
            DescriptorProtos.ServiceDescriptorProto sdp); static String grpcStubClass(DescriptorProtos.FileDescriptorProto fd,
            DescriptorProtos.ServiceDescriptorProto sdp); static String jerseyResourceClassName(DescriptorProtos.ServiceDescriptorProto sdp); static String genClassName(Descriptors.Descriptor descriptor); static ImmutableList<Descriptors.FieldDescriptor> fieldPath(Descriptors.Descriptor root, String path);  }