public class ReflectionUtils
extends java.lang.Object
Constructor and Description |
---|
ReflectionUtils() |
Modifier and Type | Method and Description |
---|---|
static void |
call(java.lang.Object thisObject,
java.lang.String methodName)
Helper method to call a no argument, no return method.
|
static java.lang.Object |
callAny(java.lang.Object thisObject,
java.lang.String methodName,
java.lang.Class<?>[] argTypes,
java.lang.Object[] args)
Helper method to call a multi-argument method having a return.
|
static java.lang.Object |
callAny(java.lang.Object thisObject,
java.lang.String methodName,
java.lang.Object[] args)
Helper method to call a multi-argument method having a return.
|
static java.lang.Object |
callAnyWithoutException(java.lang.Object thisObject,
java.lang.Class<?> objectClass,
java.lang.String methodName,
java.lang.Class<?>[] argTypes,
java.lang.Object[] args)
Helper method to call a multi-argument method having a return without throwing an exception.
|
static java.lang.Object |
callConstructor(java.lang.Class<?> clazz,
java.lang.Class<?>[] argTypes,
java.lang.Object[] args)
Helper method to call a constructor.
|
static java.lang.Object |
callGet(java.lang.Object thisObject,
java.lang.String methodName)
Helper method to call a get method with no argument.
|
static void |
callSet(java.lang.Object thisObject,
java.lang.String methodName,
java.lang.Object value)
Helper method to call a set boolean method.
|
static void |
callSetBoolean(java.lang.Object thisObject,
java.lang.String methodName,
boolean value)
Helper method to call a set boolean method.
|
static void |
callSetInt(java.lang.Object thisObject,
java.lang.String methodName,
int value)
Helper method to call a set boolean method.
|
static java.lang.Object |
callStatic(java.lang.Class<?> thisClass,
java.lang.String methodName,
java.lang.Class<?>[] argTypes,
java.lang.Object[] args)
Helper method to call a multi-argument static class method having a return.
|
static java.lang.Object |
createInstance(java.lang.String className,
java.lang.Class<?>[] types,
java.lang.Object[] args)
Instantiate an object based on the class name.
|
static boolean |
isSubClassOf(java.lang.Object o,
java.lang.String className)
Checks if the instance o is an instance of a subclass of the designated class name.
|
public static void callSetBoolean(java.lang.Object thisObject, java.lang.String methodName, boolean value) throws java.lang.Exception
thisObject
- the instancemethodName
- the method namevalue
- true or falsejava.lang.Exception
- if the method is not found or invocation to the method fails.public static void callSetInt(java.lang.Object thisObject, java.lang.String methodName, int value) throws java.lang.Exception
thisObject
- the instancemethodName
- the method namevalue
- the valuejava.lang.Exception
- if the method is not found or invocation to the method fails.public static void callSet(java.lang.Object thisObject, java.lang.String methodName, java.lang.Object value) throws java.lang.Exception
thisObject
- the instancemethodName
- the method namevalue
- the valuejava.lang.Exception
- if the method is not found or invocation to the method fails.public static java.lang.Object callGet(java.lang.Object thisObject, java.lang.String methodName) throws java.lang.Exception
thisObject
- the instancemethodName
- the method namejava.lang.Exception
- if the method is not found or invocation to the method fails.public static void call(java.lang.Object thisObject, java.lang.String methodName) throws java.lang.Exception
thisObject
- the instancemethodName
- the method namejava.lang.Exception
- if the method is not found or invocation to the method fails.public static java.lang.Object callConstructor(java.lang.Class<?> clazz, java.lang.Class<?>[] argTypes, java.lang.Object[] args) throws java.lang.Exception
clazz
- the classargTypes
- argument Classes for constructor lookup. Must not be null.args
- the argument arrayjava.lang.Exception
- if the method is not found or invocation to the method fails.public static java.lang.Object callAny(java.lang.Object thisObject, java.lang.String methodName, java.lang.Object[] args) throws java.lang.Exception
callAny(Object, methodName, argTypes, args)
.thisObject
- the instancemethodName
- the method nameargs
- the argument array, must not contain null.java.lang.Exception
- if the method is not found or invocation to the method fails.public static java.lang.Object callAny(java.lang.Object thisObject, java.lang.String methodName, java.lang.Class<?>[] argTypes, java.lang.Object[] args) throws java.lang.Exception
thisObject
- the instancemethodName
- the method nameargTypes
- argument Classes for constructor lookup. Must not be null.args
- the argument arrayjava.lang.Exception
- if the method is not found or invocation to the method fails.public static java.lang.Object callAnyWithoutException(java.lang.Object thisObject, java.lang.Class<?> objectClass, java.lang.String methodName, java.lang.Class<?>[] argTypes, java.lang.Object[] args)
thisObject
- the instanceobjectClass
- the class which could find the method namemethodName
- the method nameargTypes
- argument Classes for constructor lookup. Must not be null.args
- the argument arraypublic static java.lang.Object callStatic(java.lang.Class<?> thisClass, java.lang.String methodName, java.lang.Class<?>[] argTypes, java.lang.Object[] args) throws java.lang.Exception
thisClass
- the classmethodName
- the method nameargTypes
- argument Classes for constructor lookup. Must not be null.args
- the argument arrayjava.lang.Exception
- if the method is not found or invocation to the method fails.public static java.lang.Object createInstance(java.lang.String className, java.lang.Class<?>[] types, java.lang.Object[] args)
className
- the class nametypes
- the class types for the constructorargs
- the constructor valuespublic static boolean isSubClassOf(java.lang.Object o, java.lang.String className)
o
- the instance to checkclassName
- the class name to check