On Sat, 19 Sep 2026 08:51:23 GMT, Tagir F. Valeev <[email protected]> wrote:
> After discussion, I updated the PR. Now, the new collector is named as
> `Collectors.joining(ListFormat)`. I feel it's the best option.
I don't think the discussion on core-libs-dev came to any conclusion. I think
we need to explore further the options that don't involve ListFormat in the
API. It's a bit unfortunate that there wasn't more eyes on ListFormat when it
was being discussed as it's very domain focused. With your proposal I look at
examples like this:
ListFormat neitherNor = ListFormat.getInstance(new String[] {
"neither {0}, {1}", // (start_before){0}start_between{1}
"{0}, {1}", // {0}middle_between{1}
"{0}, nor {1}", // {0}end_between{1}(end_after)
"neither {0} nor {1}", // (two_before){0}two_between{1}(two_after)
"" //
(three_before){0}three_between1{1}three_between2{2}(three_after)
});
String result = Stream.of("read", "write", "execute")
.collect(Collectors.joining(neitherNor));
and wonder about future regrets if string templates were to be re-visited in
some new form in the future.
Naming is confusing too. ListFormat is for parsing and formatting lists of
strings whereas the proposed API is a mutable reduction op that processes
elements in a stream. It kinda feels like I should be using toList and then
applying the "list format". It begs the question as to why this isn't a
"formatting" method with parameters for the format.
I think it would be useful to write down what we think the important use cases
are. Would the suggested joiningConjunctively(Locale) and
joiningDisjunctively(Locale) (or better named) methods that provide the locale
sensitive and/or-joining cover the most common cases?
How terrible would if the less common or advance configuration, and LDML
list-patterns, require using a method on ListFormat to create a collector as
you original proposed? Yes, less discoverable but not terrible if it's not
something that some developers would ever use.
-------------
PR Comment: https://git.openjdk.org/jdk/pull/32716#issuecomment-5748470128