Should we use clone or BeanUtils.copyProperties and why

前端 未结 7 1734
醉话见心
醉话见心 2020-12-13 04:47

By the looks of it - BeanUtils.copyProperties seems to create a clone of an object. If this is the case, and what with the concerns around implementing the Clon

相关标签:
7条回答
  • 2020-12-13 05:35

    Cloning is done by you. If the instance which you trying clone contains reference of another instance you have to write cloning code to that one too. What if the instances contains chain of references to other instances? So if you do cloning by yourself, there are chances that you might miss a small detail.

    BeanUtils.copyProperties on otherhand take care of everything by itself. It reduces your effort.

    0 讨论(0)
提交回复
热议问题