类 ClassUtils
java.lang.Object
com.baomidou.mybatisplus.core.toolkit.ClassUtils
ClassUtils
- 从以下版本开始:
- 2017/07/08
- 作者:
- Caratacus, HCL
-
方法概要
修饰符和类型方法说明static ClassLoader已过时。static StringgetPackageName(Class<?> clazz) Determine the name of the package of the given class, e.g.static StringgetPackageName(String fqClassName) Determine the name of the package of the given fully-qualified class name, e.g.static Class<?> getUserClass(Class<?> clazz) 获取当前对象的 classstatic Class<?> getUserClass(Object object) 获取当前对象的classstatic boolean判断传入的类型是否是布尔类型static boolean判断是否为代理对象static <T> TnewInstance(Class<T> clazz) 根据指定的 class , 实例化一个对象,根据构造参数来实例化static <T> TnewInstance(String clazzName) 实例化对象.static Class<?> toClassConfident(String name) 请仅在确定类存在的情况下调用该方法static Class<?> toClassConfident(String name, ClassLoader classLoader)
-
方法详细资料
-
isBoolean
判断传入的类型是否是布尔类型- 参数:
type- 类型- 返回:
- 如果是原生布尔或者包装类型布尔,均返回 true
-
isProxy
判断是否为代理对象- 参数:
clazz- 传入 class 对象- 返回:
- 如果对象class是代理 class,返回 true
-
getUserClass
获取当前对象的 class
- 参数:
clazz- 传入- 返回:
- 如果是代理的class,返回父 class,否则返回自身
-
getUserClass
获取当前对象的class
- 参数:
object- 对象- 返回:
- 返回对象的 user class
-
newInstance
根据指定的 class , 实例化一个对象,根据构造参数来实例化
在 java9 及其之后的版本 Class.newInstance() 方法已被废弃
- 类型参数:
T- 类型,由输入类型决定- 参数:
clazz- 需要实例化的对象- 返回:
- 返回新的实例
-
newInstance
实例化对象.- 类型参数:
T- 类型- 参数:
clazzName- 全类名- 返回:
- 实例
- 从以下版本开始:
- 3.3.2
-
toClassConfident
请仅在确定类存在的情况下调用该方法
- 参数:
name- 全类名- 返回:
- 返回转换后的 Class
-
toClassConfident
- 参数:
name- 全类名classLoader- 类加载器- 返回:
- Class信息
- 从以下版本开始:
- 3.4.3
-
getPackageName
Determine the name of the package of the given class, e.g. "java.lang" for thejava.lang.Stringclass.- 参数:
clazz- the class- 返回:
- the package name, or the empty String if the class is defined in the default package
-
getPackageName
Determine the name of the package of the given fully-qualified class name, e.g. "java.lang" for thejava.lang.Stringclass name.- 参数:
fqClassName- the fully-qualified class name- 返回:
- the package name, or the empty String if the class is defined in the default package
-
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 anullClassLoader reference as well).- 返回:
- the default ClassLoader (only
nullif even the system ClassLoader isn't accessible) - 从以下版本开始:
- 3.3.2
- 另请参阅:
-