@Test public void properties_array_to_map() { String[] props = {"key1", "value1", "key2", "value2"}; Map<String, String> map = PropertyUtils.toMap(props); assertThat(map).hasSize(2); assertThat(map.get("key1")).isEqualTo("value1"); assertThat(map.get("key2")).isEqualTo("value2"); }
static Map<String, String> toMap(String[] keyValues) { checkArgument(keyValues.length % 2 == 0, "Must be an even number of key/values"); Map<String, String> map = new HashMap<>(); int index = 0; while (index < keyValues.length) { String key = keyValues[index++]; String value = keyValues[index++]; map.put(key, value); } return map; }
PropertyUtils { static Map<String, String> toMap(String[] keyValues) { checkArgument(keyValues.length % 2 == 0, "Must be an even number of key/values"); Map<String, String> map = new HashMap<>(); int index = 0; while (index < keyValues.length) { String key = keyValues[index++]; String value = keyValues[index++]; map.put(key, value); } return map; } }
PropertyUtils { static Map<String, String> toMap(String[] keyValues) { checkArgument(keyValues.length % 2 == 0, "Must be an even number of key/values"); Map<String, String> map = new HashMap<>(); int index = 0; while (index < keyValues.length) { String key = keyValues[index++]; String value = keyValues[index++]; map.put(key, value); } return map; } private  PropertyUtils(); }
PropertyUtils { static Map<String, String> toMap(String[] keyValues) { checkArgument(keyValues.length % 2 == 0, "Must be an even number of key/values"); Map<String, String> map = new HashMap<>(); int index = 0; while (index < keyValues.length) { String key = keyValues[index++]; String value = keyValues[index++]; map.put(key, value); } return map; } private  PropertyUtils();  }
PropertyUtils { static Map<String, String> toMap(String[] keyValues) { checkArgument(keyValues.length % 2 == 0, "Must be an even number of key/values"); Map<String, String> map = new HashMap<>(); int index = 0; while (index < keyValues.length) { String key = keyValues[index++]; String value = keyValues[index++]; map.put(key, value); } return map; } private  PropertyUtils();   }