Class ClassUtils

java.lang.Object
cn.lm.mybatis.mapper.util.ClassUtils

public final class ClassUtils extends Object

ClassUtils

Since:
2017/07/08
Author:
Caratacus, HCL
  • Method Details

    • isBoolean

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

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

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

      获取当前对象的 class

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

      public static Class<?> getUserClass(Object object)

      获取当前对象的class

      Parameters:
      object - 对象
      Returns:
      返回对象的 user class
    • newInstance

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

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

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

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

      public static <T> T newInstance(String clazzName)
      实例化对象.
      Type Parameters:
      T - 类型
      Parameters:
      clazzName - 类名
      Returns:
      实例
      Since:
      3.3.2
    • toClassConfident

      public static Class<?> toClassConfident(String name)

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

      Parameters:
      name - 类名称
      Returns:
      返回转换后的 Class
    • toClassConfident

      public static Class<?> toClassConfident(String name, ClassLoader classLoader)
      Parameters:
      name -
      classLoader -
      Returns:
      Since:
      3.4.3
    • getDefaultClassLoader

      @Deprecated public static ClassLoader getDefaultClassLoader()
      Deprecated.
      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).

      Returns:
      the default ClassLoader (only null if even the system ClassLoader isn't accessible)
      Since:
      3.3.2
      See Also: