Uploaded image for project: 'Commons Lang'
  1. Commons Lang
  2. LANG-1625

IsStringBuilder.reflectionToString support multiline for all formats

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Open
    • Major
    • Resolution: Unresolved
    • None
    • None
    • lang.builder.*
    • None

    Description

      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 

      var styles = new StyleBuilder().multiline().json();
       IsStringBuilder.reflectionToString(obj, styles);

      or

      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.

       

       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 (but I like this option less)

       

      ToStringFormatter formatter= ToStringFormat.of( ToStringStyle.SHORT_PREFIX, ToStringLineStyle.MULTILINE);
      ToStringBuilder.reflectUpToSuperClass(this, formatter, true, MyClass.class);
      

      as a side note, and I can create another ticket, I would love to see a json5 format.

      Attachments

        Activity

          People

            Unassigned Unassigned
            xenoterracide Caleb Cushing
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: