ExtensionLoader { static Map<String, String> parseExtAttribute(String attribute) { Map<String, String> ret = new HashMap<String, String>(); if (attribute == null || attribute.length() == 0) return ret; String[] parts = attribute.split(","); for (String part : parts) { part = part.trim(); int idx = part.indexOf('='); if (idx > 0) { ret.put(part.substring(0, idx).trim(), part.substring(idx + 1).trim()); } else { ret.put(part, ""); } } return ret; } private  ExtensionLoader(Class<T> type); @SuppressWarnings("unchecked") static ExtensionLoader<T> getExtensionLoader(Class<T> type); void registerExtension(String name, T extension); void registerExtension(String name, T extension, boolean override); T getExtension(String name); T getExtension(String name, Map<String, String> properties); T getExtension(Map<String, String> properties); T getExtension(String name, List<String> wrappers); T getExtension(String name, Map<String, String> properties, List<String> wrappers); T getDefaultExtension(); T getDefaultExtension(List<String> wrappers); boolean hasExtension(String name); boolean hasDefaultExtension(); Set<String> getSupportedExtensions(); String getDefaultExtensionName(); Map<String, Map<String, String>> getExtensionAttribute(); Map<String, String> getExtensionAttribute(String name); @Override String toString();  }
@Test public void test_parseExtAttribute() throws Exception { assertEquals(Utils.kv2Map("k1", "v1", "k2", "v2"), ExtensionLoader.parseExtAttribute("k1=v1,k2=v2")); assertEquals(Utils.kv2Map("k1", "v1", "k2", "v2", "k3", ""), ExtensionLoader.parseExtAttribute(" k1 =v1, k2= v2 , k3 ")); assertEquals(Utils.kv2Map("k1", ""), ExtensionLoader.parseExtAttribute("k1")); }