Package com.google.common.base
Class Splitter.MapSplitter
- java.lang.Object
-
- com.google.common.base.Splitter.MapSplitter
-
- Enclosing class:
- Splitter
public static final class Splitter.MapSplitter extends java.lang.Object
An object that splits strings into maps asSplitter
splits iterables and lists. LikeSplitter
, it is thread-safe and immutable. The common way to build instances is by providing an additional key-value separator toSplitter
.- Since:
- 10.0
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.Map<java.lang.String,java.lang.String>
split(java.lang.CharSequence sequence)
Splitssequence
into substrings, splits each substring into an entry, and returns an unmodifiable map with each of the entries.
-
-
-
Method Detail
-
split
public java.util.Map<java.lang.String,java.lang.String> split(java.lang.CharSequence sequence)
Splitssequence
into substrings, splits each substring into an entry, and returns an unmodifiable map with each of the entries. For example,Splitter.on(';').trimResults().withKeyValueSeparator("=>").split("a=>b ; c=>b")
will return a mapping from"a"
to"b"
and"c"
to"b"
.The returned map preserves the order of the entries from
sequence
.- Throws:
java.lang.IllegalArgumentException
- if the specified sequence does not split into valid map entries, or if there are duplicate keys
-
-