@Test public void decodeMap() { Assertions.assertNull(CollectionUtils.decodeMap(null)); Map<String, String> map = CollectionUtils.decodeMap(""); Assertions.assertEquals(0, map.size()); map = CollectionUtils.decodeMap("x=1"); Assertions.assertEquals(1, map.size()); Assertions.assertEquals("1", map.get("x")); map = CollectionUtils.decodeMap("x=1&y=2"); Assertions.assertEquals(2, map.size()); Assertions.assertEquals("2", map.get("y")); }
public static Map<String, String> decodeMap(String data) { if (data == null) { return null; } Map<String, String> map = new ConcurrentHashMap<>(); if (StringUtils.isBlank(data)) { return map; } String[] kvPairs = data.split(PAIR_SPLIT); if (kvPairs.length == 0) { return map; } for (String kvPair : kvPairs) { if (StringUtils.isNullOrEmpty(kvPair)) { continue; } String[] kvs = kvPair.split(KV_SPLIT); if (kvs.length != 2) { continue; } map.put(kvs[0], kvs[1]); } return map; }
CollectionUtils { public static Map<String, String> decodeMap(String data) { if (data == null) { return null; } Map<String, String> map = new ConcurrentHashMap<>(); if (StringUtils.isBlank(data)) { return map; } String[] kvPairs = data.split(PAIR_SPLIT); if (kvPairs.length == 0) { return map; } for (String kvPair : kvPairs) { if (StringUtils.isNullOrEmpty(kvPair)) { continue; } String[] kvs = kvPair.split(KV_SPLIT); if (kvs.length != 2) { continue; } map.put(kvs[0], kvs[1]); } return map; } }
CollectionUtils { public static Map<String, String> decodeMap(String data) { if (data == null) { return null; } Map<String, String> map = new ConcurrentHashMap<>(); if (StringUtils.isBlank(data)) { return map; } String[] kvPairs = data.split(PAIR_SPLIT); if (kvPairs.length == 0) { return map; } for (String kvPair : kvPairs) { if (StringUtils.isNullOrEmpty(kvPair)) { continue; } String[] kvs = kvPair.split(KV_SPLIT); if (kvs.length != 2) { continue; } map.put(kvs[0], kvs[1]); } return map; }  }
CollectionUtils { public static Map<String, String> decodeMap(String data) { if (data == null) { return null; } Map<String, String> map = new ConcurrentHashMap<>(); if (StringUtils.isBlank(data)) { return map; } String[] kvPairs = data.split(PAIR_SPLIT); if (kvPairs.length == 0) { return map; } for (String kvPair : kvPairs) { if (StringUtils.isNullOrEmpty(kvPair)) { continue; } String[] kvs = kvPair.split(KV_SPLIT); if (kvs.length != 2) { continue; } map.put(kvs[0], kvs[1]); } return map; }  static boolean isEmpty(Collection col); static boolean isNotEmpty(Collection col); static boolean isEmpty(Object[] array); static boolean isNotEmpty(Object[] array); static String toString(Collection col); static boolean isSizeEquals(Collection col0, Collection col1); static String encodeMap(Map<String, String> map); static Map<String, String> decodeMap(String data); static List<String> toUpperList(List<String> sourceList); }
CollectionUtils { public static Map<String, String> decodeMap(String data) { if (data == null) { return null; } Map<String, String> map = new ConcurrentHashMap<>(); if (StringUtils.isBlank(data)) { return map; } String[] kvPairs = data.split(PAIR_SPLIT); if (kvPairs.length == 0) { return map; } for (String kvPair : kvPairs) { if (StringUtils.isNullOrEmpty(kvPair)) { continue; } String[] kvs = kvPair.split(KV_SPLIT); if (kvs.length != 2) { continue; } map.put(kvs[0], kvs[1]); } return map; }  static boolean isEmpty(Collection col); static boolean isNotEmpty(Collection col); static boolean isEmpty(Object[] array); static boolean isNotEmpty(Object[] array); static String toString(Collection col); static boolean isSizeEquals(Collection col0, Collection col1); static String encodeMap(Map<String, String> map); static Map<String, String> decodeMap(String data); static List<String> toUpperList(List<String> sourceList);  }