[ 
https://issues.apache.org/jira/browse/LANG-621?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Thomas Neidhart updated LANG-621:
---------------------------------

    Attachment: LANG-621.patch

First version of a patch to provide a RecursiveToStringStyle which does 
recursively formats an object.

Similar to the ReflectionToStringBuilder, it has an accept(Class) method which 
allows for additional filtering for this recursive behavior. By default, only 
the primitive wrappers and java.lang.String are formatted in a shallow way. All 
the rest is formatted in a deep way.

It is provided as a separate source file (not as inner class of ToStringStyle) 
as this class also serves as an howto/example for users as requested by the 
original poster.
                
> ReflectionToStringBuilder.toString does not debug 3rd party object fields 
> within 3rd party object
> -------------------------------------------------------------------------------------------------
>
>                 Key: LANG-621
>                 URL: https://issues.apache.org/jira/browse/LANG-621
>             Project: Commons Lang
>          Issue Type: Improvement
>          Components: lang.builder.*
>    Affects Versions: 2.5
>            Reporter: Philip Hodges
>            Priority: Minor
>             Fix For: 3.x
>
>         Attachments: LANG-621.patch
>
>
> {code:title=Reflect.java|borderStyle=solid}
> import org.apache.commons.lang.builder.ReflectionToStringBuilder;
> public class Reflect {
>     public static void main(String[] args) {
>         // "You can also use the builder to debug 3rd party objects:"
>         // System.out.println("An object: " + 
> ReflectionToStringBuilder.toString(anObject));
>         // expected: 
> Reflect$Compound@a83b8a[instanceInt=67890,fixture=Reflect$Simple@1d1acd3[instanceInt=12345]]
>         // actual: 
> Reflect$Compound@a83b8a[instanceInt=67890,fixture=Reflect$Simple@1d1acd3]
>         System.out.println(ReflectionToStringBuilder.toString(new 
> Compound()));
>     }
>     static class Compound {
>         private int instanceInt = 67890;
>         private Simple fixture = new Simple();
>     }
>     static class Simple {
>         private int instanceInt = 12345;
>     }
> }
> {code}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to