Class ClassUtil


  • public final class ClassUtil
    extends java.lang.Object
    Various helper methods to deal with Classes
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.String getClassName​(java.lang.Class cls)
      Return only the class name, without package.
      static java.lang.String getClassName​(java.lang.String fullName)
      Return only the class name.
      static java.lang.String getPackageName​(java.lang.Class cls)
      Return only the package, or empty string if none.
      static java.lang.String getPackageName​(java.lang.String fullName)
      Return only the package, or empty string if none.
      static java.lang.Class toClass​(java.lang.String str, boolean resolve, java.lang.ClassLoader loader)
      Return the class for the given string, correctly handling primitive types.
      static java.lang.Class toClass​(java.lang.String str, java.lang.ClassLoader loader)
      Return the class for the given string, correctly handling primitive types.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • toClass

        public static java.lang.Class toClass​(java.lang.String str,
                                              java.lang.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:
        java.lang.RuntimeException - on load error
      • toClass

        public static java.lang.Class toClass​(java.lang.String str,
                                              boolean resolve,
                                              java.lang.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:
        java.lang.RuntimeException - on load error
      • getClassName

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

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

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

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