public class FieldUtils extends Object
Modifier and Type | Class and Description |
---|---|
static class |
FieldUtils.FieldUtilsException
类异常
|
static class |
FieldUtils.InvokeResult
内部类
方法执行的返回值封装类,此类除了重写方法以外的唯一公共接口
|
Modifier and Type | Method and Description |
---|---|
static void |
allNonNull(Object... all)
只要传入的参数中任意一个出现了null则会抛出空指针异常
|
static Class |
basicToBox(Class type)
将基础数据类型封装为其对应的封装类
|
static Field |
getField(Class objectClass,
String fieldName)
获取类指定字段对象
|
static Method |
getFieldGetter(Class<?> whereIn,
Field field)
获取字段的getter方法
|
static Method |
getFieldGetter(Class<?> whereIn,
String fieldName)
获取字段的getter方法,单层级
|
static Method |
getFieldGetter(Object obj,
String fieldName)
获取字段的getter方法
|
static Field[] |
getFields(Class type,
boolean withSuper)
获取类中全部的字段
|
static Method |
getFieldSetter(Class<?> whereIn,
Field field)
获取字段的setter方法
|
static Method |
getFieldSetter(Class<?> whereIn,
String fieldName)
获取字段的setter方法
|
static Method |
getFieldSetter(Object obj,
String fieldName)
获取字段的setter方法
|
static Stream<Field> |
getFieldsStream(Class type,
boolean withSuper)
获取类中全部的字段
|
static String |
getMethodNameWithoutGetterAndSetter(Method method)
获取方法名,如果是个getter或setter规则方法名则移除get或set并开头小写
|
static String |
headLower(String str)
单词开头小写
|
static String |
headUpper(String str)
单词开头大写
|
static boolean |
isBasic(Class type)
判断类型是否为基础数据类型或封装类
|
static boolean |
isChild(Class child,
Class findFather)
判断一个Class对象是否为另一个对象的实现类
|
static boolean |
notInterfaceAndAbstract(Class<?> clazz)
判断一个类是不是不是抽象类也不是接口
|
static Object |
objectGetter(Object t,
String fieldName)
通过对象的getter获取字段数值
支持类似“user.child”这种多层级的获取方式
获取的字段必须有其对应的公共get方法
|
public static Method getFieldGetter(Class<?> whereIn, String fieldName)
whereIn
- fieldName
- public static Method getFieldGetter(Class<?> whereIn, Field field)
whereIn
- 字段所在类field
- 字段public static Method getFieldGetter(Object obj, String fieldName)
obj
- fieldName
- public static Method getFieldSetter(Class<?> whereIn, String fieldName)
whereIn
- fieldName
- public static Method getFieldSetter(Class<?> whereIn, Field field)
whereIn
- field
- public static Method getFieldSetter(Object obj, String fieldName)
obj
- fieldName
- public static Object objectGetter(Object t, String fieldName) throws IllegalAccessException, NoSuchMethodException, InvocationTargetException
t
- fieldName
- IllegalAccessException
NoSuchMethodException
InvocationTargetException
public static Field getField(Class objectClass, String fieldName)
objectClass
- 类的class对象fieldName
- 字段名称public static Field[] getFields(Class type, boolean withSuper)
type
- Class对象withSuper
- 是否获取父类中的全部public static Stream<Field> getFieldsStream(Class type, boolean withSuper)
type
- Class对象withSuper
- 是否获取父类中的全部public static boolean isChild(Class child, Class findFather)
child
- 进行寻找的子类findFather
- 被寻找的父类public static boolean isBasic(Class type)
type
- public static void allNonNull(Object... all)
all
- public static boolean notInterfaceAndAbstract(Class<?> clazz)
Copyright © 2020. All rights reserved.