You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Simone Tripodi (Commented) (JIRA)" <ji...@apache.org> on 2012/02/21 22:42:49 UTC

[jira] [Commented] (SANDBOX-396) [BeanUtils2] Implement clone() on DefaultBeanAccessor

    [ https://issues.apache.org/jira/browse/SANDBOX-396?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13212981#comment-13212981 ] 

Simone Tripodi commented on SANDBOX-396:
----------------------------------------

patch looks good, anyway:

{quote}
+        @SuppressWarnings( "unchecked" )
+        B clone = (B) bean.getClass().newInstance();
+        DefaultBeanAccessor<B> cloneAccessor = new DefaultBeanAccessor<B>( clone );
+        cloneAccessor.populate( this.describe() );
+        return clone;
{quote}

 * it is a good practice adding a comment that justifies why the unchecked warning can be suppressed;

 * the {{this.}} prefix can be omitted.

We could even reuse the {{BeanUtils.on( beanType ).newInstance()}} that would help removing the duplicated code.

Can you please apply these modifications and resubmit the patch?
TIA,
-Simo
                
> [BeanUtils2] Implement clone() on DefaultBeanAccessor
> -----------------------------------------------------
>
>                 Key: SANDBOX-396
>                 URL: https://issues.apache.org/jira/browse/SANDBOX-396
>             Project: Commons Sandbox
>          Issue Type: Improvement
>          Components: BeanUtils2
>    Affects Versions: Nightly Builds
>            Reporter: Benedikt Ritter
>         Attachments: SANDBOX-396.txt
>
>
> Implement {{clone()}} on DefaultBeanAccessor:
> * create a new instance of the same type as the bean encapsulated by the Accessor
> * create a {{DefaultBeanAccessor}} for the new instance
> * call populate on the new {{DefaultBeanAccessor}} with {{this.describe()}} as argument
> * return the clone

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira