您的位置:首页 > 其它

两个对象之前的复制

2015-06-04 18:27 211 查看

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

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: