Open rob-stoecklein opened 3 years ago
Yes, please! This would be wonderful! It's simply to implement, simple to retrofit, and is backwards compatible!
Groovy has a similar option, see [groovy.transform.ToString#ignoreNulls](https://docs.groovy-lang.org/latest/html/api//groovy/transform/ToString.html#ignoreNulls()). I like this somewhat shorter naming "ignoreNulls". Property names cannot be null, thus the suffix 'Values' is not needed.
Please consider this option:
Upvoting this!
GOAL Reduce the length of toString() outputs by ignoring variables that are null.
BENEFIT Greatly improves the readability of object outputs, especially on data beans that contain many null variables.
EXAMPLE A simple data bean with three fields, two of which are null, has a toString() output of:
Bean(foo=null, hee=haw, bar=null)
Propose that the output can be:
Bean(hee=haw)
On data beans many fields, this can significantly simplify the toString() output.
CHANGE Add an option "includeNullValues" be added to the ToString annotation:
@ToString(includeNullValues=false)
Of course, this option would default to true.
Thanks for your consideration!