Package org.nd4j.common.io
Class ReflectionUtils
- java.lang.Object
-
- org.nd4j.common.io.ReflectionUtils
-
public abstract class ReflectionUtils extends Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
ReflectionUtils.FieldCallback
static interface
ReflectionUtils.FieldFilter
static interface
ReflectionUtils.MethodCallback
static interface
ReflectionUtils.MethodFilter
-
Field Summary
Fields Modifier and Type Field Description static ReflectionUtils.FieldFilter
COPYABLE_FIELDS
static ReflectionUtils.MethodFilter
NON_BRIDGED_METHODS
static ReflectionUtils.MethodFilter
USER_DECLARED_METHODS
-
Constructor Summary
Constructors Constructor Description ReflectionUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method 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 specifiedClass
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)
-
-
-
Field Detail
-
COPYABLE_FIELDS
public static ReflectionUtils.FieldFilter COPYABLE_FIELDS
-
NON_BRIDGED_METHODS
public static ReflectionUtils.MethodFilter NON_BRIDGED_METHODS
-
USER_DECLARED_METHODS
public static ReflectionUtils.MethodFilter USER_DECLARED_METHODS
-
-
Method Detail
-
invokeJdbcMethod
public static Object invokeJdbcMethod(Method method, Object target) throws Exception
- Throws:
Exception
-
invokeJdbcMethod
public static Object invokeJdbcMethod(Method method, Object target, Object... args) throws Exception
- Throws:
Exception
-
handleReflectionException
public static void handleReflectionException(Exception ex)
-
handleInvocationTargetException
public static void handleInvocationTargetException(InvocationTargetException ex)
-
rethrowRuntimeException
public static void rethrowRuntimeException(Throwable ex)
-
rethrowException
public static void rethrowException(Throwable ex) throws Exception
- Throws:
Exception
-
isPublicStaticFinal
public static boolean isPublicStaticFinal(Field field)
-
isEqualsMethod
public static boolean isEqualsMethod(Method method)
-
isHashCodeMethod
public static boolean isHashCodeMethod(Method method)
-
isToStringMethod
public static boolean isToStringMethod(Method method)
-
isObjectMethod
public static boolean isObjectMethod(Method method)
-
isCglibRenamedMethod
public static boolean isCglibRenamedMethod(Method renamedMethod)
-
makeAccessible
public static void makeAccessible(Field field)
-
makeAccessible
public static void makeAccessible(Method method)
-
makeAccessible
public static void makeAccessible(Constructor<?> ctor)
-
doWithMethods
public static void doWithMethods(Class<?> clazz, ReflectionUtils.MethodCallback mc) throws IllegalArgumentException
- Throws:
IllegalArgumentException
-
doWithMethods
public static void doWithMethods(Class<?> clazz, ReflectionUtils.MethodCallback mc, ReflectionUtils.MethodFilter mf) throws IllegalArgumentException
- Throws:
IllegalArgumentException
-
getAllDeclaredMethods
public static Method[] getAllDeclaredMethods(Class<?> leafClass) throws IllegalArgumentException
- Throws:
IllegalArgumentException
-
getUniqueDeclaredMethods
public static Method[] getUniqueDeclaredMethods(Class<?> leafClass) throws IllegalArgumentException
- Throws:
IllegalArgumentException
-
doWithFields
public static void doWithFields(Class<?> clazz, ReflectionUtils.FieldCallback fc) throws IllegalArgumentException
- Throws:
IllegalArgumentException
-
doWithFields
public static void doWithFields(Class<?> clazz, ReflectionUtils.FieldCallback fc, ReflectionUtils.FieldFilter ff) throws IllegalArgumentException
- Throws:
IllegalArgumentException
-
shallowCopyFieldState
public static void shallowCopyFieldState(Object src, Object dest) throws IllegalArgumentException
- Throws:
IllegalArgumentException
-
newInstance
public static <T> T newInstance(Class<T> clazz, Object... args)
Create a new instance of the specifiedClass
by invoking the constructor whose argument list matches the types of the supplied arguments.Provided class must have a public constructor.
- Parameters:
clazz
- the class to instantiate; nevernull
args
- the arguments to pass to the constructor, none of which may benull
- Returns:
- the new instance; never
null
-
-