You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by Duncan Jones <du...@wortharead.com> on 2016/11/23 20:29:23 UTC

[LANG] Support recursion in ReflectionToStringBuilder and deprecate RecursiveToStringStyle?

Hi all,

To create a deep toString() representation of an object, one must use a combination of ReflectionToStringBuilder and RecursiveToStringStyle. IMO this confuses behaviour and presentation. LANG-1249 is an example of the problems the original design can cause - it’s not clear from the ReflectionToStringBuilder documentation whether RecursiveToStringStyle is able or willing to take notice of the excluded fields for inner objects.

I propose that the recursion behaviour is governed by the builder, not the ToStringStyle. Either a new class should be created (RecursiveToStringBuilder) or additional constructors should be added to ReflectionToStringBuilder to trigger recursion.

This would have the added benefit of allowing different styling options when recursion is employed. I’m a little concerned whether MULTI_LINE_STYLE would work correctly without an overhaul of the ToStringStyle class to include some kind of “depth” indicator. But I can dig into that further if there’s any interest in this idea.

What do people think about this? I tried to search the mail archives for some discussion around these classes, but couldn’t find anything. Apologies if this is well trodden ground.

Duncan 
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org


Re: [LANG] Support recursion in ReflectionToStringBuilder and deprecate RecursiveToStringStyle?

Posted by Duncan Jones <du...@wortharead.com>.
> On 24 Nov 2016, at 22:13, Pascal Schumacher <pa...@gmx.net> wrote:
> 
> Am 23.11.2016 um 21:29 schrieb Duncan Jones:
>> To create a deep toString() representation of an object, one must use a combination of ReflectionToStringBuilder and RecursiveToStringStyle. IMO this confuses behaviour and presentation. LANG-1249 is an example of the problems the original design can cause - it’s not clear from the ReflectionToStringBuilder documentation whether RecursiveToStringStyle is able or willing to take notice of the excluded fields for inner objects.
>> 
>> I propose that the recursion behaviour is governed by the builder, not the ToStringStyle.
> IMHO this makes sense.
> 
> -Pascal

Thanks, Pascal. Any thoughts on this from others?

Duncan
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org


Re: [LANG] Support recursion in ReflectionToStringBuilder and deprecate RecursiveToStringStyle?

Posted by Pascal Schumacher <pa...@gmx.net>.
Am 23.11.2016 um 21:29 schrieb Duncan Jones:
> To create a deep toString() representation of an object, one must use a combination of ReflectionToStringBuilder and RecursiveToStringStyle. IMO this confuses behaviour and presentation. LANG-1249 is an example of the problems the original design can cause - it\u2019s not clear from the ReflectionToStringBuilder documentation whether RecursiveToStringStyle is able or willing to take notice of the excluded fields for inner objects.
>
> I propose that the recursion behaviour is governed by the builder, not the ToStringStyle.
IMHO this makes sense.

-Pascal


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org