Details
-
Improvement
-
Status: Open
-
Major
-
Resolution: Unresolved
-
None
-
None
-
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.