Closed GoogleCodeExporter closed 9 years ago
The omitEmptyStrings part of the above is sort of meaningless and can be
removed.
Original comment by nik9...@gmail.com
on 17 Jan 2012 at 9:17
The first #trimResults only applies to the key splitter. You can get what you
want with:
Map<String, String> map = Splitter
.on(",")
.omitEmptyStrings()
.trimResults()
.withKeyValueSeparator(Splitter.on("->").trimResults())
.split("cows-> big, sheep -> annoying, geese -> welcome");
Perhaps we need to make this more clear in the javadocs somehow though?
Original comment by kak@google.com
on 17 Jan 2012 at 9:19
Original comment by kak@google.com
on 17 Jan 2012 at 9:19
Its more like the trim works on the splitter that splits the entries - the one
that uses the ",". Would it be ok to provide the trim behavior to the keyvalue
splitter? Something like:
@CheckReturnValue
@Beta
public MapSplitter withKeyValueSeparator(String separator) {
- return withKeyValueSeparator(on(separator));
+ return withKeyValueSeparator(on(separator).trimResults(trimmer));
}
Original comment by nik9...@gmail.com
on 17 Jan 2012 at 9:27
Unfortunately, this would leave the user no apparent way to specify when they
*don't* want that trimming. I don't know if there's going to be a good solution
to this problem. :-(
Original comment by kevinb@google.com
on 18 Jan 2012 at 3:06
Wouldn't the withKeyValueSeparator(Splitter) syntax do that? Those that want
the current behavior I'm seeing could do
Splitter.on(",").trimResults().withKeyValueSerarator(Splitter.on("->")).split(""
)
Something like that'd still require a note in the javadoc for the String
version of withKeyValueSeparator, but I think it'd be overall more intuitive.
Original comment by nik9...@gmail.com
on 18 Jan 2012 at 3:30
Original comment by wasserman.louis
on 16 Feb 2012 at 6:27
Original comment by fry@google.com
on 16 Feb 2012 at 7:17
We are starting to wonder if it was a mistake to implement MapSplitter in the
way we did (start with a Splitter, then get a MapSplitter from it). A parallel
API probably would have been a lot less confusing. I am not sure we how
feasible it is to fix this behavior now.
Original comment by kevinb@google.com
on 16 Feb 2012 at 9:52
Original comment by kevinb@google.com
on 30 May 2012 at 7:51
Original comment by kevinb@google.com
on 22 Jun 2012 at 6:16
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:14
Original comment by cgdecker@google.com
on 1 Nov 2014 at 4:18
Original comment by cgdecker@google.com
on 3 Nov 2014 at 9:09
Original issue reported on code.google.com by
nik9...@gmail.com
on 17 Jan 2012 at 9:04