UserTypeUtil { public static String getCanonicalName(UserType userType) { String name = getClassName(userType); String canonicalName; if (userType.isNested()) { Message parent = (Message) userType.getParent(); canonicalName = getCanonicalName(parent) + '.' + name; } else { Proto proto = userType.getProto(); String pkg = ProtoUtil.getPackage(proto); if (pkg.isEmpty()) { canonicalName = name; } else { canonicalName = pkg + '.' + name; } } return canonicalName; } private  UserTypeUtil(); static String getClassName(UserType userType); static String getCanonicalName(UserType userType);  }
@Test void getCanonicalName() { String name = UserTypeUtil.getCanonicalName(message); assertEquals("io.protostuff.MessageName", name); }
@Test void getCanonicalName_nestedMessage() { String name = UserTypeUtil.getCanonicalName(nestedMessage); assertEquals("io.protostuff.MessageName.NestedMessage", name); }
@Test void getCanonicalName_packageIsEmpty() { proto.setPackage(new Package(proto, "")); String name = UserTypeUtil.getCanonicalName(message); assertEquals("MessageName", name); }
@Test void getCanonicalName_packageIsSetByOption() { proto.getOptions().set("java_package", DynamicMessage.Value.createString("java.package")); String name = UserTypeUtil.getCanonicalName(message); assertEquals("java.package.MessageName", name); }