Closed GoogleCodeExporter closed 9 years ago
As of Guava 16, you can make a Converter<String, Iterable<String>> that
encapsulates your Joiner/Splitter.
Does that help?
Original comment by kak@google.com
on 7 Jan 2014 at 9:03
We thought about the connection between these two classes, but felt the
correspondences between "similar" features of Joiner and Splitter were actually
much more tenuous than they first appear.
Original comment by kevinb@google.com
on 7 Jan 2014 at 9:06
In response to Comment 1:
Converter would not help for two reasons.
#1 There is no easy way to turn a Splitter/Joiner into a function
#2 The point of the common functionality would be to have a common way of
declaring that splitting/joining will be on a specified character/string
without having to repeat it.
Original comment by jos.k.st...@gmail.com
on 7 Jan 2014 at 10:36
1) You'd declare them separately, like (excuse any typos):
class StringCleaver extends Converter<String, Iterable<String>> {
private static final String SEPARATOR = "!";
private static final Splitter SPLITTER = Splitter.on(SEPARATOR);
private static final Joiner JOINER = Joiner.on(SEPARATOR);
protected String doBackward(Iterable<String> input) {
return JOINER.join(input);
}
protected Iterable<String> doForward(String input) {
return SPLITTER.split(input);
}
}
2) see the constant above
Original comment by kak@google.com
on 7 Jan 2014 at 10:50
This issue has been migrated to GitHub.
It can be found at https://github.com/google/guava/issues/<issue id>
Original comment by cgdecker@google.com
on 1 Nov 2014 at 4:10
Original comment by cgdecker@google.com
on 1 Nov 2014 at 4:17
Original comment by cgdecker@google.com
on 3 Nov 2014 at 9:07
Original issue reported on code.google.com by
jos.k.st...@gmail.com
on 7 Jan 2014 at 8:58