@Test public void testParsing() { final List<String> actual = FEELListParser.parse(input); assertThat(actual.size()).isEqualTo(expected.length); assertThat(actual).containsExactly(expected); }
public static List<String> parse(final String input) { final List<String> items = new ArrayList<>(); if (Objects.isNull(input)) { return items; } int start = 0; boolean inQuotes = false; for (int current = 0; current < input.length(); current++) { if (input.charAt(current) == '\"') { inQuotes = !inQuotes; } final boolean atLastChar = (current == input.length() - 1); if (atLastChar) { items.add(input.substring(start).trim()); } else if (input.charAt(current) == ',' && !inQuotes) { items.add(input.substring(start, current).trim()); start = current + 1; } } return items; }
FEELListParser { public static List<String> parse(final String input) { final List<String> items = new ArrayList<>(); if (Objects.isNull(input)) { return items; } int start = 0; boolean inQuotes = false; for (int current = 0; current < input.length(); current++) { if (input.charAt(current) == '\"') { inQuotes = !inQuotes; } final boolean atLastChar = (current == input.length() - 1); if (atLastChar) { items.add(input.substring(start).trim()); } else if (input.charAt(current) == ',' && !inQuotes) { items.add(input.substring(start, current).trim()); start = current + 1; } } return items; } }
FEELListParser { public static List<String> parse(final String input) { final List<String> items = new ArrayList<>(); if (Objects.isNull(input)) { return items; } int start = 0; boolean inQuotes = false; for (int current = 0; current < input.length(); current++) { if (input.charAt(current) == '\"') { inQuotes = !inQuotes; } final boolean atLastChar = (current == input.length() - 1); if (atLastChar) { items.add(input.substring(start).trim()); } else if (input.charAt(current) == ',' && !inQuotes) { items.add(input.substring(start, current).trim()); start = current + 1; } } return items; }  }
FEELListParser { public static List<String> parse(final String input) { final List<String> items = new ArrayList<>(); if (Objects.isNull(input)) { return items; } int start = 0; boolean inQuotes = false; for (int current = 0; current < input.length(); current++) { if (input.charAt(current) == '\"') { inQuotes = !inQuotes; } final boolean atLastChar = (current == input.length() - 1); if (atLastChar) { items.add(input.substring(start).trim()); } else if (input.charAt(current) == ',' && !inQuotes) { items.add(input.substring(start, current).trim()); start = current + 1; } } return items; }  static List<String> parse(final String input); }
FEELListParser { public static List<String> parse(final String input) { final List<String> items = new ArrayList<>(); if (Objects.isNull(input)) { return items; } int start = 0; boolean inQuotes = false; for (int current = 0; current < input.length(); current++) { if (input.charAt(current) == '\"') { inQuotes = !inQuotes; } final boolean atLastChar = (current == input.length() - 1); if (atLastChar) { items.add(input.substring(start).trim()); } else if (input.charAt(current) == ',' && !inQuotes) { items.add(input.substring(start, current).trim()); start = current + 1; } } return items; }  static List<String> parse(final String input);  }