两个对象之前的复制

1.DozerBeanMapper的map方法

public class BeanMapper {

        private static DozerBeanMapper dozer = new DozerBeanMapper();

        public static <T> T map(Object source, Class<T> destinationClass) {

                return dozer.map(source, destinationClass);

        }

        public static <T> List<T> mapList(Collection sourceList, Class<T> destinationClass) {

                List<T> destinationList = Lists.newArrayList();

                for (Object sourceObject : sourceList) {

                          T destinationObject = dozer.map(sourceObject, destinationClass);

                           destinationList.add(destinationObject);

                }

                return destinationList;

         }

         public static void copy(Object source, Object destinationObject) {

                dozer.map(source, destinationObject);

         }

}

2.PropertyUtils.copyProperties

3.BeanUtils.copyProperties

4.BeanCopier

猜你喜欢

转载自cairewen.iteye.com/blog/2217106
今日推荐