public abstract class ReflectionUtils extends Object
| Modifier and Type | Class and Description |
|---|---|
static interface |
ReflectionUtils.FieldCallback |
static interface |
ReflectionUtils.FieldFilter |
static interface |
ReflectionUtils.MethodCallback |
static interface |
ReflectionUtils.MethodFilter |
| Modifier and Type | Field and Description |
|---|---|
static ReflectionUtils.FieldFilter |
COPYABLE_FIELDS |
static ReflectionUtils.MethodFilter |
NON_BRIDGED_METHODS |
static ReflectionUtils.MethodFilter |
USER_DECLARED_METHODS |
| Constructor and Description |
|---|
ReflectionUtils() |
| Modifier and Type | Method and Description |
|---|---|
static boolean |
declaresException(Method method,
Class<?> exceptionType) |
static void |
doWithFields(Class<?> clazz,
ReflectionUtils.FieldCallback fc) |
static void |
doWithFields(Class<?> clazz,
ReflectionUtils.FieldCallback fc,
ReflectionUtils.FieldFilter ff) |
static void |
doWithMethods(Class<?> clazz,
ReflectionUtils.MethodCallback mc) |
static void |
doWithMethods(Class<?> clazz,
ReflectionUtils.MethodCallback mc,
ReflectionUtils.MethodFilter mf) |
static Field |
findField(Class<?> clazz,
String name) |
static Field |
findField(Class<?> clazz,
String name,
Class<?> type) |
static Method |
findMethod(Class<?> clazz,
String name) |
static Method |
findMethod(Class<?> clazz,
String name,
Class<?>... paramTypes) |
static Method[] |
getAllDeclaredMethods(Class<?> leafClass) |
static Object |
getField(Field field,
Object target) |
static Method[] |
getUniqueDeclaredMethods(Class<?> leafClass) |
static void |
handleInvocationTargetException(InvocationTargetException ex) |
static void |
handleReflectionException(Exception ex) |
static Object |
invokeJdbcMethod(Method method,
Object target) |
static Object |
invokeJdbcMethod(Method method,
Object target,
Object... args) |
static Object |
invokeMethod(Method method,
Object target) |
static Object |
invokeMethod(Method method,
Object target,
Object... args) |
static boolean |
isCglibRenamedMethod(Method renamedMethod) |
static boolean |
isEqualsMethod(Method method) |
static boolean |
isHashCodeMethod(Method method) |
static boolean |
isObjectMethod(Method method) |
static boolean |
isPublicStaticFinal(Field field) |
static boolean |
isToStringMethod(Method method) |
static void |
makeAccessible(Constructor<?> ctor) |
static void |
makeAccessible(Field field) |
static void |
makeAccessible(Method method) |
static <T> T |
newInstance(Class<T> clazz,
Object... args)
Create a new instance of the specified
Class by invoking
the constructor whose argument list matches the types of the supplied
arguments. |
static void |
rethrowException(Throwable ex) |
static void |
rethrowRuntimeException(Throwable ex) |
static void |
setField(Field field,
Object target,
Object value) |
static void |
shallowCopyFieldState(Object src,
Object dest) |
public static ReflectionUtils.FieldFilter COPYABLE_FIELDS
public static ReflectionUtils.MethodFilter NON_BRIDGED_METHODS
public static ReflectionUtils.MethodFilter USER_DECLARED_METHODS
public static Object invokeJdbcMethod(Method method, Object target) throws Exception
Exceptionpublic static Object invokeJdbcMethod(Method method, Object target, Object... args) throws Exception
Exceptionpublic static void handleReflectionException(Exception ex)
public static void handleInvocationTargetException(InvocationTargetException ex)
public static void rethrowRuntimeException(Throwable ex)
public static void rethrowException(Throwable ex) throws Exception
Exceptionpublic static boolean isPublicStaticFinal(Field field)
public static boolean isEqualsMethod(Method method)
public static boolean isHashCodeMethod(Method method)
public static boolean isToStringMethod(Method method)
public static boolean isObjectMethod(Method method)
public static boolean isCglibRenamedMethod(Method renamedMethod)
public static void makeAccessible(Field field)
public static void makeAccessible(Method method)
public static void makeAccessible(Constructor<?> ctor)
public static void doWithMethods(Class<?> clazz, ReflectionUtils.MethodCallback mc) throws IllegalArgumentException
IllegalArgumentExceptionpublic static void doWithMethods(Class<?> clazz, ReflectionUtils.MethodCallback mc, ReflectionUtils.MethodFilter mf) throws IllegalArgumentException
IllegalArgumentExceptionpublic static Method[] getAllDeclaredMethods(Class<?> leafClass) throws IllegalArgumentException
IllegalArgumentExceptionpublic static Method[] getUniqueDeclaredMethods(Class<?> leafClass) throws IllegalArgumentException
IllegalArgumentExceptionpublic static void doWithFields(Class<?> clazz, ReflectionUtils.FieldCallback fc) throws IllegalArgumentException
IllegalArgumentExceptionpublic static void doWithFields(Class<?> clazz, ReflectionUtils.FieldCallback fc, ReflectionUtils.FieldFilter ff) throws IllegalArgumentException
IllegalArgumentExceptionpublic static void shallowCopyFieldState(Object src, Object dest) throws IllegalArgumentException
IllegalArgumentExceptionpublic static <T> T newInstance(Class<T> clazz, Object... args)
Class by invoking
the constructor whose argument list matches the types of the supplied
arguments.
Provided class must have a public constructor.
clazz - the class to instantiate; never nullargs - the arguments to pass to the constructor, none of which may
be nullnullCopyright © 2022. All rights reserved.