Package cn.toutatis.xvoid.toolkit.clazz
Object ReflectToolkit
-
- All Implemented Interfaces:
public class ReflectToolkitReflect toolkit 反射相关工具
-
-
Field Summary
Fields Modifier and Type Field Description public final static StringIS_FIELD_LAMBDApublic final static StringGET_FIELD_LAMBDApublic final static StringSET_FIELD_LAMBDApublic final static ReflectToolkitINSTANCE
-
Method Summary
Modifier and Type Method Description final static <T extends Any> TconvertMapToEntity(Map<String, Object> map, Class<T> entityClass)Convert a map to entity 将Map类型对象转换为Java实体类 final static BooleanisWrapperClass(Class<?> clazz)Is wrapper class 判断是否为包装类型 final static List<Field>getAllFields(Class<?> clazz, Boolean includeSuper)Get all fields 获取一个类的所有字段包括父级 final static UnitsetObjectField(Object obj, Field field, Object value)Set object field 设置对象字段 final static StringconvertGetterToFieldName(String getterName)Convert getter to field name 将getter方法名转换为字段名 final static ArrayList<Method>getGetterMethods(Class<?> clazz)获取一个类的所有getter方法 final static StringgetFieldGetterMethodName(Field field)获取字段的getter方法名 final static StringgetFieldGetterMethodName(String field)获取字段的getter方法名 final static ObjectgetFieldValue(Object obj, Field field)获取字段的值 final static FieldrecursionGetField(Class<?> clazz, String fieldName)递归获取字段 final static FieldrecursionGetField(Class<?> clazz, String fieldName, Boolean includeSuper)递归获取字段 final static FieldrecursionGetFieldExcludeSuper(Class<?> clazz, String fieldName)递归获取字段,不包含父类 -
-
Method Detail
-
convertMapToEntity
final static <T extends Any> T convertMapToEntity(Map<String, Object> map, Class<T> entityClass)
Convert a map to entity 将Map类型对象转换为Java实体类
- Parameters:
map- 需要转换的图entityClass- 实体类Class- Returns:
转换实体类
-
isWrapperClass
final static Boolean isWrapperClass(Class<?> clazz)
Is wrapper class 判断是否为包装类型
- Parameters:
clazz- class信息- Returns:
是否为包装类
-
getAllFields
final static List<Field> getAllFields(Class<?> clazz, Boolean includeSuper)
Get all fields 获取一个类的所有字段包括父级
- Parameters:
clazz- 类对象includeSuper- 包含父级- Returns:
所有Field字段
-
setObjectField
final static Unit setObjectField(Object obj, Field field, Object value)
Set object field 设置对象字段
- Parameters:
obj- 对象field- 字段value- 值
-
convertGetterToFieldName
final static String convertGetterToFieldName(String getterName)
Convert getter to field name 将getter方法名转换为字段名
- Parameters:
getterName- getter方法名- Returns:
字段名
-
getGetterMethods
final static ArrayList<Method> getGetterMethods(Class<?> clazz)
获取一个类的所有getter方法
-
getFieldGetterMethodName
final static String getFieldGetterMethodName(Field field)
获取字段的getter方法名
-
getFieldGetterMethodName
final static String getFieldGetterMethodName(String field)
获取字段的getter方法名
-
getFieldValue
final static Object getFieldValue(Object obj, Field field)
获取字段的值
-
recursionGetField
final static Field recursionGetField(Class<?> clazz, String fieldName)
递归获取字段
- Parameters:
clazz- 类fieldName- 字段名
-
recursionGetField
final static Field recursionGetField(Class<?> clazz, String fieldName, Boolean includeSuper)
递归获取字段
- Parameters:
clazz- 类fieldName- 字段名includeSuper- 是否包含父类
-
recursionGetFieldExcludeSuper
final static Field recursionGetFieldExcludeSuper(Class<?> clazz, String fieldName)
递归获取字段,不包含父类
- Parameters:
clazz- 类fieldName- 字段名
-
-
-
-