JavaClassNames { public static String superSimpleClassName(Class<?> t) { if (Map.class.isAssignableFrom(t)) return "map"; if (Iterable.class.isAssignableFrom(t) || Iterator.class.isAssignableFrom(t) || t.isArray()) return "list"; if (CharSequence.class.isAssignableFrom(t)) return "string"; if (Number.class.isAssignableFrom(t)) return "number"; if (Boolean.class.isAssignableFrom(t)) return "boolean"; return simpleClassName(t); }  static Class<?> type(Object x); static Class<?> componentType(Object x); static String superSimpleClassName(Class<?> t); static String superSimpleClassName(Object o); static String simpleClassName(Class<?> t); static String verySimpleClassName(Class<?> t); static String simpleClassName(Object x); static String simplifyClassName(String className); static String cleanSimpleClassName(Object x); static String cleanSimpleClassName(Class<?> x); static String packageName(Object x); static String packagePath(Object x); static String resolveName(Object context, String path); static String resolveClasspathUrl(Object context, String path); static StackTraceElement[] currentStackTraceCleaned(); static StackTraceElement currentStackElement(); static StackTraceElement callerStackElement(int depth); static String niceClassAndMethod(StackTraceElement st); static String callerNiceClassAndMethod(int depth); static String niceClassAndMethod();  }
@Test public void testSuperSimpleClassNames() { Assert.assertEquals(JavaClassNames.superSimpleClassName(this), "JavaClassNamesTest"); Assert.assertEquals(JavaClassNames.superSimpleClassName(1), "number"); Assert.assertEquals(JavaClassNames.superSimpleClassName(true), "boolean"); Assert.assertEquals(JavaClassNames.superSimpleClassName("hello world"), "string"); Assert.assertEquals(JavaClassNames.superSimpleClassName(new String[][] { }), "list"); Assert.assertEquals(JavaClassNames.superSimpleClassName(new int[] { 1, 2, 3 }), "list"); Assert.assertEquals(JavaClassNames.superSimpleClassName(MutableMap.of("key", "val")), "map"); Assert.assertEquals(JavaClassNames.superSimpleClassName(MutableMap.of()), "map"); Assert.assertEquals(JavaClassNames.superSimpleClassName(MutableList.of()), "list"); }