Java Class Simple Name Get simpleClassNameAndHashCodeString(Object object)

Here you can find the source of simpleClassNameAndHashCodeString(Object object)

Description

simple Class Name And Hash Code String

License

Apache License

Declaration

public static String simpleClassNameAndHashCodeString(Object object) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {
    public static String simpleClassNameAndHashCodeString(Object object) {
        String simpleClassName = simpleClassName(object);
        if (object == null) {
            return simpleClassName;
        } else {/*from   w w w  .jav  a2  s  .co m*/
            return simpleClassName + "@" + Integer.toHexString(object.hashCode());
        }
    }

    public static String simpleClassName(Object object) {
        if (object == null) {
            return "null_object";
        }

        Class clazz = object.getClass();
        Package pkg = clazz.getPackage();
        if (pkg != null) {
            return clazz.getName().substring(pkg.getName().length() + 1);
        } else {
            return clazz.getName();
        }
    }
}

Related

  1. simpleClassName(final String className)
  2. simpleClassName(Object o)
  3. simpleClassName(Object o)
  4. simpleClassName(Object object)
  5. simpleClassName(String fqn)
  6. simpleClassNameAndHashCodeString(Object object)
  7. simpleClassNameFrom(String fqClassName)
  8. simpleClassNameOf(Class c)
  9. simpleName(Class clazz)