@@ -236,29 +236,72 @@ static String underscoresToCamelCase(String input) {
236
236
return underscoresToCamelCase (input , /* capitalizeNextLetter= */ true );
237
237
}
238
238
239
- /** Returns the fully qualified Java class name for the given message descriptor. */
240
- public static String getClassName (Descriptor message ) {
239
+ /**
240
+ * Returns the fully qualified Java bytecode class name for the given message descriptor.
241
+ *
242
+ * <p>Nested classes will use '$' as the separator, rather than '.'.
243
+ */
244
+ public static String getBytecodeClassName (Descriptor message ) {
241
245
// Replicates the logic for ClassName from immutable/names.h
242
246
return getClassFullName (
243
247
getClassNameWithoutPackage (message ), message .getFile (), !getNestInFileClass (message ));
244
248
}
245
249
246
- /** Returns the fully qualified Java class name for the given enum descriptor. */
247
- public static String getClassName (EnumDescriptor enm ) {
250
+ /**
251
+ * Returns the fully qualified Java bytecode class name for the given enum descriptor.
252
+ *
253
+ * <p>Nested classes will use '$' as the separator, rather than '.'.
254
+ */
255
+ public static String getBytecodeClassName (EnumDescriptor enm ) {
248
256
// Replicates the logic for ClassName from immutable/names.h
249
257
return getClassFullName (
250
258
getClassNameWithoutPackage (enm ), enm .getFile (), !getNestInFileClass (enm ));
251
259
}
252
260
253
- /** Returns the fully qualified Java class name for the given service descriptor. */
254
- static String getClassName (ServiceDescriptor service ) {
261
+ /**
262
+ * Returns the fully qualified Java bytecode class name for the given service descriptor.
263
+ *
264
+ * <p>Nested classes will use '$' as the separator, rather than '.'.
265
+ */
266
+ static String getBytecodeClassName (ServiceDescriptor service ) {
255
267
// Replicates the logic for ClassName from immutable/names.h
256
268
String suffix = "" ;
257
269
boolean isOwnFile = !getNestInFileClass (service );
258
270
return getClassFullName (getClassNameWithoutPackage (service ), service .getFile (), isOwnFile )
259
271
+ suffix ;
260
272
}
261
273
274
+ static String getQualifiedFromBytecodeClassName (String bytecodeClassName ) {
275
+ return bytecodeClassName .replace ('$' , '.' );
276
+ }
277
+
278
+ /**
279
+ * Returns the fully qualified Java class name for the given message descriptor.
280
+ *
281
+ * <p>Nested classes will use '.' as the separator, rather than '$'.
282
+ */
283
+ public static String getQualifiedClassName (Descriptor message ) {
284
+ return getQualifiedFromBytecodeClassName (getBytecodeClassName (message ));
285
+ }
286
+
287
+ /**
288
+ * Returns the fully qualified Java class name for the given enum descriptor.
289
+ *
290
+ * <p>Nested classes will use '.' as the separator, rather than '$'.
291
+ */
292
+ public static String getQualifiedClassName (EnumDescriptor enm ) {
293
+ return getQualifiedFromBytecodeClassName (getBytecodeClassName (enm ));
294
+ }
295
+
296
+ /**
297
+ * Returns the fully qualified Java class name for the given service descriptor.
298
+ *
299
+ * <p>Nested classes will use '.' as the separator, rather than '$'.
300
+ */
301
+ public static String getQualifiedClassName (ServiceDescriptor service ) {
302
+ return getQualifiedFromBytecodeClassName (getBytecodeClassName (service ));
303
+ }
304
+
262
305
private static String getClassFullName (
263
306
String nameWithoutPackage , FileDescriptor file , boolean isOwnFile ) {
264
307
// Replicates the logic for ClassNameResolver::GetJavaClassFullName from immutable/names.cc
0 commit comments