question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Collectors.joining()

See original GitHub issue

With the CharSequence->String transformation, there is an overloaded version of Collectors.joining() that accepts a String, and another that accepts three Strings. Perfect!

Sadly, these methods return Collector<CharSequence> instead of Collector<String>, forcing me to write:

    value fileName = fileNameParts.stream()
            .filter(not(String.empty))
            .map(javaString)
            .collect(Collectors.joining("_"))
            .string;

Instead of just

    value fileName = fileNameParts.stream()
            .filter(not(String.empty))
            .collect(Collectors.joining("_"));

I say we do some special-casing here, so that I get back a Collector<String> for Collectors.joining(). WDYT, @FroMage?

Issue Analytics

  • State:open
  • Created 7 years ago
  • Comments:10 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
gavinkingcommented, Nov 24, 2016

Yeah, but that wouldn’t be as cool.

0reactions
gavinkingcommented, Nov 25, 2016

A very similar request, from @MikhailMalyutin, would be to make Java Comparators transform to Comparison(T,T) instead of Integer(T,T). That’s pretty reasonable, i suppose. Another special case…

Read more comments on GitHub >

github_iconTop Results From Across the Web

Java 8 Streams | Collectors.joining() method with Examples
The joining() method of Collectors Class, in Java, is used to join various elements of a character or string array into a single...
Read more >
Collectors (Java Platform SE 8 ) - Oracle Help Center
joining (", ")); // Compute sum of salaries of employee int total = employees.stream() .collect(Collectors.summingInt(Employee::getSalary))); // Group employees ...
Read more >
Java 8 Streams - Collectors.joining Examples - LogicBig
The overloaded static methods, Collector#joining() return a Collector that concatenates the input element strings into a single String.
Read more >
java.util.stream.Collectors.joining java code examples - Tabnine
Compute and print fibonacci numbers · ResourceWebHandler.formatLocations() · AbstractHandlerMethodMapping.formatMappings(...) · ContextFieldVisitor.joinTypes(...).
Read more >
What is the Collectors.joining() method in Java? - Educative.io
joining() is a static method of Collectors that returns a Collector that concatenates the input elements with the specified delimiter.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found