public class ReflectionUtil
extends java.lang.Object
| Constructor and Description |
|---|
ReflectionUtil() |
| Modifier and Type | Method and Description |
|---|---|
static int |
arity(java.lang.reflect.Constructor<?> constructor) |
static int |
arity(java.lang.reflect.Method method) |
static java.lang.Class<?> |
classForName(java.lang.String name)
Load a class
|
static java.util.List<java.lang.reflect.Method> |
getAllPublicInstanceMethods(java.lang.Class<?> clazz,
boolean includeInheritedClasses) |
static java.util.List<java.lang.reflect.Method> |
getAllPublicInstanceMethods(java.lang.Class<?> clazz,
java.lang.String methodName,
java.lang.Integer arity,
boolean includeInheritedClasses) |
static java.util.List<java.lang.reflect.Method> |
getAllPublicMethods(java.lang.Class<?> clazz,
java.lang.String methodName,
java.lang.Integer arity,
boolean includeInheritedClasses,
boolean addInstanceMethods,
boolean addStaticMethods,
boolean addTransientMethods,
boolean addDeprecatedMethods) |
static java.util.List<java.lang.reflect.Method> |
getAllPublicStaticMethods(java.lang.Class<?> clazz,
boolean includeInheritedClasses) |
static java.util.List<java.lang.reflect.Method> |
getAllPublicStaticMethods(java.lang.Class<?> clazz,
java.lang.String methodName,
java.lang.Integer arity,
boolean includeInheritedClasses) |
static java.lang.String |
getAttributeNameByGetter(java.lang.reflect.Method getter) |
static java.lang.reflect.Method |
getBeanGetterMethod(java.lang.Class<?> clazz,
java.lang.String propertyName) |
static java.util.List<java.lang.reflect.Method> |
getBeanGetterMethods(java.lang.Class<?> type) |
static java.util.List<java.lang.String> |
getBeanGetterProperties(java.lang.Class<?> type) |
static java.lang.String |
getBeanPropertyName(java.lang.reflect.Method method) |
static java.lang.reflect.Method |
getBeanSetterMethod(java.lang.Class<?> clazz,
java.lang.String propertyName) |
static java.util.List<java.lang.reflect.Method> |
getBeanSetterMethods(java.lang.Class<?> type) |
static java.util.List<java.lang.String> |
getBeanSetterProperties(java.lang.Class<?> type) |
static java.lang.reflect.Constructor<?> |
getDefaultConstructor(java.lang.Class<?> type) |
static java.lang.Class<?> |
getGenericType(java.lang.Class<?> clazz,
int idx)
Gets the type of a generic parameter of a class that has a generic super class.
|
static java.util.List<java.lang.reflect.Constructor<?>> |
getPublicConstructors(java.lang.Class<?> type,
int numArgs) |
static java.lang.reflect.Field |
getPublicInstanceField(java.lang.Class<?> clazz,
java.lang.String name) |
static java.lang.reflect.Field |
getPublicStaticField(java.lang.Class<?> clazz,
java.lang.String name) |
static java.lang.Class<?> |
getSuperclass(java.lang.Class<?> type) |
static java.lang.reflect.Type[] |
getTypeArguments(java.lang.reflect.Type type)
Returns the type arguments of a parameterized type
if the given type is not parameterized, null is returned
|
static boolean |
hasDefaultConstructor(java.lang.Class<?> type) |
static boolean |
isBeanGetterMethod(java.lang.reflect.Method method) |
static boolean |
isBeanSetterMethod(java.lang.reflect.Method method) |
static boolean |
isDeprecated(java.lang.reflect.Method method) |
static boolean |
isGetter(java.lang.reflect.Method method)
Checks if a method is a getter method
|
static boolean |
isPublic(java.lang.reflect.Field field) |
static boolean |
isPublic(java.lang.reflect.Method method) |
static boolean |
isSetter(java.lang.reflect.Method method)
Checks if a method is a setter method
|
static boolean |
isStatic(java.lang.reflect.Field field) |
static boolean |
isStatic(java.lang.reflect.Method method) |
static boolean |
isTransient(java.lang.reflect.Method method) |
static java.lang.Class<?> |
nearestSuperClass(java.lang.Class<?> c1,
java.lang.Class<?> c2)
Finds the nearest super class of two classes
|
static java.lang.Class<?> |
nearestSuperClass(java.util.Collection<java.lang.Class<?>> classes)
Finds the nearest super class of a collection of classes
|
public static java.lang.Class<?> classForName(java.lang.String name)
name - the class's namepublic static boolean isGetter(java.lang.reflect.Method method)
method - the method to checkpublic static boolean isSetter(java.lang.reflect.Method method)
method - the method to checkpublic static java.lang.String getAttributeNameByGetter(java.lang.reflect.Method getter)
public static java.lang.reflect.Type[] getTypeArguments(java.lang.reflect.Type type)
type - a typepublic static java.lang.Class<?> nearestSuperClass(java.lang.Class<?> c1,
java.lang.Class<?> c2)
c1 - a classc2 - another classpublic static java.lang.Class<?> nearestSuperClass(java.util.Collection<java.lang.Class<?>> classes)
classes - a collection of classespublic static java.lang.Class<?> getGenericType(java.lang.Class<?> clazz,
int idx)
clazz - a class having a generic super classidx - number of the parameterpublic static java.lang.Class<?> getSuperclass(java.lang.Class<?> type)
public static boolean hasDefaultConstructor(java.lang.Class<?> type)
public static java.lang.reflect.Constructor<?> getDefaultConstructor(java.lang.Class<?> type)
public static java.util.List<java.lang.reflect.Constructor<?>> getPublicConstructors(java.lang.Class<?> type,
int numArgs)
public static java.util.List<java.lang.reflect.Method> getBeanGetterMethods(java.lang.Class<?> type)
public static java.util.List<java.lang.String> getBeanGetterProperties(java.lang.Class<?> type)
public static boolean isBeanGetterMethod(java.lang.reflect.Method method)
public static java.util.List<java.lang.reflect.Method> getBeanSetterMethods(java.lang.Class<?> type)
public static java.util.List<java.lang.String> getBeanSetterProperties(java.lang.Class<?> type)
public static boolean isBeanSetterMethod(java.lang.reflect.Method method)
public static java.lang.String getBeanPropertyName(java.lang.reflect.Method method)
public static java.lang.reflect.Method getBeanGetterMethod(java.lang.Class<?> clazz,
java.lang.String propertyName)
public static java.lang.reflect.Method getBeanSetterMethod(java.lang.Class<?> clazz,
java.lang.String propertyName)
public static java.lang.reflect.Field getPublicStaticField(java.lang.Class<?> clazz,
java.lang.String name)
public static java.lang.reflect.Field getPublicInstanceField(java.lang.Class<?> clazz,
java.lang.String name)
public static int arity(java.lang.reflect.Constructor<?> constructor)
public static int arity(java.lang.reflect.Method method)
public static boolean isStatic(java.lang.reflect.Method method)
public static boolean isPublic(java.lang.reflect.Method method)
public static boolean isDeprecated(java.lang.reflect.Method method)
public static boolean isTransient(java.lang.reflect.Method method)
public static boolean isStatic(java.lang.reflect.Field field)
public static boolean isPublic(java.lang.reflect.Field field)
public static java.util.List<java.lang.reflect.Method> getAllPublicInstanceMethods(java.lang.Class<?> clazz,
boolean includeInheritedClasses)
public static java.util.List<java.lang.reflect.Method> getAllPublicInstanceMethods(java.lang.Class<?> clazz,
java.lang.String methodName,
java.lang.Integer arity,
boolean includeInheritedClasses)
public static java.util.List<java.lang.reflect.Method> getAllPublicStaticMethods(java.lang.Class<?> clazz,
boolean includeInheritedClasses)
public static java.util.List<java.lang.reflect.Method> getAllPublicStaticMethods(java.lang.Class<?> clazz,
java.lang.String methodName,
java.lang.Integer arity,
boolean includeInheritedClasses)
public static java.util.List<java.lang.reflect.Method> getAllPublicMethods(java.lang.Class<?> clazz,
java.lang.String methodName,
java.lang.Integer arity,
boolean includeInheritedClasses,
boolean addInstanceMethods,
boolean addStaticMethods,
boolean addTransientMethods,
boolean addDeprecatedMethods)