Hello!

Another possibility would be to keep a single collector method (e.g.
`joining(ListFormat)`), but add more convenient builder-like methods
to the `ListFormat` itself, like
public static ListFormat standard(Locale loc) // = getInstance(loc,
Type.STANDARD, Style.FULL)
public static ListFormat unit(Locale loc) // = getInstance(loc,
Type.UNIT, Style.FULL)
public static ListFormat or(Locale loc) // = getInstance(loc, Type.OR,
Style.FULL)

public ListFormat full() // = getInstance(this.locale, this.type, Style.FULL)
public ListFormat short() // = getInstance(this.locale, this.type, Style.SHORT)
public ListFormat narrow() // = getInstance(this.locale, this.type,
Style.NARROW)

This would make use of ListFormat more pleasant in general, not only
for collectors. After that we could write the following code:

myStream.collect(Collectors.joining(ListFormat.standard(Locale.US).narrow()));
Compare with the existing factory:
myStream.collect(Collectors.joining(ListFormat.getInstance(Locale.US,
Type.STANDARD, Style.NARROW)));

Though creating new factory methods in `ListFormat` should probably be
covered in a separate enhancement request.

Tagir

On Thu, Sep 10, 2026 at 8:09 AM Alan Bateman <[email protected]> wrote:
>
> On 09/09/2026 18:00, Tagir Valeev wrote:
>
> Thank you for your suggestions. I see that there's a general
> preference towards adding a static method to the Collectors class, so
> let's move in this direction. So far, I've seen several proposals for
> the method name:
> - formatting
> - listFormatting
> - joiningLocalized
>
>
> Assuming the most common format types are STANDARD and OR then another 
> suggestion for your list is "joiningConjunctively" and "joiningDisjunctively".
>
> This line of naming would help remove the need to specify a ListFormat and 
> instead focus on having Locale be the parameter to give you examples like 
> this;
>
> Collectors.joining(", ") => "foo, bar, baz"
>
> Collectors.joiningConjunctively(Locale.US) => "foo, bar, and baz"
>
> Collectors.joiningConjunctively(Locale.UK) => "foo, bar and baz"
>
> Collectors.joiningDisjunctively(Locale.US) => "foo, bar, or baz"
>
> Collectors.joiningDisjunctively(Locale.UK) => "foo, bar or baz"
>
> which I think isn't too bad.
>
> -Alan.

Reply via email to