public class BeanUtil extends Object
| 限定符和类型 | 字段和说明 |
|---|---|
static Pattern |
ARRAY_PATTERN |
protected static org.slf4j.Logger |
logger
定义日志
|
| 限定符和类型 | 方法和说明 |
|---|---|
static void |
batchSetProperties(Collection voList,
String[] properties,
Object[] values,
boolean autoConvertType) |
static void |
batchSetProperties(Collection voList,
String[] properties,
Object[] values,
boolean autoConvertType,
boolean forceUpdate) |
static int |
compare(Object target,
Object compared) |
static Object |
convertArray(Object values,
String typeName) |
static String |
convertBoolean(String var) |
static Object |
convertType(Object value,
int typeValue,
String typeName) |
static Object |
convertType(TypeHandler typeHandler,
Object value,
int typeValue,
String typeName,
Class genericType) |
static boolean |
equals(Object target,
Object compared) |
static boolean |
equalsIgnoreType(Object target,
Object compared,
boolean ignoreCase) |
static Object |
getArrayIndexValue(Object result,
int index) |
static List<TableCascadeModel> |
getCascadeModels(Class entityClass) |
static Object |
getComplexProperty(Object bean,
String property) |
static Class |
getEntityClass(Class entityClass) |
static KeyAndIndex |
getKeyAndIndex(String property) |
static Method |
getMethod(Class beanClass,
String methodName,
int argLength) |
static Object |
getProperty(Object bean,
String property) |
static Object |
invokeMethod(Object bean,
String methodName,
Object[] args) |
static boolean |
isBaseDataType(Class clazz) |
static void |
loadAllMapping(List mainEntities,
List itemEntities,
TableCascadeModel cascadeModel) |
static void |
mappingSetProperties(Collection voList,
String[] properties,
List<Object[]> values,
int[] index,
boolean autoConvertType) |
static void |
mappingSetProperties(Collection voList,
String[] properties,
List<Object[]> values,
int[] index,
boolean autoConvertType,
boolean forceUpdate) |
static Method[] |
matchGetMethods(Class voClass,
String... props) |
static Integer[] |
matchMethodsType(Class voClass,
String... properties) |
static String[] |
matchSetMethodNames(Class voClass) |
static Method[] |
matchSetMethods(Class voClass,
String... props)
update 2019-09-05 优化匹配方式,修复setIsXXX的错误
update 2020-04-09 支持setXXX()并返回对象本身,适配链式操作
update 2021-03-12 支持property中含下划线跟对象属性进行匹配
|
static List<Object[]> |
reflectBeansToInnerAry(List dataSet,
String[] properties,
Object[] defaultValues,
ReflectPropsHandler reflectPropsHandler) |
static List |
reflectBeansToList(List datas,
String[] props) |
static List |
reflectBeansToList(List datas,
String[] properties,
ReflectPropsHandler reflectPropsHandler) |
static Object[] |
reflectBeanToAry(Object serializable,
String[] properties) |
static Object[] |
reflectBeanToAry(Object serializable,
String[] properties,
Object[] defaultValues,
ReflectPropsHandler reflectPropsHandler) |
static List |
reflectListToBean(TypeHandler typeHandler,
Collection datas,
int[] indexs,
String[] properties,
Class voClass) |
static List |
reflectListToBean(TypeHandler typeHandler,
Collection datas,
int[] indexs,
String[] properties,
Class voClass,
boolean autoConvertType) |
static List |
reflectListToBean(TypeHandler typeHandler,
Collection datas,
String[] properties,
Class voClass) |
static <T extends Serializable> |
reflectRowToBean(TypeHandler typeHandler,
Method[] realMethods,
int[] methodTypeValues,
String[] methodTypes,
Class[] genericTypes,
List rowList,
int[] indexs,
String[] properties,
Class<T> voClass) |
static void |
setProperty(Object bean,
String property,
Object value) |
static Object[] |
sliceToArray(List datas,
String propertyName) |
static <T extends Serializable> |
wrapEntities(TypeHandler typeHandler,
EntityMeta entityMeta,
Class<T> voClass,
Object... ids) |
protected static final org.slf4j.Logger logger
public static final Pattern ARRAY_PATTERN
public static Method[] matchSetMethods(Class voClass, String... props)
voClass - props - public static Method[] matchGetMethods(Class voClass, String... props)
voClass - props - public static Integer[] matchMethodsType(Class voClass, String... properties)
voClass - properties - public static Object invokeMethod(Object bean, String methodName, Object[] args) throws Exception
bean - methodName - args - Exceptionpublic static boolean equalsIgnoreType(Object target, Object compared, boolean ignoreCase)
target - compared - ignoreCase - public static Object convertType(Object value, int typeValue, String typeName) throws Exception
value - typeValue - DataType.getType(typeName) 注意typeName不用转小写typeName - getParameterTypes()[0].getTypeName() 没有转大小写Exceptionpublic static Object convertType(TypeHandler typeHandler, Object value, int typeValue, String typeName, Class genericType) throws Exception
typeHandler - value - typeValue - typeName - getTypeName()没有转大小写genericType - 泛型类型Exceptionpublic static List reflectBeansToList(List datas, String[] props) throws RuntimeException
datas - props - RuntimeExceptionpublic static Object[] sliceToArray(List datas, String propertyName) throws RuntimeException
datas - propertyName - ExceptionRuntimeExceptionpublic static List reflectBeansToList(List datas, String[] properties, ReflectPropsHandler reflectPropsHandler) throws RuntimeException
datas - properties - reflectPropsHandler - RuntimeExceptionpublic static Object[] reflectBeanToAry(Object serializable, String[] properties, Object[] defaultValues, ReflectPropsHandler reflectPropsHandler)
serializable - properties - defaultValues - reflectPropsHandler - public static List<Object[]> reflectBeansToInnerAry(List dataSet, String[] properties, Object[] defaultValues, ReflectPropsHandler reflectPropsHandler)
dataSet - properties - defaultValues - reflectPropsHandler - public static List reflectListToBean(TypeHandler typeHandler, Collection datas, String[] properties, Class voClass)
public static List reflectListToBean(TypeHandler typeHandler, Collection datas, int[] indexs, String[] properties, Class voClass) throws RuntimeException
typeHandler - datas - indexs - properties - voClass - RuntimeExceptionpublic static List reflectListToBean(TypeHandler typeHandler, Collection datas, int[] indexs, String[] properties, Class voClass, boolean autoConvertType)
typeHandler - datas - indexs - properties - voClass - autoConvertType - public static <T extends Serializable> T reflectRowToBean(TypeHandler typeHandler, Method[] realMethods, int[] methodTypeValues, String[] methodTypes, Class[] genericTypes, List rowList, int[] indexs, String[] properties, Class<T> voClass)
public static void batchSetProperties(Collection voList, String[] properties, Object[] values, boolean autoConvertType)
public static void batchSetProperties(Collection voList, String[] properties, Object[] values, boolean autoConvertType, boolean forceUpdate)
voList - properties - values - autoConvertType - forceUpdate - public static void mappingSetProperties(Collection voList, String[] properties, List<Object[]> values, int[] index, boolean autoConvertType) throws RuntimeException
voList - properties - values - index - autoConvertType - RuntimeExceptionpublic static void mappingSetProperties(Collection voList, String[] properties, List<Object[]> values, int[] index, boolean autoConvertType, boolean forceUpdate) throws RuntimeException
RuntimeExceptionpublic static Method getMethod(Class beanClass, String methodName, int argLength)
beanClass - methodName - argLength - public static boolean isBaseDataType(Class clazz)
clazz - public static void setProperty(Object bean, String property, Object value) throws RuntimeException
bean - property - value - RuntimeExceptionpublic static Object getProperty(Object bean, String property) throws RuntimeException
bean - property - RuntimeExceptionpublic static Object getComplexProperty(Object bean, String property) throws RuntimeException
bean - property - RuntimeExceptionpublic static <T extends Serializable> List<T> wrapEntities(TypeHandler typeHandler, EntityMeta entityMeta, Class<T> voClass, Object... ids)
T - typeHandler - entityMeta - voClass - ids - public static Object convertArray(Object values, String typeName)
values - typeName - public static void loadAllMapping(List mainEntities, List itemEntities, TableCascadeModel cascadeModel) throws Exception
mainEntities - itemEntities - cascadeModel - Exceptionpublic static List<TableCascadeModel> getCascadeModels(Class entityClass)
entityClass - public static KeyAndIndex getKeyAndIndex(String property)
Copyright © 2023. All rights reserved.