public class BeanUtils extends Object
| 构造器和说明 |
|---|
BeanUtils() |
| 限定符和类型 | 方法和说明 |
|---|---|
static boolean |
canReadField(Class<?> target,
String property)
测试是否支持 Field 方法读
|
static boolean |
canReadProperty(Class<?> target,
String property)
测试是否支持 readProperty 方法, 返回 true 表示可以进行读取操作
|
static boolean |
canWriteField(Class<?> target,
String property)
测试是否支持 Field 方法写
|
static boolean |
canWriteProperty(Class<?> target,
String property)
测试是否支持 writeProperty 方法, 返回 true 表示可以进行写入操作
|
static void |
copyProperties(Object dest,
Object orig) |
static void |
copyProperty(Object dest,
Object orig,
String property) |
static Property |
createMapPropertyFunc(String property) |
static List<Method> |
findALLMethods(Class<?> target)
获取类定义的方法和继承父类中定义的方法以及父类的父类(子类的重写方法也会被返回)
|
static Map<String,Field> |
getALLFields(Class<?> target)
获取类定义的字段和继承父类中定义的字段以及父类的父类(子类重新定义同名字段也会被列入集合)
|
static Object |
getDefaultValue(Class<?> returnType)
获取指定类型的默认值
|
static Object[] |
getDefaultValues(Class<?>[] paramArray) |
static Field |
getField(Class<?> target,
String field)
查找一个可操作的字段
|
static Map<String,Property> |
getFieldFunc(Class<?> target)
获取属性名集合,被包含的属性可能有些只是只读属性,有些是只写属性。
|
static Property |
getFieldFunc(Class<?> target,
String property)
获取属性名集合,被包含的属性可能有些只是只读属性,有些是只写属性。
|
static Map<String,Field> |
getFieldMap(Class<?> target,
String field)
查找字段
|
static List<Field> |
getFields(Class<?> type)
查找一个可操作的字段列表
|
static Class<?> |
getFieldType(Class<?> target,
String property) |
static Method |
getMethod(Class<?> target,
String name,
Class<?>[] paramType)
查找一个可操作的方法
|
static List<Method> |
getMethods(Class<?> type)
查找一个可操作的方法列表
|
static List<String> |
getProperties(Class<?> target)
获取属性名集合,被包含的属性可能有些只是只读属性,有些是只写属性。
|
static Map<String,Annotation[]> |
getPropertyAnnotation(Class<?> target)
获取属性名集合,被包含的属性可能有些只是只读属性,有些是只写属性。
|
static Annotation[] |
getPropertyAnnotation(Class<?> target,
String property)
获取属性名集合,被包含的属性可能有些只是只读属性,有些是只写属性。
|
static Annotation[] |
getPropertyAnnotation(Property property)
获取属性名集合,被包含的属性可能有些只是只读属性,有些是只写属性。
|
static PropertyDescriptor[] |
getPropertyDescriptors(Class<?> defineType)
获取属性名集合,被包含的属性可能有些只是只读属性,有些是只写属性。
|
static Map<String,Property> |
getPropertyFunc(Class<?> target)
获取属性名集合,被包含的属性可能有些只是只读属性,有些是只写属性。
|
static Property |
getPropertyFunc(Class<?> target,
String property)
获取属性名集合,被包含的属性可能有些只是只读属性,有些是只写属性。
|
static Map<String,Class<?>> |
getPropertyType(Class<?> target) |
static Class<?> |
getPropertyType(Class<?> target,
String property) |
static Class<?> |
getPropertyType(Property property) |
static Method |
getReadMethod(Class<?> target,
String property)
获取一个属性的读取方法
|
static Method |
getWriteMethod(Class<?> target,
String property)
获取一个属性的写入方法
|
static boolean |
hasField(Class<?> target,
String property)
测试是否具有 fieldName 所表示的字段, 无论是读或写方法只要存在一个就表示存在该属性
|
static boolean |
hasProperty(Class<?> target,
String property)
测试是否具有 property 所表示的属性, 无论是读或写方法只要存在一个就表示存在该属性
|
static Object |
invokeMethod(Object target,
String name,
Object... objects)
该方法的作用是反射的形式调用目标的方法。
|
static Object |
readField(Object object,
String property)
执行字段读取
|
static Object |
readProperty(Object object,
String property)
执行属性读取
|
static String |
toProperty(SFunction<?> property) |
static boolean |
writeField(Object object,
String property,
Object value)
执行字段注入,除了注入int,short,long,等基本类型之外该方法还支持注入枚举类型。
|
static boolean |
writeProperty(Object object,
String property,
Object value)
执行属性注入,除了注入int,short,long,等基本类型之外该方法还支持注入枚举类型。
|
public static Method getMethod(Class<?> target, String name, Class<?>[] paramType)
public static Object invokeMethod(Object target, String name, Object... objects) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException
target - 被调用的对象name - 要调用的反射方法名。objects - 参数列表IllegalArgumentExceptionIllegalAccessExceptionInvocationTargetExceptionpublic static Map<String,Field> getALLFields(Class<?> target)
public static List<Method> findALLMethods(Class<?> target)
public static List<String> getProperties(Class<?> target)
public static Annotation[] getPropertyAnnotation(Class<?> target, String property)
public static Annotation[] getPropertyAnnotation(Property property)
public static Map<String,Annotation[]> getPropertyAnnotation(Class<?> target)
public static PropertyDescriptor[] getPropertyDescriptors(Class<?> defineType)
public static Property getPropertyFunc(Class<?> target, String property)
public static Map<String,Property> getPropertyFunc(Class<?> target)
public static Property getFieldFunc(Class<?> target, String property)
public static Map<String,Property> getFieldFunc(Class<?> target)
public static boolean canReadProperty(Class<?> target, String property)
public static boolean canWriteProperty(Class<?> target, String property)
public static boolean canWriteField(Class<?> target, String property)
public static boolean hasProperty(Class<?> target, String property)
public static boolean hasField(Class<?> target, String property)
public static boolean writeProperty(Object object, String property, Object value)
public static boolean writeField(Object object, String property, Object value)
Copyright © 2022. All rights reserved.