public final class FieldUtil extends Object
| 限定符和类型 | 方法和说明 |
|---|---|
static Object |
get(Object object,
Field field)
读取属性值
|
static Object |
get(Object object,
String name)
读取属性值
|
static Field |
getField(Class<?> clazz,
String name)
根据类对象获取字段列表
|
static List<Field> |
getFields(Class<?> clazz)
根据类对象获取字段列表
|
static List<Field> |
getFieldsWithFilter(Class<?> clazz,
Collection<Predicate<Field>> filters)
获取过滤后的字段列表
|
static List<Field> |
getFieldsWithFilter(Class<?> clazz,
Predicate<Field>... filters)
获取过滤后的字段列表
|
static boolean |
isNumberClass(Class<?> fieldType)
判断某个类型是否为数值类
|
static void |
put(Object object,
Field field,
Object value)
设置属性
|
static void |
put(Object object,
String name,
Object value)
设置属性
|
static Object |
read(Object object,
Field field)
读取属性值
|
static Object |
read(Object object,
String name)
读取属性值
|
static void |
write(Object object,
Field field,
Object value)
设置属性
|
static void |
write(Object object,
String name,
Object value)
设置属性
|
public static Object read(Object object, String name) throws IllegalAccessException, InvocationTargetException, IntrospectionException
object - 对象name - 属性名IllegalAccessException - if this Method object
is enforcing Java language access control and the underlying
method is inaccessible.InvocationTargetException - if the underlying method
throws an exception.IntrospectionException - if an exception occurs during introspection.public static Object read(Object object, Field field) throws IllegalAccessException, InvocationTargetException, IntrospectionException
object - 对象field - 字段IllegalAccessException - if this Method object
is enforcing Java language access control and the underlying
method is inaccessible.InvocationTargetException - if the underlying method
throws an exception.IntrospectionException - if an exception occurs during introspection.public static void put(Object object, Field field, Object value)
object - 对象field - 字段value - 属性值public static void put(Object object, String name, Object value)
object - 对象name - 属性名value - 属性值public static void write(Object object, String name, Object value) throws IntrospectionException, InvocationTargetException, IllegalAccessException
object - 对象name - 属性名value - 属性值IntrospectionException - if an exception occurs during
introspection.InvocationTargetException - if the underlying method
throws an exception.IllegalAccessException - if this Method object
is enforcing Java language access control and the underlying
method is inaccessible.public static void write(Object object, Field field, Object value) throws IntrospectionException, InvocationTargetException, IllegalAccessException
object - 对象field - 字段value - 属性值IntrospectionException - if an exception occurs during
introspection.InvocationTargetException - if the underlying method
throws an exception.IllegalAccessException - if this Method object
is enforcing Java language access control and the underlying
method is inaccessible.public static boolean isNumberClass(Class<?> fieldType)
fieldType - 字段类型public static Field getField(Class<?> clazz, String name)
clazz - 类对象public static List<Field> getFieldsWithFilter(Class<?> clazz, Collection<Predicate<Field>> filters)
clazz - 类对象filters - 过滤器列表Copyright © 2021 guerlab. All rights reserved.