@Test public void encodeMap() { Map<String, String> map = null; Assertions.assertNull(CollectionUtils.encodeMap(map)); map = new HashMap<>(); Assertions.assertEquals("", CollectionUtils.encodeMap(map)); map.put("x", "1"); Assertions.assertEquals("x=1", CollectionUtils.encodeMap(map)); map.put("y", "2"); Assertions.assertEquals("x=1&y=2", CollectionUtils.encodeMap(map)); }
public static String encodeMap(Map<String, String> map) { if (map == null) { return null; } if (map.isEmpty()) { return StringUtils.EMPTY; } StringBuilder sb = new StringBuilder(); for (Map.Entry<String, String> entry : map.entrySet()) { sb.append(entry.getKey()).append(KV_SPLIT).append(entry.getValue()).append(PAIR_SPLIT); } return sb.substring(0, sb.length() - 1); }
CollectionUtils { public static String encodeMap(Map<String, String> map) { if (map == null) { return null; } if (map.isEmpty()) { return StringUtils.EMPTY; } StringBuilder sb = new StringBuilder(); for (Map.Entry<String, String> entry : map.entrySet()) { sb.append(entry.getKey()).append(KV_SPLIT).append(entry.getValue()).append(PAIR_SPLIT); } return sb.substring(0, sb.length() - 1); } }
CollectionUtils { public static String encodeMap(Map<String, String> map) { if (map == null) { return null; } if (map.isEmpty()) { return StringUtils.EMPTY; } StringBuilder sb = new StringBuilder(); for (Map.Entry<String, String> entry : map.entrySet()) { sb.append(entry.getKey()).append(KV_SPLIT).append(entry.getValue()).append(PAIR_SPLIT); } return sb.substring(0, sb.length() - 1); }  }
CollectionUtils { public static String encodeMap(Map<String, String> map) { if (map == null) { return null; } if (map.isEmpty()) { return StringUtils.EMPTY; } StringBuilder sb = new StringBuilder(); for (Map.Entry<String, String> entry : map.entrySet()) { sb.append(entry.getKey()).append(KV_SPLIT).append(entry.getValue()).append(PAIR_SPLIT); } return sb.substring(0, sb.length() - 1); }  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 String encodeMap(Map<String, String> map) { if (map == null) { return null; } if (map.isEmpty()) { return StringUtils.EMPTY; } StringBuilder sb = new StringBuilder(); for (Map.Entry<String, String> entry : map.entrySet()) { sb.append(entry.getKey()).append(KV_SPLIT).append(entry.getValue()).append(PAIR_SPLIT); } return sb.substring(0, sb.length() - 1); }  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);  }