You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Benedikt Ritter (Created) (JIRA)" <ji...@apache.org> on 2012/02/20 14:36:34 UTC

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

[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


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

        

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

Posted by "Simone Tripodi (Commented) (JIRA)" <ji...@apache.org>.
    [ 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

        

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

Posted by "Benedikt Ritter (Updated) (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/SANDBOX-396?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Benedikt Ritter updated SANDBOX-396:
------------------------------------

    Attachment: SANDBOX-396v2.txt

I've corrected the patch the way you suggested. 

Regards,
Benedikt
                
> [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, SANDBOX-396v2.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

        

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

Posted by "Simone Tripodi (Resolved) (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/SANDBOX-396?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Simone Tripodi resolved SANDBOX-396.
------------------------------------

    Resolution: Fixed
      Assignee: Simone Tripodi

v2 looked much better, applied on [r1293663|http://svn.apache.org/viewvc?rev=1293663&view=rev], thanks for contributing
                
> [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
>            Assignee: Simone Tripodi
>         Attachments: SANDBOX-396.txt, SANDBOX-396v2.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

        

[jira] [Issue Comment Edited] (SANDBOX-396) [BeanUtils2] Implement clone() on DefaultBeanAccessor

Posted by "Simone Tripodi (Issue Comment Edited) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/SANDBOX-396?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13212981#comment-13212981 ] 

Simone Tripodi edited comment on SANDBOX-396 at 2/21/12 9:42 PM:
-----------------------------------------------------------------

patch looks good, anyway:

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

 * 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()}} chain that would help removing the duplicated code.

Can you please apply these modifications and resubmit the patch?
TIA,
-Simo
                
      was (Author: simone.tripodi):
    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

        

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

Posted by "Benedikt Ritter (Updated) (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/SANDBOX-396?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Benedikt Ritter updated SANDBOX-396:
------------------------------------

    Attachment: SANDBOX-396.txt

I've attached a patch for this issue.

There is one thing worth mentioning: We had a discussion about the behavior of {{cloneBean()}} regarding Maps on the ML. At first I thought, that passing a Map to {{cloneBean()}} in BeanUtils1 would return an exact copy of that  map. I've looked at BeanUtils1 once again and my first impression was wrong. For this reason there is no special handling for Maps implemented in the patch (since that is the same behavior as in BeanUtils1)

Regards,
Benedikt
                
> [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

        

[jira] [Issue Comment Edited] (SANDBOX-396) [BeanUtils2] Implement clone() on DefaultBeanAccessor

Posted by "Simone Tripodi (Issue Comment Edited) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/SANDBOX-396?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13212981#comment-13212981 ] 

Simone Tripodi edited comment on SANDBOX-396 at 2/21/12 9:42 PM:
-----------------------------------------------------------------

patch looks good, anyway:

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

 * 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()}} chain that returns a {{BeanAccessor<B>}} and would help removing the duplicated code.

Can you please apply these modifications and resubmit the patch?
TIA,
-Simo
                
      was (Author: simone.tripodi):
    patch looks good, anyway:

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

 * 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()}} chain 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

        

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

Posted by "Benedikt Ritter (Commented) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/SANDBOX-396?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13213562#comment-13213562 ] 

Benedikt Ritter commented on SANDBOX-396:
-----------------------------------------

Hey Simo,

thanks for your feedback! I'll have a look at it next weekend. Because I'm currently working on setIndexed(), it requires me to finish that first, create a patch and then revert the project. If I don't, you would have to deal with several patches mixed up together in one file.

Have a nice day!
Benedikt 

                
> [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