public class ReflectionUtils extends Object
Constructor and Description |
---|
ReflectionUtils() |
Modifier and Type | Method and Description |
---|---|
static Object |
callMethod(Object source,
String method)
Call method.
|
static Object |
getField(Object source,
String field)
Get the specified field name in the object source
|
static <T> T |
getFirstWith(Object from,
Class<?> clazz,
Class<T> searchingFor)
Get the first field which have the searching for class type
|
static Object |
getPrivateField(Object object,
String field) |
static Class<?> |
getSubClassWithName(Class<?> clazz,
String name) |
static void |
setField(Object src,
String fieldName,
Object value) |
public static Object getPrivateField(Object object, String field) throws Exception
Exception
public static Object getField(Object source, String field)
source
- where we will find the fieldfield
- the name of the fieldpublic static Object callMethod(Object source, String method)
source
- the object where we want to run the methodmethod
- the name of the method to callpublic static <T> T getFirstWith(Object from, Class<?> clazz, Class<T> searchingFor) throws Exception
from
- the object where we will try to find the fieldclazz
- the class that have to define the fieldsearchingFor
- the class of the required fieldException
- if something gone wrong