类 BeanUtil
- java.lang.Object
-
- org.sagacity.sqltoy.utils.BeanUtil
-
public class BeanUtil extends Object
- 版本:
- v1.0,Date:2008-11-10
- 作者:
- zhongxuchen
-
-
字段概要
字段 修饰符和类型 字段 说明 static PatternARRAY_PATTERNprotected static org.slf4j.Loggerlogger定义日志
-
方法概要
所有方法 静态方法 具体方法 修饰符和类型 方法 说明 static voidbatchSetProperties(Collection voList, String[] properties, Object[] values, boolean autoConvertType)static voidbatchSetProperties(Collection voList, String[] properties, Object[] values, boolean autoConvertType, boolean forceUpdate)static intcompare(Object target, Object compared)static ObjectconvertArray(Object values, String typeName)static StringconvertBoolean(String var)static ObjectconvertType(Object value, int typeValue, String typeName)static ObjectconvertType(TypeHandler typeHandler, Object value, int typeValue, String typeName, Class genericType)static booleanequals(Object target, Object compared)static booleanequalsIgnoreType(Object target, Object compared, boolean ignoreCase)static ObjectgetAryPropValue(Object result, int index)static List<TableCascadeModel>getCascadeModels(Class entityClass)static ObjectgetComplexProperty(Object bean, String property)static ClassgetEntityClass(Class entityClass)static KeyAndIndexgetKeyAndIndex(String property)static MethodgetMethod(Class beanClass, String methodName, int argLength)static ObjectgetProperty(Object bean, String property)static ObjectinvokeMethod(Object bean, String methodName, Object[] args)static booleanisBaseDataType(Class clazz)static voidloadAllMapping(List mainEntities, List itemEntities, TableCascadeModel cascadeModel)static voidmappingSetProperties(Collection voList, String[] properties, List<Object[]> values, int[] index, boolean autoConvertType)static voidmappingSetProperties(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 ListreflectBeansToList(List datas, String[] props)static ListreflectBeansToList(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 ListreflectListToBean(TypeHandler typeHandler, Collection datas, int[] indexs, String[] properties, Class voClass)static ListreflectListToBean(TypeHandler typeHandler, Collection datas, int[] indexs, String[] properties, Class voClass, boolean autoConvertType)static ListreflectListToBean(TypeHandler typeHandler, Collection datas, String[] properties, Class voClass)static <T extends Serializable>
TreflectRowToBean(TypeHandler typeHandler, Method[] realMethods, int[] methodTypeValues, String[] methodTypes, Class[] genericTypes, List rowList, int[] indexs, String[] properties, Class<T> voClass)static voidsetProperty(Object bean, String property, Object value)static Object[]sliceToArray(List datas, String propertyName)static <T extends Serializable>
List<T>wrapEntities(TypeHandler typeHandler, EntityMeta entityMeta, Class<T> voClass, Object... ids)
-
-
-
字段详细资料
-
logger
protected static final org.slf4j.Logger logger
定义日志
-
ARRAY_PATTERN
public static final Pattern ARRAY_PATTERN
-
-
方法详细资料
-
matchSetMethods
public static Method[] matchSetMethods(Class voClass, String... props)
- update 2019-09-05 优化匹配方式,修复setIsXXX的错误
- update 2020-04-09 支持setXXX()并返回对象本身,适配链式操作
- update 2021-03-12 支持property中含下划线跟对象属性进行匹配
- 参数:
voClass-props-- 返回:
-
matchGetMethods
public static Method[] matchGetMethods(Class voClass, String... props)
- 参数:
voClass-props-- 返回:
-
matchMethodsType
public static Integer[] matchMethodsType(Class voClass, String... properties)
- 参数:
voClass-properties-- 返回:
-
invokeMethod
public static Object invokeMethod(Object bean, String methodName, Object[] args) throws Exception
- 参数:
bean-methodName-args-- 返回:
- 抛出:
Exception
-
equalsIgnoreType
public static boolean equalsIgnoreType(Object target, Object compared, boolean ignoreCase)
- 参数:
target-compared-ignoreCase-- 返回:
-
convertType
public static Object convertType(Object value, int typeValue, String typeName) throws Exception
- 参数:
value-typeValue- DataType.getType(typeName) 注意typeName不用转小写typeName- getParameterTypes()[0].getTypeName() 没有转大小写- 返回:
- 抛出:
Exception
-
convertType
public static Object convertType(TypeHandler typeHandler, Object value, int typeValue, String typeName, Class genericType) throws Exception
- 参数:
typeHandler-value-typeValue-typeName- getTypeName()没有转大小写genericType- 泛型类型- 返回:
- 抛出:
Exception
-
reflectBeansToList
public static List reflectBeansToList(List datas, String[] props) throws RuntimeException
- 参数:
datas-props-- 返回:
- 抛出:
RuntimeException
-
sliceToArray
public static Object[] sliceToArray(List datas, String propertyName) throws RuntimeException
- 参数:
datas-propertyName-- 返回:
- 抛出:
ExceptionRuntimeException
-
reflectBeansToList
public static List reflectBeansToList(List datas, String[] properties, ReflectPropsHandler reflectPropsHandler) throws RuntimeException
- 参数:
datas-properties-reflectPropsHandler-- 返回:
- 抛出:
ExceptionRuntimeException
-
reflectBeanToAry
public static Object[] reflectBeanToAry(Object serializable, String[] properties, Object[] defaultValues, ReflectPropsHandler reflectPropsHandler)
- 参数:
serializable-properties-defaultValues-reflectPropsHandler-- 返回:
-
reflectBeansToInnerAry
public static List<Object[]> reflectBeansToInnerAry(List dataSet, String[] properties, Object[] defaultValues, ReflectPropsHandler reflectPropsHandler)
- 参数:
dataSet-properties-defaultValues-reflectPropsHandler-- 返回:
-
reflectListToBean
public static List reflectListToBean(TypeHandler typeHandler, Collection datas, String[] properties, Class voClass)
-
reflectListToBean
public static List reflectListToBean(TypeHandler typeHandler, Collection datas, int[] indexs, String[] properties, Class voClass) throws RuntimeException
- 参数:
typeHandler-datas-indexs-properties-voClass-- 返回:
- 抛出:
RuntimeException
-
reflectListToBean
public static List reflectListToBean(TypeHandler typeHandler, Collection datas, int[] indexs, String[] properties, Class voClass, boolean autoConvertType)
- 参数:
typeHandler-datas-indexs-properties-voClass-autoConvertType-- 返回:
-
reflectRowToBean
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)
-
batchSetProperties
public static void batchSetProperties(Collection voList, String[] properties, Object[] values, boolean autoConvertType)
-
batchSetProperties
public static void batchSetProperties(Collection voList, String[] properties, Object[] values, boolean autoConvertType, boolean forceUpdate)
- 参数:
voList-properties-values-autoConvertType-forceUpdate-
-
mappingSetProperties
public static void mappingSetProperties(Collection voList, String[] properties, List<Object[]> values, int[] index, boolean autoConvertType) throws RuntimeException
- 参数:
voList-properties-values-index-autoConvertType-- 抛出:
RuntimeException
-
mappingSetProperties
public static void mappingSetProperties(Collection voList, String[] properties, List<Object[]> values, int[] index, boolean autoConvertType, boolean forceUpdate) throws RuntimeException
- 抛出:
RuntimeException
-
getMethod
public static Method getMethod(Class beanClass, String methodName, int argLength)
- 参数:
beanClass-methodName-argLength-- 返回:
-
isBaseDataType
public static boolean isBaseDataType(Class clazz)
- 参数:
clazz-- 返回:
-
setProperty
public static void setProperty(Object bean, String property, Object value) throws RuntimeException
- 参数:
bean-property-value-- 抛出:
RuntimeException
-
getProperty
public static Object getProperty(Object bean, String property) throws RuntimeException
- 参数:
bean-property-- 返回:
- 抛出:
RuntimeException
-
getComplexProperty
public static Object getComplexProperty(Object bean, String property) throws RuntimeException
- 参数:
bean-property-- 返回:
- 抛出:
RuntimeException
-
wrapEntities
public static <T extends Serializable> List<T> wrapEntities(TypeHandler typeHandler, EntityMeta entityMeta, Class<T> voClass, Object... ids)
- 类型参数:
T-- 参数:
typeHandler-entityMeta-voClass-ids-- 返回:
-
convertArray
public static Object convertArray(Object values, String typeName)
- 参数:
values-typeName-- 返回:
-
loadAllMapping
public static void loadAllMapping(List mainEntities, List itemEntities, TableCascadeModel cascadeModel) throws Exception
- 参数:
mainEntities-itemEntities-cascadeModel-- 抛出:
Exception
-
getCascadeModels
public static List<TableCascadeModel> getCascadeModels(Class entityClass)
- 参数:
entityClass-- 返回:
-
getKeyAndIndex
public static KeyAndIndex getKeyAndIndex(String property)
-
-