Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <h2>For deep cloning (clones the entire object hierarchy):</h2> <ul> <li><p><a href="http://commons.apache.org/proper/commons-lang/javadocs/api-release/org/apache/commons/lang3/SerializationUtils.html" rel="noreferrer">commons-lang SerializationUtils</a> - using serialization - if all classes are in your control and you can force implementing <code>Serializable</code>.</p></li> <li><p><a href="https://github.com/kostaskougios/cloning/" rel="noreferrer">Java Deep Cloning Library</a> - using reflection - in cases when the classes or the objects you want to clone are out of your control (a 3rd party library) and you can't make them implement <code>Serializable</code>, or in cases you don't want to implement <code>Serializable</code>.</p></li> </ul> <h2>For shallow cloning (clones only the first level properties):</h2> <ul> <li><p><a href="https://commons.apache.org/proper/commons-beanutils/javadocs/v1.8.3/apidocs/org/apache/commons/beanutils/BeanUtils.html#cloneBean(java.lang.Object)" rel="noreferrer">commons-beanutils BeanUtils</a> - in most cases.</p></li> <li><p><a href="http://static.springsource.org/spring/docs/2.5.6/api/org/springframework/beans/BeanUtils.html" rel="noreferrer">Spring BeanUtils</a> - if you are already using spring and hence have this utility on the classpath.</p></li> </ul> <p>I deliberately omitted the "do-it-yourself" option - the API's above provide a good control over what to and what not to clone (for example using <code>transient</code>, or <code>String[] ignoreProperties</code>), so reinventing the wheel isn't preferred.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload