public static Map<String, String> parseCsvMap(String str) {
        Map<String, String> map = new HashMap<>();
        if (str == null || str.isEmpty())
            return map;
        String[] keyVals = str.split("\\s*,\\s*");
        for (String s : keyVals) {
            int lio = s.lastIndexOf(":");
            map.put(s.substring(0, lio).trim(), s.substring(lio + 1).trim());
        }
        return map;
    }
@Test
    public void testCsvMap() {
        Map<String, String> emptyMap = Csv.parseCsvMap("");
        assertEquals(Collections.emptyMap(), emptyMap);

        String kvPairsIpV6 = "a:b:c:v,a:b:c:v";
        Map<String, String> ipv6Map = Csv.parseCsvMap(kvPairsIpV6);
        for (Map.Entry<String, String> entry : ipv6Map.entrySet()) {
            assertEquals("a:b:c", entry.getKey());
            assertEquals("v", entry.getValue());
        }

        String singleEntry = "key:value";
        Map<String, String> singleMap = Csv.parseCsvMap(singleEntry);
        String value = singleMap.get("key");
        assertEquals("value", value);

        String kvPairsIpV4 = "192.168.2.1/30:allow, 192.168.2.1/30:allow";
        Map<String, String> ipv4Map = Csv.parseCsvMap(kvPairsIpV4);
        for (Map.Entry<String, String> entry : ipv4Map.entrySet()) {
            assertEquals("192.168.2.1/30", entry.getKey());
            assertEquals("allow", entry.getValue());
        }

        String kvPairsSpaces = "key:value      , key:   value";
        Map<String, String> spaceMap = Csv.parseCsvMap(kvPairsSpaces);
        for (Map.Entry<String, String> entry : spaceMap.entrySet()) {
            assertEquals("key", entry.getKey());
            assertEquals("value", entry.getValue());
        }
    }