package com.taover.util; import java.lang.reflect.Field; import java.util.ArrayList; import java.util.List; public class UtilObject { /** * 将源对象source字段赋值到对象dest字段,条件1字段名相同,条件2字段类型相同; * 注:source与dest可以是两个没有关系的类,不接受基本封装类型,例如Integer * @param source * @param dest * @param allowNull * @param exceptFieldNameArray * @return 如果source==dest或者source==null或者dest==null,则返回false */ public static Object fieldCopy(Object source, Object dest, boolean allowNull, String exceptFieldNameArray[], boolean isNewInstance){ //引用检查 if(source==null || dest==null || source==dest){ return null; } //获取Field数组 Field[] sourceField = source.getClass().getDeclaredFields(); Field[] destField = dest.getClass().getDeclaredFields(); //获取目标对象 String[] destFieldNameArray = new String[destField.length]; String[] destFieldTypeArray = new String[destField.length]; for(int i=0; i hello_word * @param source * @param isCopyNull * @param exceptFieldNameArray * @return */ public static List objecFieldToListToLowerCase(Object source, boolean isCopyNull, String exceptFieldNameArray[]){ List result = new ArrayList(); //参数检验 if(source == null){ return result; } //获取Field数组 Field[] sourceField = source.getClass().getDeclaredFields(); //遍历源field数组,处理源field数组 for(int i=0; i fieldToArray(Object source, boolean allowNull, String exceptFieldNameArray[]){ List result = new ArrayList(); //参数检验 if(source == null){ return result; } //获取Field数组 Field[] sourceField = source.getClass().getDeclaredFields(); //遍历源field数组,处理源field数组 for(int i=0; i