JavaLibrary { public static String simpleClassName(String qualifiedClassName) { String simpleClassName = qualifiedClassName; int lastPackageSeparator = qualifiedClassName.lastIndexOf('.'); if (lastPackageSeparator > -1) { simpleClassName = qualifiedClassName.substring(lastPackageSeparator + 1); } int lastNestingSeparator = simpleClassName.lastIndexOf('$'); if (lastNestingSeparator > -1) { simpleClassName = simpleClassName.substring(lastNestingSeparator + 1); } return simpleClassName; }  static String asClasspath(URL[] urls); static String[] asFilePath(URL[] urls); static String simpleClassName(String qualifiedClassName); static String packageName(String qualifiedClassName); static String systemClasspath(); static URL[] systemClasspathURLs(); static void extendSystemClasspathWith(URL[] classpaths); static URL[] extendClasspathWith(String classpath, URL[] destination); static URL[] classpathFrom(String classpath); static void setClasspath(String newClasspath); static void extendSystemClassLoaderClasspathWith(URL[] classpaths); static void extendClassLoaderClasspathWith(URLClassLoader classLoader, URL[] classpaths); static Class<?> classFromClasspath(URL classpath, String qualifiedName); static List<Class<?>> classesFromClasspath(URL[] classpath, Collection<String> qualifiedNames); static List<Class<?>> loadedClassesFrom(ClassLoader classLoader, Collection<String> qualifiedNames); static void close(URLClassLoader loader); static Character classpathSeparator(); static Character folderPathSeparator(); static String lineSeparator();  }
@Test public void classNameFromQualifiedName() { assertEquals("", simpleClassName("")); assertEquals("HelloWorld", simpleClassName("HelloWorld")); assertEquals("HelloWorld", simpleClassName("java.HelloWorld")); assertEquals("HelloWorld", simpleClassName("java.api.HelloWorld")); assertEquals("Greeting", simpleClassName("HelloWorld$Greeting")); assertEquals("Greeting", simpleClassName("java.api.HelloWorld$Greeting")); assertEquals("Inner", simpleClassName(Inner.class.getName())); assertEquals("Inner", simpleClassName(Inner.class.getSimpleName())); assertEquals("Inner", simpleClassName(Inner.class.getCanonicalName())); assertEquals("NestedInner", simpleClassName(Inner.NestedInner.class.getName())); assertEquals("NestedInner", simpleClassName(Inner.NestedInner.class.getSimpleName())); assertEquals("NestedInner", simpleClassName(Inner.NestedInner.class.getCanonicalName())); }