public final class ClassUtils extends Object
| 构造器和说明 |
|---|
ClassUtils() |
| 限定符和类型 | 方法和说明 |
|---|---|
static Set<String> |
fieldDiff(Class<?> a,
Class<?> b) |
static Class<?> |
findAnnotatedClass(Class<?> supClass,
Class<?> subClass,
Class<? extends Annotation> annClass) |
static String |
getClassFilePath(Class<?> clazz)
获取类文件的路径(文件)
|
static String |
getClasspath()
获取当前的类路径(目录)
|
static String |
getClasspath(Class<?> clazz)
获取指定类的类路径(目录)
|
static <T> Constructor<T> |
getConstructor(Class<T> type,
Class<?>... parameterTypes) |
static Field |
getField(Class<?> clazz,
String fieldName)
Returns the member field(include super class)
|
static List<Field> |
getFields(Class<?> clazz)
Returns member field list include super class(exclude transient field)
|
static Method |
getMethod(Object caller,
String methodName,
Class<?>... parameterTypes) |
static String |
getObjectClassName(Object obj) |
static String |
getPackagePath(Class<?> clazz)
包名称转目录路径名
ClassUtils.getPackagePath(ClassUtils.class) -> code/ponfee/commons/reflect
|
static String |
getPackagePath(String packageName)
包名称转目录路径名
getPackagePath("cn.ponfee.commons.reflect") -> cn/ponfee/commons/reflect
|
static Field |
getStaticField(Class<?> clazz,
String staticFieldName)
Returns the static field
|
static Field |
getStaticFieldIncludeSuperClass(Class<?> clazz,
String staticFieldName)
Returns the static field, get in class pointer chain
|
static <T> T |
invoke(Object caller,
Method method,
Object... args) |
static <T> T |
invoke(Object caller,
String methodName,
Class<?>[] parameterTypes,
Object[] args) |
static <T> T |
invoke(Object caller,
String methodName,
Object... args) |
static <T> T |
newInstance(Class<T> type,
Class<?>[] parameterTypes,
Object[] args) |
static <T> T |
newInstance(Class<T> type,
Object... args)
ClassUtils.newInstance(Tuple3.class, 1, 2, 3)
ClassUtils.newInstance(Tuple2.class, new String[]{"a", "b"}, new Integer[]{1, 2}) |
static <T> T |
newInstance(Constructor<T> constructor,
Object... args) |
public static Field getField(Class<?> clazz, String fieldName)
clazz - the typefieldName - the field namepublic static List<Field> getFields(Class<?> clazz)
clazz - the classpublic static Field getStaticFieldIncludeSuperClass(Class<?> clazz, String staticFieldName)
clazz - the clazzstaticFieldName - the static field namepublic static Field getStaticField(Class<?> clazz, String staticFieldName)
clazz - the clazzstaticFieldName - the static field namepublic static Class<?> findAnnotatedClass(Class<?> supClass, Class<?> subClass, Class<? extends Annotation> annClass)
public static String getPackagePath(String packageName)
getPackagePath("cn.ponfee.commons.reflect") -> cn/ponfee/commons/reflect
packageName - the package nameClassUtils.convertClassNameToResourcePath(java.lang.String)public static String getPackagePath(Class<?> clazz)
ClassUtils.getPackagePath(ClassUtils.class) -> code/ponfee/commons/reflect
clazz - the classpublic static String getClassFilePath(Class<?> clazz)
clazz - the classpublic static String getClasspath(Class<?> clazz)
clazz - the classpublic static String getClasspath()
public static <T> Constructor<T> getConstructor(Class<T> type, Class<?>... parameterTypes)
public static <T> T newInstance(Constructor<T> constructor, Object... args)
public static <T> T newInstance(Class<T> type, Object... args)
T - class typetype - the classargs - the argspublic static <T> T newInstance(Class<T> type, Class<?>[] parameterTypes, Object[] args)
public static Method getMethod(Object caller, String methodName, Class<?>... parameterTypes)
Copyright © 2025. All rights reserved.