@Test public void testParseStrange() { Map<String, String> props = EventSendCommand.parse(Arrays.asList("a=b","c=d=3", "e=")); assertThat(props.size(), equalTo(3)); assertThat(props.get("a"), equalTo("b")); assertThat(props.get("c"), equalTo("d=3")); assertThat(props.get("e"), equalTo("")); }
static Map<String, String> parse(List<String> propList) { Map<String, String> properties = new HashMap<>(); if (propList != null) { for (String keyValue : propList) { int splitAt = keyValue.indexOf("="); if (splitAt <= 0) { throw new IllegalArgumentException("Invalid property " + keyValue); } else { String key = keyValue.substring(0, splitAt); String value = keyValue.substring(splitAt + 1); properties.put(key, value); } } } return properties; }
EventSendCommand implements Action { static Map<String, String> parse(List<String> propList) { Map<String, String> properties = new HashMap<>(); if (propList != null) { for (String keyValue : propList) { int splitAt = keyValue.indexOf("="); if (splitAt <= 0) { throw new IllegalArgumentException("Invalid property " + keyValue); } else { String key = keyValue.substring(0, splitAt); String value = keyValue.substring(splitAt + 1); properties.put(key, value); } } } return properties; } }
EventSendCommand implements Action { static Map<String, String> parse(List<String> propList) { Map<String, String> properties = new HashMap<>(); if (propList != null) { for (String keyValue : propList) { int splitAt = keyValue.indexOf("="); if (splitAt <= 0) { throw new IllegalArgumentException("Invalid property " + keyValue); } else { String key = keyValue.substring(0, splitAt); String value = keyValue.substring(splitAt + 1); properties.put(key, value); } } } return properties; }  }
EventSendCommand implements Action { static Map<String, String> parse(List<String> propList) { Map<String, String> properties = new HashMap<>(); if (propList != null) { for (String keyValue : propList) { int splitAt = keyValue.indexOf("="); if (splitAt <= 0) { throw new IllegalArgumentException("Invalid property " + keyValue); } else { String key = keyValue.substring(0, splitAt); String value = keyValue.substring(splitAt + 1); properties.put(key, value); } } } return properties; }  @Override Object execute(); }
EventSendCommand implements Action { static Map<String, String> parse(List<String> propList) { Map<String, String> properties = new HashMap<>(); if (propList != null) { for (String keyValue : propList) { int splitAt = keyValue.indexOf("="); if (splitAt <= 0) { throw new IllegalArgumentException("Invalid property " + keyValue); } else { String key = keyValue.substring(0, splitAt); String value = keyValue.substring(splitAt + 1); properties.put(key, value); } } } return properties; }  @Override Object execute();  }