NamesUtil { public static String[] getGenericQualifierNames(String className) { int genericQualifierPos = className.indexOf("<"); int genericQualifierEndPos = className.lastIndexOf(">"); if (genericQualifierPos>=0 && genericQualifierEndPos<=0 || genericQualifierPos>genericQualifierEndPos) throw new IllegalArgumentException("Illegal format of generic qualifier in "+className); if (genericQualifierPos>=0) { String qualifiers = className.substring(genericQualifierPos+1, genericQualifierEndPos); return qualifiers.split("\\,"); } else return emptyArray; } 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 testGetGenericQualifierNames() { String[] qualifiers = NamesUtil.getGenericQualifierNames("test.GenericInterface<java.lang.String,test.OtherInterface>"); Assert.assertArrayEquals("Class name not constructed correctly", new String[] { "java.lang.String", "test.OtherInterface"}, qualifiers); }
@Test public void testGetGenericQualifierNamesNOGenericType() { String[] qualifiers = NamesUtil.getGenericQualifierNames("test.GenericInterface"); Assert.assertArrayEquals("Class name not constructed correctly", new String[] {}, qualifiers); }