填坑-十万个为什么?(25)

380 阅读1分钟

之前的笔记主要涉及前端,之后会以这个Web知识体系做学习

1.Java中对象属性拷贝的方法和性能对比

①手动拷贝(set)
②动态代理
    cglib版本:'net.sf.cglib.beans.BeanCopier.copy(Object from, Object to, Converter converter)'
③反射机制
    Spring版本:'org.springframework.beans.BeanUtils.copyProperties(Object source, Object target) '
    Apache版本:'org.apache.commons.beanutils.PropertyUtils.copyProperties(Object dest, Object orig) '
                'org.apache.commons.beanutils.BeanUtils.copyProperties(Object dest, Object orig)'
④dozer版本(xml配置映射)
                'org.dozer.DozerBeanMapper.map(Object source, Class<T> destinationClass)'

拷贝对象属性时间复杂度T(n)
manualCopy > cglibCopy > springBeanUtils > apachePropertyUtils > apacheBeanUtils

参考文章:
作者:三石雨 原文:对象属性拷贝工具类的性能比较