Package com.jbstrap.core.utils
Class ReflectionUtils
java.lang.Object
com.jbstrap.core.utils.ReflectionUtils
- Since:
- 4.0
- Author:
- JBStrap
-
Method Summary
-
Method Details
-
setField
- Parameters:
obj
- The object where the value will be setfieldName
- The name of the field, that will have its value setdata
- The value to be set- Throws:
IllegalStateException
- If the field value couldn't be setNullPointerException
- If the object or field name was defined asnull
-
getField
- Type Parameters:
T
- The type of the returned value- Parameters:
obj
- The source objectfieldName
- The name of the field- Returns:
- The field value
- Throws:
NullPointerException
- If the specified object value isnull
IllegalStateException
- If the field value was not found
-
invoke
public static Object invoke(Object obj, String methodName, Object... params) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException - Parameters:
obj
- The object where the method will be usedmethodName
- The name of the methodparams
- The method parameters- Returns:
- The methods return value
- Throws:
NoSuchMethodException
- If the specified method was not foundIllegalAccessException
- If the invoking code has no access rights to the specified methodInvocationTargetException
- If the target couldn't be found
-
calledFromMethod
- Parameters:
methodName
- The name of the method- Returns:
true
, if the method is in the chain, otherwisefalse
-