Closed GoogleCodeExporter closed 9 years ago
I'm trying to understand why you see that code as a "hack". It seems the exact
opposite of a hack to me.
Splitter's job is to be a splitter. It splits.
Original comment by kevinb@google.com
on 16 Apr 2014 at 7:08
A "hack" in that I am ultimately creating two collections: The String
collection from the split, and then the actual element-type I wanted for my
collection in the first place.
Splitter already can chain atop itself for omitting whitespace, empty elements,
or null mapvalues. I don't see any real loss of cohesion in being able to
decide what type of collection you're actually splitting *into*.
Original comment by masal...@gmail.com
on 16 Apr 2014 at 7:29
If you use Splitter.split instead of splitToList, you're not actually creating
two collections: the returned Iterable does the split lazily.
There's no performance hit for splitting to an Iterable<String> and then
transforming the Iterable with your parser.
Original comment by lowas...@google.com
on 16 Apr 2014 at 7:33
Ah, you mean:
385 public Iterable<String> split(final CharSequence sequence) {
386 checkNotNull(sequence);
387
388 return new Iterable<String>() {
389 @Override public Iterator<String> iterator() {
390 return splittingIterator(sequence);
391 }
392 @Override public String toString() {
393 return Joiner.on(", ")
394 .appendTo(new StringBuilder().append('['), this)
395 .append(']')
396 .toString();
397 }
398 };
399 }
Thanks for the clarification. I can make a few wrap-around classes to work off
of this rule.
Original comment by masal...@gmail.com
on 16 Apr 2014 at 7:40
Original comment by cgdecker@google.com
on 16 Apr 2014 at 9:05
I agree with decision not to extend Splitter API with transformation, however
is there any reason why Splitter.split() doesn't return FluentIterable?
Original comment by tomas.za...@gmail.com
on 17 Apr 2014 at 8:04
Since Kevin's email response didn't get included in the issue: We are
prohibited from having circular package dependencies.
Original comment by cgdecker@google.com
on 17 Apr 2014 at 3:35
This issue has been migrated to GitHub.
It can be found at https://github.com/google/guava/issues/<id>
Original comment by cgdecker@google.com
on 1 Nov 2014 at 4:09
Original comment by cgdecker@google.com
on 3 Nov 2014 at 9:07
Original issue reported on code.google.com by
masal...@gmail.com
on 16 Apr 2014 at 6:53