|  |  |  | @ -6,10 +6,15 @@ import java.util.ArrayList; | 
			
		
	
		
			
				
					|  |  |  |  | import java.util.Arrays; | 
			
		
	
		
			
				
					|  |  |  |  | import java.util.List; | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | import org.apache.log4j.Logger; | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | import com.fasterxml.jackson.databind.PropertyNamingStrategy.UpperCamelCaseStrategy; | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | public class BeanCopy { | 
			
		
	
		
			
				
					|  |  |  |  | 	 | 
			
		
	
		
			
				
					|  |  |  |  | 	@SuppressWarnings("static-access") | 
			
		
	
		
			
				
					|  |  |  |  | 	public static Logger log = Configs.DAILY_ROLLING_LOGGER.getLogger(BeanCopy.class); | 
			
		
	
		
			
				
					|  |  |  |  | 	 | 
			
		
	
		
			
				
					|  |  |  |  | 	/** 复制属性(子类父类等继承关系不可用) | 
			
		
	
		
			
				
					|  |  |  |  | 	 * @param source 源对象 | 
			
		
	
		
			
				
					|  |  |  |  | 	 * @param dst 目标对象 | 
			
		
	
	
		
			
				
					|  |  |  | @ -53,6 +58,35 @@ public class BeanCopy { | 
			
		
	
		
			
				
					|  |  |  |  | 		 | 
			
		
	
		
			
				
					|  |  |  |  | 	} | 
			
		
	
		
			
				
					|  |  |  |  | 	 | 
			
		
	
		
			
				
					|  |  |  |  | 	public static void copyField(Object src, Object dst,String... filter) { | 
			
		
	
		
			
				
					|  |  |  |  | 		List<String> filters = Arrays.asList(filter); | 
			
		
	
		
			
				
					|  |  |  |  | 		List<Field> fields = new ArrayList<Field>(); | 
			
		
	
		
			
				
					|  |  |  |  | 		Class<?> classobj = src.getClass(); | 
			
		
	
		
			
				
					|  |  |  |  | 		if (null != classobj) { | 
			
		
	
		
			
				
					|  |  |  |  | 			Field[] fs = classobj.getDeclaredFields(); | 
			
		
	
		
			
				
					|  |  |  |  | 			for (Field field : fs) { | 
			
		
	
		
			
				
					|  |  |  |  | 				field.setAccessible(true); | 
			
		
	
		
			
				
					|  |  |  |  | 				fields.add(field); | 
			
		
	
		
			
				
					|  |  |  |  | 			} | 
			
		
	
		
			
				
					|  |  |  |  | 			fields = findFatherField(classobj, fields); | 
			
		
	
		
			
				
					|  |  |  |  | 		} | 
			
		
	
		
			
				
					|  |  |  |  | 		for (Field field : fields) { | 
			
		
	
		
			
				
					|  |  |  |  | 			if (filters.contains(field.getName())) { | 
			
		
	
		
			
				
					|  |  |  |  | 				continue; | 
			
		
	
		
			
				
					|  |  |  |  | 			} | 
			
		
	
		
			
				
					|  |  |  |  | 			// dst  obj's property set value
 | 
			
		
	
		
			
				
					|  |  |  |  | 			try { | 
			
		
	
		
			
				
					|  |  |  |  | 				field.set(dst, field.get(src)); | 
			
		
	
		
			
				
					|  |  |  |  | 			} catch (SecurityException e) { | 
			
		
	
		
			
				
					|  |  |  |  | 				log.error(field.getName() + " is unsafe : SecurityException"); | 
			
		
	
		
			
				
					|  |  |  |  | 			} catch (IllegalArgumentException e) { | 
			
		
	
		
			
				
					|  |  |  |  | 				log.error(field.getName() + " is inexist or null or OutOfRange : ArgumentException "); | 
			
		
	
		
			
				
					|  |  |  |  | 			} catch (IllegalAccessException e) { | 
			
		
	
		
			
				
					|  |  |  |  | 				log.error(field.getName() + " Access is false : AccessException"); | 
			
		
	
		
			
				
					|  |  |  |  | 			} | 
			
		
	
		
			
				
					|  |  |  |  | 		} | 
			
		
	
		
			
				
					|  |  |  |  | 	} | 
			
		
	
		
			
				
					|  |  |  |  | 	 | 
			
		
	
		
			
				
					|  |  |  |  | 	private static void fatherCopyChild(Object father, Object dst, String... params) throws Exception{ | 
			
		
	
		
			
				
					|  |  |  |  | 		List<String> filter = new ArrayList<String>(); | 
			
		
	
		
			
				
					|  |  |  |  | 		filter.addAll(Arrays.asList(params)); | 
			
		
	
	
		
			
				
					|  |  |  | @ -74,6 +108,21 @@ public class BeanCopy { | 
			
		
	
		
			
				
					|  |  |  |  | 		} | 
			
		
	
		
			
				
					|  |  |  |  | 	} | 
			
		
	
		
			
				
					|  |  |  |  | 	 | 
			
		
	
		
			
				
					|  |  |  |  | 	private static List<Field> findFatherField(Class<?> classObj, List<Field> fields) { | 
			
		
	
		
			
				
					|  |  |  |  | 		Class<?> classz = classObj.getSuperclass(); | 
			
		
	
		
			
				
					|  |  |  |  | 		if (null != classz) { | 
			
		
	
		
			
				
					|  |  |  |  | 			Field[] field_array = classz.getDeclaredFields(); | 
			
		
	
		
			
				
					|  |  |  |  | 			if (field_array.length > 0) { | 
			
		
	
		
			
				
					|  |  |  |  | 				for (Field field : field_array) { | 
			
		
	
		
			
				
					|  |  |  |  | 					field.setAccessible(true); | 
			
		
	
		
			
				
					|  |  |  |  | 					fields.add(field); | 
			
		
	
		
			
				
					|  |  |  |  | 				} | 
			
		
	
		
			
				
					|  |  |  |  | 				findFatherField(classz,fields); | 
			
		
	
		
			
				
					|  |  |  |  | 			} | 
			
		
	
		
			
				
					|  |  |  |  | 		} | 
			
		
	
		
			
				
					|  |  |  |  | 		return fields; | 
			
		
	
		
			
				
					|  |  |  |  | 	} | 
			
		
	
		
			
				
					|  |  |  |  | 	 | 
			
		
	
		
			
				
					|  |  |  |  | 	private static String upperHeadChar(String in) { | 
			
		
	
		
			
				
					|  |  |  |  | 		String head = in.substring(0,1); | 
			
		
	
		
			
				
					|  |  |  |  | 		return head.toUpperCase()+in.substring(1, in.length()); | 
			
		
	
	
		
			
				
					|  |  |  | 
 |