Java Utililty Methods Class Simple Name Get

List of utility methods to do Class Simple Name Get

Description

The list of methods to do Class Simple Name Get are organized into topic(s).

Method

StringsimpleClassName(String fqn)
simple Class Name
int lastDot = fqn.lastIndexOf('.');
return lastDot > 0 ? fqn.substring(lastDot + 1) : fqn;
StringsimpleClassNameAndHashCodeString(Object object)
simple Class Name And Hash Code String
if (object == null) {
    return "null_object";
return object.getClass().getSimpleName() + "@" + Integer.toHexString(object.hashCode());
StringsimpleClassNameAndHashCodeString(Object object)
simple Class Name And Hash Code String
String simpleClassName = simpleClassName(object);
if (object == null) {
    return simpleClassName;
} else {
    return simpleClassName + "@" + Integer.toHexString(object.hashCode());
StringsimpleClassNameFrom(String fqClassName)
simple Class Name From
if (fqClassName == null) {
    return null;
} else if (fqClassName.isEmpty()) {
    return "";
final String[] split = fqClassName.split("\\.");
return split[split.length - 1];
StringsimpleClassNameOf(Class c)
Since Class.getSimpleName() method is not supported by GWT JRE.
String cname = c.getName();
return cname.substring(cname.lastIndexOf('.') + 1);
StringsimpleName(Class clazz)
simple Name
String name = clazz.getName();
int p = name.lastIndexOf(".");
if (p >= 0) {
    name = name.substring(p + 1);
return name;
StringsimpleName(Class c)
Produce the simple name of the given class, as specified by Class#getSimpleName , with an improved scheme for anonymous classes.
if (c.isArray()) {
    return simpleName(c.getComponentType()) + "[]";
} else if (isAnonymousClass(c)) {
    if (c.getInterfaces().length > 0) {
        return "anonymous " + simpleName(c.getInterfaces()[0]);
    } else {
        return "anonymous " + simpleName(c.getSuperclass());
} else {
    String fullName = c.getName();
    int dot = fullName.lastIndexOf('.');
    int dollar = fullName.lastIndexOf('$');
    int nameStart = (dot > dollar) ? dot + 1 : dollar + 1;
    int length = fullName.length();
    while (nameStart < length && Character.isDigit(fullName.charAt(nameStart))) {
        nameStart++;
    return fullName.substring(nameStart);
StringsimpleName(final Class className)
simple Name
if (className != null) {
    return className.getSimpleName();
} else {
    return "NULL";
StringsimpleName(final String fqn)
simple Name
int dotIndex = fqn.lastIndexOf(".");
if (dotIndex == -1) {
    return fqn;
if (dotIndex == fqn.length() - 1) {
    throw new IllegalArgumentException("Bad class name (trailing dot) [" + fqn + "]");
return fqn.substring(dotIndex + 1);
...
StringsimpleName(final String fullyQualifiedClassName)
simple Name
return fullyQualifiedClassName.substring(fullyQualifiedClassName.lastIndexOf('.') + 1);