public class ReflectHelper extends Object
| 构造器和说明 |
|---|
ReflectHelper() |
| 限定符和类型 | 方法和说明 |
|---|---|
static void |
addMethod(Object parent,
Object sub,
String fieldName,
Class subClass)
Add method.
|
static String |
getCollectionsInfo(List<?> list)
Gets collections info.
|
static Object |
getMethod(Object obj,
String field)
Gets method.
|
static String |
getObjectInfo(Object obj)
Gets object info.
|
static <T> T |
newInstance(Class<?> commandClass)
通过反射创建实例
|
static <T> T |
newInstance(String className)
通过反射创建实例
|
static void |
setMethod(Class cls,
String fieldName,
Object value,
Class fieldType)
Sets method.
|
static void |
setMethod(Object obj,
String fieldName,
Object value)
Sets method.
|
static void |
setMethod(Object obj,
String fieldName,
Object value,
Class fieldType)
Sets method.
|
static void |
setValue(Object obj,
Field field,
String value) |
public static void setMethod(Object obj, String fieldName, Object value)
obj - the objfieldName - the field namevalue - the valuepublic static void setMethod(Object obj, String fieldName, Object value, Class fieldType)
obj - the objfieldName - the field namevalue - the valuefieldType - the field classpublic static void setMethod(Class cls, String fieldName, Object value, Class fieldType)
cls - the clsfieldName - the field namevalue - the valuefieldType - the field classpublic static void addMethod(Object parent, Object sub, String fieldName, Class subClass)
parent - the parentsub - the subfieldName - the field namesubClass - the sub classpublic static Object getMethod(Object obj, String field)
obj - the objfield - the fieldpublic static String getObjectInfo(Object obj)
obj - the objpublic static String getCollectionsInfo(List<?> list)
list - the listpublic static <T> T newInstance(String className)
T - the type parameterclassName - the class namepublic static <T> T newInstance(Class<?> commandClass)
T - the type parametercommandClass - the classCopyright © 2017. All rights reserved.