@Test public void testExtractMap() { assertThat(TypeNameValue.extractMap(null)).isEmpty(); assertThat(TypeNameValue.extractMap("")).isEmpty(); assertThat(TypeNameValue.extractMap("x-key1-x")).isEqualTo(ImmutableMap.of("x-key1-x", "")); assertThat(TypeNameValue.extractMap("x-key1-x,x-key2-x")).isEqualTo(ImmutableMap.of("x-key1-x", "", "x-key2-x", "")); assertThat(TypeNameValue.extractMap("x-key1-x=x-value1-x")).isEqualTo(ImmutableMap.of("x-key1-x", "x-value1-x")); assertThat(TypeNameValue.extractMap("x-key1-x=x-value1-x,y-key2-y=y-value2-y")) .isEqualTo(ImmutableMap.of("x-key1-x", "x-value1-x", "y-key2-y", "y-value2-y")); assertThat(TypeNameValue.extractMap("x-key1-x=x-value1-x,y-key2-y=y-value2-y,z-key3-z=z-value3-z")) .isEqualTo(ImmutableMap.of("x-key1-x", "x-value1-x", "y-key2-y", "y-value2-y", "z-key3-z", "z-value3-z")); assertThat(TypeNameValue.extractMap("x-key1-x=x-value1-x,y-key2-y,yy-key2.5-yy=a=1,z-key3-z=z-value3-z")) .isEqualTo(ImmutableMap.of("x-key1-x", "x-value1-x", "y-key2-y", "", "yy-key2.5-yy", "a=1", "z-key3-z", "z-value3-z")); }
public static Map<String, String> extractMap(String typeNameStr) { if (typeNameStr == null) { return Collections.emptyMap(); } Map<String, String> result = newHashMap(); for (TypeNameValue typeNameValue : extract(typeNameStr)) { result.put(typeNameValue.getKey(), typeNameValue.getValue()); } return result; }
TypeNameValue { public static Map<String, String> extractMap(String typeNameStr) { if (typeNameStr == null) { return Collections.emptyMap(); } Map<String, String> result = newHashMap(); for (TypeNameValue typeNameValue : extract(typeNameStr)) { result.put(typeNameValue.getKey(), typeNameValue.getValue()); } return result; } }
TypeNameValue { public static Map<String, String> extractMap(String typeNameStr) { if (typeNameStr == null) { return Collections.emptyMap(); } Map<String, String> result = newHashMap(); for (TypeNameValue typeNameValue : extract(typeNameStr)) { result.put(typeNameValue.getKey(), typeNameValue.getValue()); } return result; } TypeNameValue(String key, String value);  TypeNameValue(String key); }
TypeNameValue { public static Map<String, String> extractMap(String typeNameStr) { if (typeNameStr == null) { return Collections.emptyMap(); } Map<String, String> result = newHashMap(); for (TypeNameValue typeNameValue : extract(typeNameStr)) { result.put(typeNameValue.getKey(), typeNameValue.getValue()); } return result; } TypeNameValue(String key, String value);  TypeNameValue(String key); static Iterable<TypeNameValue> extract(final String typeNameStr); static Map<String, String> extractMap(String typeNameStr); }
TypeNameValue { public static Map<String, String> extractMap(String typeNameStr) { if (typeNameStr == null) { return Collections.emptyMap(); } Map<String, String> result = newHashMap(); for (TypeNameValue typeNameValue : extract(typeNameStr)) { result.put(typeNameValue.getKey(), typeNameValue.getValue()); } return result; } TypeNameValue(String key, String value);  TypeNameValue(String key); static Iterable<TypeNameValue> extract(final String typeNameStr); static Map<String, String> extractMap(String typeNameStr);  }