You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Caleb Cushing (Jira)" <ji...@apache.org> on 2020/12/08 15:35:00 UTC

[jira] [Updated] (LANG-1625) IsStringBuilder.reflectionToString support multiline for all formats

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

Caleb Cushing updated LANG-1625:
--------------------------------
    Summary: IsStringBuilder.reflectionToString support multiline for all formats  (was: IsStringBuilder.reflectionToString compound styles)

> IsStringBuilder.reflectionToString support multiline for all formats
> --------------------------------------------------------------------
>
>                 Key: LANG-1625
>                 URL: https://issues.apache.org/jira/browse/LANG-1625
>             Project: Commons Lang
>          Issue Type: Improvement
>          Components: lang.builder.*
>            Reporter: Caleb Cushing
>            Priority: Major
>
> what I want is to be able to add multiline/prettyprint to any style. I like the `IsStringBuilder.reflectionToString` method, but I wish it could support compound styling, for example 
> ```java
> var styles = new StyleBuilder().multiline().json();
> IsStringBuilder.reflectionToString(obj, styles);
> ```
> or
> ```java
> var styles = new StyleBuilder().multiline().shortPrefix();
> IsStringBuilder.reflectionToString(obj, styles);
> ```
> I feel like adding an additional parameter breaks the rule of no more than 4 parameters unless varargs (josh bloch, and others), so I'm proposing a builder.
> ```java
> var styles = new StyleBuilder()
>     .multiline()
>     .shortPrefix()
>     .outputTransients()
>     .reflectUpToSuperClass(...); // name change here, I didn't quite get what it was talking about at first in the documentation.
> ```
> or maybe
> ```java
> ToStringFormatter formatter= ToStringFormat.of( ToStringStyle.SHORT_PREFIX, ToStringLineStyle.MULTILINE);
> ToStringBuilder.reflectUpToSuperClass(this, formatter, true, MyClass.class);
> ```



--
This message was sent by Atlassian Jira
(v8.3.4#803005)