Class ClassUtil


  • public final class ClassUtil
    extends Object
    Various helper methods to deal with Classes
    • Method Detail

      • toClass

        public static Class toClass​(String str,
                                    ClassLoader loader)
        Return the class for the given string, correctly handling primitive types. If the given class loader is null, the context loader of the current thread will be used.
        Throws:
        RuntimeException - on load error
      • toClass

        public static Class toClass​(String str,
                                    boolean resolve,
                                    ClassLoader loader)
        Return the class for the given string, correctly handling primitive types. If the given class loader is null, the context loader of the current thread will be used.
        Throws:
        RuntimeException - on load error
      • getClassName

        public static String getClassName​(Class cls)
        Return only the class name, without package.
      • getClassName

        public static String getClassName​(String fullName)
        Return only the class name.
      • getPackageName

        public static String getPackageName​(Class cls)
        Return only the package, or empty string if none.
      • getPackageName

        public static String getPackageName​(String fullName)
        Return only the package, or empty string if none.