Collectors.joining()
See original GitHub issueWith the CharSequence
->String
transformation, there is an overloaded version of Collectors.joining()
that accepts a String
, and another that accepts three String
s. 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:
- Created 7 years ago
- Comments:10 (10 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Yeah, but that wouldn’t be as cool.
A very similar request, from @MikhailMalyutin, would be to make Java
Comparator
s transform toComparison(T,T)
instead ofInteger(T,T)
. That’s pretty reasonable, i suppose. Another special case…