类 ClassUtils

java.lang.Object
com.baomidou.mybatisplus.core.toolkit.ClassUtils

public final class ClassUtils extends Object

ClassUtils

从以下版本开始:
2017/07/08
作者:
Caratacus, HCL
  • 方法详细资料

    • isBoolean

      public static boolean isBoolean(Class<?> type)
      判断传入的类型是否是布尔类型
      参数:
      type - 类型
      返回:
      如果是原生布尔或者包装类型布尔,均返回 true
    • isProxy

      public static boolean isProxy(Class<?> clazz)
      判断是否为代理对象
      参数:
      clazz - 传入 class 对象
      返回:
      如果对象class是代理 class,返回 true
    • getUserClass

      public static Class<?> getUserClass(Class<?> clazz)

      获取当前对象的 class

      参数:
      clazz - 传入
      返回:
      如果是代理的class,返回父 class,否则返回自身
    • getUserClass

      public static Class<?> getUserClass(Object object)

      获取当前对象的class

      参数:
      object - 对象
      返回:
      返回对象的 user class
    • newInstance

      public static <T> T newInstance(Class<T> clazz)

      根据指定的 class , 实例化一个对象,根据构造参数来实例化

      在 java9 及其之后的版本 Class.newInstance() 方法已被废弃

      类型参数:
      T - 类型,由输入类型决定
      参数:
      clazz - 需要实例化的对象
      返回:
      返回新的实例
    • newInstance

      public static <T> T newInstance(String clazzName)
      实例化对象.
      类型参数:
      T - 类型
      参数:
      clazzName - 全类名
      返回:
      实例
      从以下版本开始:
      3.3.2
    • toClassConfident

      public static Class<?> toClassConfident(String name)

      请仅在确定类存在的情况下调用该方法

      参数:
      name - 全类名
      返回:
      返回转换后的 Class
    • toClassConfident

      public static Class<?> toClassConfident(String name, ClassLoader classLoader)
      参数:
      name - 全类名
      classLoader - 类加载器
      返回:
      Class信息
      从以下版本开始:
      3.4.3
    • getPackageName

      public static String getPackageName(Class<?> clazz)
      Determine the name of the package of the given class, e.g. "java.lang" for the java.lang.String class.
      参数:
      clazz - the class
      返回:
      the package name, or the empty String if the class is defined in the default package
    • getPackageName

      public static String getPackageName(String fqClassName)
      Determine the name of the package of the given fully-qualified class name, e.g. "java.lang" for the java.lang.String class name.
      参数:
      fqClassName - the fully-qualified class name
      返回:
      the package name, or the empty String if the class is defined in the default package
    • getDefaultClassLoader

      @Deprecated public static ClassLoader getDefaultClassLoader()
      已过时。
      Return the default ClassLoader to use: typically the thread context ClassLoader, if available; the ClassLoader that loaded the ClassUtils class will be used as fallback.

      Call this method if you intend to use the thread context ClassLoader in a scenario where you clearly prefer a non-null ClassLoader reference: for example, for class path resource loading (but not necessarily for Class.forName, which accepts a null ClassLoader reference as well).

      返回:
      the default ClassLoader (only null if even the system ClassLoader isn't accessible)
      从以下版本开始:
      3.3.2
      另请参阅: