guava icon indicating copy to clipboard operation
guava copied to clipboard

[Feature] Add ability for Joiner to truncate

Open rwinograd opened this issue 3 years ago • 0 comments

I often write code of the flavor: log.info("Array items: [{}]", Joiner.on(",").join(array)). This code is somewhat brittle for extremely long lists, but I have no convenient way to truncate the list while still indicating that the list has been truncated.

It would be nice if there was some way to both truncate the list to a fixed number of values, but also show within the joined string that it has been truncated. So for example, to borrow from the Ascii#truncate API: log.info("Array items: [{}]", Joiner.on(",").withTruncationIndicator("...").join(array))

rwinograd avatar Aug 09 '22 17:08 rwinograd