NamesUtil { public static String ensureQualifedName(String name, String defaultPackage) { if (!name.contains(".") && !defaultPackage.isEmpty()) return defaultPackage+"."+name; 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 testEnsureQualifedNameAllreadyQualified() { String actual = NamesUtil.ensureQualifedName("java.lang.Comparable", "xx"); Assert.assertEquals("Class name not constructed correctly", "java.lang.Comparable", actual); }
@Test public void testEnsureQualifedNameNotQualified() { String actual = NamesUtil.ensureQualifedName("Comparable", "java.lang"); Assert.assertEquals("Class name not constructed correctly", "java.lang.Comparable", actual); }