Convert { public static String innerClassName(String enclosingClassName, String shortName) { Preconditions.checkArgument(!enclosingClassName.isEmpty(), "Enclosing class name should not be empty : " + shortName); int indexEnclosing = shortName.indexOf(enclosingClassName); if (indexEnclosing == -1) { return shortName; } Preconditions.checkState(shortName.substring(indexEnclosing + enclosingClassName.length()).charAt(0) == '$'); return shortName.substring(indexEnclosing + enclosingClassName.length() + 1); } private  Convert(); static String packagePart(String fullName); static String shortName(String fullName); static String flatName(String bytecodeName); static String bytecodeName(String fullName); static String enclosingClassName(String shortName); static String innerClassName(String enclosingClassName, String shortName); static String fullName(String packagePart, String className);  }
@Test void innerClassName() throws Exception { String enclosingClassName = "MyClass"; assertThat(Convert.innerClassName(enclosingClassName, "MyClass$InnerClass")).isEqualTo("InnerClass"); assertThat(Convert.innerClassName(enclosingClassName, "MyClass$InnerClass$")).isEqualTo("InnerClass$"); assertThat(Convert.innerClassName(enclosingClassName, "MyClass$InnerClass$class")).isEqualTo("InnerClass$class"); assertThat(Convert.innerClassName(enclosingClassName, "MyClass$$InnerClass$")).isEqualTo("$InnerClass$"); assertThat(Convert.innerClassName("Rules$ListResponse$Rule", "Rules$ListResponse$Rule$Builder")).isEqualTo("Builder"); }