类 Classes
- java.lang.Object
-
- net.dongliu.commons.reflect.Classes
-
public class Classes extends java.lang.ObjectUtils method for Class reflection.
-
-
构造器概要
构造器 构造器 说明 Classes()
-
方法概要
所有方法 静态方法 具体方法 修饰符和类型 方法 说明 static <T> java.lang.Class<T>cast(java.lang.Class<? super T> cls)Method for suppress generic class type cast warning.static booleanexists(java.lang.String className)Use Reflection to see if class exists, using context classloader of current thread.static booleanexists(java.lang.String className, java.lang.ClassLoader classLoader)Use Reflection to see if class exists, using specified classloader.static java.util.List<java.lang.reflect.Field>getAllMemberFields(java.lang.Class<?> cls)Get all non-static, non-Synthetic fields, declared in this class and all it's parent classes.static booleanhasMethod(java.lang.Class<?> cls, java.lang.String methodName, java.lang.Class<?>... parameterTypes)If class has specified method.static booleanisAbstract(java.lang.Class<?> cls)If is abstract classstatic booleanisFinal(java.lang.Class<?> cls)If is final classstatic booleanisInterface(java.lang.Class<?> cls)If is interface classstatic booleanisPrimitiveWrapper(java.lang.Class<?> cls)If class is primitive wrapper class(Integer, Boolean, etc).static booleanisPrivate(java.lang.Class<?> cls)If is private classstatic booleanisProtected(java.lang.Class<?> cls)If is protected classstatic booleanisPublic(java.lang.Class<?> cls)If is public class
-
-
-
方法详细资料
-
cast
public static <T> java.lang.Class<T> cast(java.lang.Class<? super T> cls)
Method for suppress generic class type cast warning. Usage:Class≶List≶String>> cls = Classes.cast(List.class);
- 类型参数:
T- the class type- 参数:
cls- the class
-
getAllMemberFields
public static java.util.List<java.lang.reflect.Field> getAllMemberFields(java.lang.Class<?> cls)
Get all non-static, non-Synthetic fields, declared in this class and all it's parent classes. If sub class override parent class's filed, will only return sub class's field.- 参数:
cls- the class- 返回:
- list of fields
-
exists
public static boolean exists(java.lang.String className)
Use Reflection to see if class exists, using context classloader of current thread. The class will not be initialized.- 参数:
className- the full class name- 返回:
- true if class exists.
-
exists
public static boolean exists(java.lang.String className, java.lang.ClassLoader classLoader)Use Reflection to see if class exists, using specified classloader. The class will not be initialized.- 参数:
className- the full class name- 返回:
- true if class exists.
-
hasMethod
public static boolean hasMethod(java.lang.Class<?> cls, java.lang.String methodName, java.lang.Class<?>... parameterTypes)If class has specified method.- 参数:
cls- the classmethodName- the method nameparameterTypes- the method parameter types- 返回:
- if method exists
-
isPrimitiveWrapper
public static boolean isPrimitiveWrapper(java.lang.Class<?> cls)
If class is primitive wrapper class(Integer, Boolean, etc).- 参数:
cls- the class- 返回:
- true if is primitive wrapper class
-
isPrivate
public static boolean isPrivate(java.lang.Class<?> cls)
If is private class- 参数:
cls- the class- 返回:
- true if is private class
-
isPublic
public static boolean isPublic(java.lang.Class<?> cls)
If is public class- 参数:
cls- the class- 返回:
- true if is public class
-
isProtected
public static boolean isProtected(java.lang.Class<?> cls)
If is protected class- 参数:
cls- the class- 返回:
- true if is protected class
-
isAbstract
public static boolean isAbstract(java.lang.Class<?> cls)
If is abstract class- 参数:
cls- the class- 返回:
- true if is abstract class
-
isInterface
public static boolean isInterface(java.lang.Class<?> cls)
If is interface class- 参数:
cls- the class- 返回:
- true if is interface
-
isFinal
public static boolean isFinal(java.lang.Class<?> cls)
If is final class- 参数:
cls- the class- 返回:
- true if is final class
-
-