java - Should we use clone or BeanUtils.copyProperties and why -
It looks - I made the cloning yesterday and then realized that I had to provide my own modifications for the non string / primitive elements, then I got the Thanks Josh Block offers some quite good logic (provided by you Including one who made it) also said that the cloning is basically defective, rather than in favor of the copy constructor. See. I have not used any practical use yet to make an immutable copy. You are copying the objects for a specific reason, possibly for the processing, to exclude some set of items that can be transformed into a single transaction, can not guarantee anything unless the processing unit is complete. If they are already immutable, then a reference is as good as a copy. BeanUtils.copyProperties are often a less intrusive way of copying without supporting your classes, and it offers some unique flexibility in compositing objects. That said, copyProperties do not always fit a size, all. You need to support certain types of objects at some points, who have special constructors, but are still unstable. Your objects can support internal methods or constructors to work around those exceptions, or you can register in some external devices to mimic specific types, but it can not reach some places which can be cloned ( ) can do. It's good, but still there are limitations. BeanUtils.copyProperties starts creating a clone of an object. If this is the case, And with concerns about implementing the clonable interface (only the new ones where there are references copied in computational objects), which is the best and why?
BeanUtils.copyProperties < / Code>, which I am now using. Both implementations provide similar functionality.
Comments
Post a Comment