NamesUtil { public static String getUnqualifiedName(String name) { int lastSep = stripGenericQualifier(name).lastIndexOf('.'); if (lastSep>=0) return name.substring(lastSep+1); else return name; } private  NamesUtil(); static boolean isJavaLangClassName(String identifier); static boolean isJavaUtilClassName(String identifier); static String makeSafeJavaIdentifier(String identifier); static String createNewClassNameFromInterfaceName(String interfaceName); static String getGenericQualifier(String className); static String[] getGenericQualifierNames(String className); static boolean hasGenericQualifier(String name); static String stripGenericQualifier(String className); static String stripArrrayQualifier(String className); static String ensureQualifedName(String name, String defaultPackage); static boolean isQualifiedName(String name); static String getUnqualifiedName(String name); static String getPackageFromQualifiedName(String name); static boolean hasPackage(String qualifiedName, String packageName); static boolean isGetterMethod(String methodName, String[] getterPrefixes); static boolean isSetterMethod(String methodName, String[] setterPrefixes); static String getWrapperTypeName(String typeName); static boolean hasWilcard(String wildcardSpecifier); static boolean matchingOverloads(String overloadNamesSpecifier1, String overloadNamesSpecifier2, boolean ignoreAllPackages); static final String ImplClassSuffix; }
@Test public void testUnqualifiedName() { String actual = NamesUtil.getUnqualifiedName("java.lang.Comparable"); Assert.assertEquals("Class name not constructed correctly", "Comparable", actual); }
@Test public void testUnqualifiedGenericName() { String actual = NamesUtil.getUnqualifiedName("java.lang.Comparable<java.lang.String>"); Assert.assertEquals("Class name not constructed correctly", "Comparable<java.lang.String>", actual); }