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.

Overload Joiner.join with a function parameter

See original GitHub issue

Currently when calling Joiner.on(String).join(Iterable<E>) the toString() method is called to get a String from the given Object. Sometimes you want to use getName() or getText() in order to get a String instead… To achieve this the join method could be overloaded accepting a java.util.function.Fuction<T,R> parameter, with T being the generic type of the given Iterable Object, and R being a String. This way the developer could choose how he wants to get a string from the object.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
cpovirkcommented, Jun 4, 2016

We have a way of doing this, but it requires a slightly different approach:

FluentIterable.from(...).transform(...).join(joiner)

Maybe we should document this pattern on Joiner.

0reactions
cpovirkcommented, Jun 4, 2016

Thanks, Louis. I filed https://github.com/google/guava/issues/2497 for the possible doc change.

Read more comments on GitHub >

github_iconTop Results From Across the Web

com.google.common.base.Joiner.withKeyValueSeparator ...
Returns a MapJoiner using the given key-value separator, and the same configuration as this Joiner otherwise. Popular methods of Joiner. join. Returns a...
Read more >
The best overloaded method match for 'string.Join(string ...
Join method only had overloads that took arrays as their second parameter. Support for IEnumerable<string> was only introduced in .NET 4.0.
Read more >
Java 8 Streams | Collectors.joining() method with Examples
Collectors.joining(CharSequence delimiter) is an overload of joining() method which takes delimiter as a parameter, of the type CharSequence ...
Read more >
How to Join Multiple Strings in Java 8 - String join() Example
join (). It has two overloaded versions, one accepts a delimiter and number of String objects as variable arguments and the other accepts...
Read more >
String.Join Method (System) - Microsoft Learn
Overloads ; Join(Char, String[], Int32, Int32). Concatenates an array of strings, using the specified separator between each member, starting with the element in ......
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