List of usage examples for com.google.common.base Splitter withKeyValueSeparator
@CheckReturnValue
@Beta
public MapSplitter withKeyValueSeparator(Splitter keyValueSplitter)
From source file:fr.dutra.confluence2wordpress.util.MapUtils.java
public static Map<String, String> split(String str, String entrySep, String keyValueSep) { if (StringUtils.isBlank(str)) { return null; }/* w w w. j a v a 2 s . c o m*/ Splitter keyValueSplitter = Splitter.on(keyValueSep).trimResults(); Splitter entrySplitter = Splitter.on(entrySep).trimResults().omitEmptyStrings(); return Maps.transformValues(entrySplitter.withKeyValueSeparator(keyValueSplitter).split(str), TRIM_TO_NULL); }
From source file:com.intel.podm.common.utils.StringRepresentation.java
public static Map<String, String> toMap(String stringToSplit, boolean trimResults, boolean omitEmptyStrings) { Splitter splitter = Splitter.on(ELEMENT_SEPARATOR); if (trimResults) { splitter = splitter.trimResults(); }//from www . j a v a2 s. co m if (omitEmptyStrings) { splitter = splitter.omitEmptyStrings(); } Map<String, String> resultMap = splitter.withKeyValueSeparator(KEY_VALUE_SEPARATOR).split(stringToSplit); resultMap = new HashMap<>(resultMap); convertStringNullValues(resultMap); return resultMap; }