MCPcopy
hub / github.com/google/guava / split

Method split

guava/src/com/google/common/base/Splitter.java:496–512  ·  view source on GitHub ↗

Splits {@code sequence} into substrings, splits each substring into an entry, and returns an unmodifiable map with each of the entries. For example, {@code Splitter.on(';').trimResults().withKeyValueSeparator("=>").split("a=>b ; c=>b")} will return a mapping from {@code "a"} to {@code "b"} and {@cod

(CharSequence sequence)

Source from the content-addressed store, hash-verified

494 * entries, or if there are duplicate keys
495 */
496 public Map<String, String> split(CharSequence sequence) {
497 Map<String, String> map = new LinkedHashMap<>();
498 for (String entry : outerSplitter.split(sequence)) {
499 Iterator<String> entryFields = entrySplitter.splittingIterator(entry);
500
501 checkArgument(entryFields.hasNext(), INVALID_ENTRY_MESSAGE, entry);
502 String key = entryFields.next();
503 checkArgument(!map.containsKey(key), "Duplicate key [%s] found.", key);
504
505 checkArgument(entryFields.hasNext(), INVALID_ENTRY_MESSAGE, entry);
506 String value = entryFields.next();
507 map.put(key, value);
508
509 checkArgument(!entryFields.hasNext(), INVALID_ENTRY_MESSAGE, entry);
510 }
511 return Collections.unmodifiableMap(map);
512 }
513 }
514
515 private interface Strategy {

Callers 1

Calls 8

nextMethod · 0.65
containsKeyMethod · 0.65
putMethod · 0.65
splitMethod · 0.45
splittingIteratorMethod · 0.45
checkArgumentMethod · 0.45
hasNextMethod · 0.45
unmodifiableMapMethod · 0.45

Tested by 1