|
||||||||||
| 上一个类 下一个类 | 框架 无框架 | |||||||||
| 摘要: 嵌套 | 字段 | 构造方法 | 方法 | 详细信息: 字段 | 构造方法 | 方法 | |||||||||
java.lang.Objectorg.test4j.tools.commons.FieldHelper
public final class FieldHelper
| 构造方法摘要 | |
|---|---|
FieldHelper()
|
|
| 方法摘要 | |
|---|---|
static List<Field> |
getAllFields(Class clazz)
返回类所有的字段(包括父类的) Gets all fields of the given class and all its super-classes. |
static Field |
getField(Class cls,
String name)
test4j method to search for a field starting from the specified class and going up the hierarchy until the field is found or the Object
class is reached. |
static Set<Field> |
getFieldsAssignableFrom(Class clazz,
Type type)
Returns all declared fields of the given class that are assignable from the given type. |
static Set<Field> |
getFieldsOfType(Class clazz,
Type type)
Returns the fields in the given class that have the exact given type. |
static Object |
getFieldValue(Object target,
Field field)
|
static Object |
getFieldValue(Object target,
String fieldName)
Returns the value of the given field (may be private) in the given object 获得对象obj的属性名为fieldname的字段值 |
static Object |
getStaticFieldValue(Class claz,
String fieldName)
|
static void |
setFieldValue(Object target,
Field field,
Object fieldValue)
|
static void |
setFieldValue(Object target,
String fieldName,
Object fieldValue)
设置实例target的字段值 |
| 从类 java.lang.Object 继承的方法 |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| 构造方法详细信息 |
|---|
public FieldHelper()
| 方法详细信息 |
|---|
public static Field getField(Class cls,
String name)
Object
class is reached.
cls - the class from which to startname - the field name
Field found
NoSuchFieldException - if the field cannot be found within the
specified class hierarchy.
public static void setFieldValue(Object target,
String fieldName,
Object fieldValue)
target - fieldName - fieldValue -
public static void setFieldValue(Object target,
Field field,
Object fieldValue)
public static Object getFieldValue(Object target,
String fieldName)
target - The object containing the field, null for static fieldsfieldName - The field, not null
public static Object getStaticFieldValue(Class claz,
String fieldName)
public static Object getFieldValue(Object target,
Field field)
public static List<Field> getAllFields(Class clazz)
clazz - The class
public static Set<Field> getFieldsAssignableFrom(Class clazz,
Type type)
clazz - The class to get fields from, not nulltype - The type, not nullisStatic - True if static fields are to be returned, false for
non-static
public static Set<Field> getFieldsOfType(Class clazz,
Type type)
clazz - The class to get the field from, not nulltype - The type, not nullisStatic - True if static fields are to be returned, false for
non-static
|
||||||||||
| 上一个类 下一个类 | 框架 无框架 | |||||||||
| 摘要: 嵌套 | 字段 | 构造方法 | 方法 | 详细信息: 字段 | 构造方法 | 方法 | |||||||||