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 interfaceReflectionUtils.FieldCallbackstatic interfaceReflectionUtils.FieldFilterstatic interfaceReflectionUtils.MethodCallbackstatic interfaceReflectionUtils.MethodFilter
-
Field Summary
Fields Modifier and Type Field Description static ReflectionUtils.FieldFilterCOPYABLE_FIELDSstatic ReflectionUtils.MethodFilterNON_BRIDGED_METHODSstatic ReflectionUtils.MethodFilterUSER_DECLARED_METHODS
-
Constructor Summary
Constructors Constructor Description ReflectionUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static booleandeclaresException(Method method, Class<?> exceptionType)static voiddoWithFields(Class<?> clazz, ReflectionUtils.FieldCallback fc)static voiddoWithFields(Class<?> clazz, ReflectionUtils.FieldCallback fc, ReflectionUtils.FieldFilter ff)static voiddoWithMethods(Class<?> clazz, ReflectionUtils.MethodCallback mc)static voiddoWithMethods(Class<?> clazz, ReflectionUtils.MethodCallback mc, ReflectionUtils.MethodFilter mf)static FieldfindField(Class<?> clazz, String name)static FieldfindField(Class<?> clazz, String name, Class<?> type)static MethodfindMethod(Class<?> clazz, String name)static MethodfindMethod(Class<?> clazz, String name, Class<?>... paramTypes)static Method[]getAllDeclaredMethods(Class<?> leafClass)static ObjectgetField(Field field, Object target)static Method[]getUniqueDeclaredMethods(Class<?> leafClass)static voidhandleInvocationTargetException(InvocationTargetException ex)static voidhandleReflectionException(Exception ex)static ObjectinvokeJdbcMethod(Method method, Object target)static ObjectinvokeJdbcMethod(Method method, Object target, Object... args)static ObjectinvokeMethod(Method method, Object target)static ObjectinvokeMethod(Method method, Object target, Object... args)static booleanisCglibRenamedMethod(Method renamedMethod)static booleanisEqualsMethod(Method method)static booleanisHashCodeMethod(Method method)static booleanisObjectMethod(Method method)static booleanisPublicStaticFinal(Field field)static booleanisToStringMethod(Method method)static voidmakeAccessible(Constructor<?> ctor)static voidmakeAccessible(Field field)static voidmakeAccessible(Method method)static <T> TnewInstance(Class<T> clazz, Object... args)Create a new instance of the specifiedClassby invoking the constructor whose argument list matches the types of the supplied arguments.static voidrethrowException(Throwable ex)static voidrethrowRuntimeException(Throwable ex)static voidsetField(Field field, Object target, Object value)static voidshallowCopyFieldState(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 specifiedClassby 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; nevernullargs- the arguments to pass to the constructor, none of which may benull- Returns:
- the new instance; never
null
-
-