@Test public void testSplitWithSingleValue() throws Exception { List<String> strings = Select2MultiChoice.splitInput("A"); assertEquals(1, strings.size()); assertEquals("A", strings.get(0)); }
static List<String> splitInput(String input) { if (input.startsWith("{") && input.endsWith("}")) { List<String> result = new ArrayList<String>(); int openBracket = 0; Integer lastStartIdx = null; for (int i = 0; i < input.length(); i++) { char c = input.charAt(i); if (c == '{') { openBracket++; if (lastStartIdx == null) { lastStartIdx = i; } } if (c == '}') { openBracket--; if (openBracket == 0) { String substring = input.substring(lastStartIdx, i + 1); result.add(substring); lastStartIdx = null; } } } return result; } return Arrays.asList(input.split(",")); }
Select2MultiChoice extends AbstractSelect2Choice<T, Collection<T>> { static List<String> splitInput(String input) { if (input.startsWith("{") && input.endsWith("}")) { List<String> result = new ArrayList<String>(); int openBracket = 0; Integer lastStartIdx = null; for (int i = 0; i < input.length(); i++) { char c = input.charAt(i); if (c == '{') { openBracket++; if (lastStartIdx == null) { lastStartIdx = i; } } if (c == '}') { openBracket--; if (openBracket == 0) { String substring = input.substring(lastStartIdx, i + 1); result.add(substring); lastStartIdx = null; } } } return result; } return Arrays.asList(input.split(",")); } }
Select2MultiChoice extends AbstractSelect2Choice<T, Collection<T>> { static List<String> splitInput(String input) { if (input.startsWith("{") && input.endsWith("}")) { List<String> result = new ArrayList<String>(); int openBracket = 0; Integer lastStartIdx = null; for (int i = 0; i < input.length(); i++) { char c = input.charAt(i); if (c == '{') { openBracket++; if (lastStartIdx == null) { lastStartIdx = i; } } if (c == '}') { openBracket--; if (openBracket == 0) { String substring = input.substring(lastStartIdx, i + 1); result.add(substring); lastStartIdx = null; } } } return result; } return Arrays.asList(input.split(",")); } Select2MultiChoice(String id, IModel<Collection<T>> model, ChoiceProvider<T> provider);  Select2MultiChoice(String id, IModel<Collection<T>> model);  Select2MultiChoice(String id); }
Select2MultiChoice extends AbstractSelect2Choice<T, Collection<T>> { static List<String> splitInput(String input) { if (input.startsWith("{") && input.endsWith("}")) { List<String> result = new ArrayList<String>(); int openBracket = 0; Integer lastStartIdx = null; for (int i = 0; i < input.length(); i++) { char c = input.charAt(i); if (c == '{') { openBracket++; if (lastStartIdx == null) { lastStartIdx = i; } } if (c == '}') { openBracket--; if (openBracket == 0) { String substring = input.substring(lastStartIdx, i + 1); result.add(substring); lastStartIdx = null; } } } return result; } return Arrays.asList(input.split(",")); } Select2MultiChoice(String id, IModel<Collection<T>> model, ChoiceProvider<T> provider);  Select2MultiChoice(String id, IModel<Collection<T>> model);  Select2MultiChoice(String id); @Override void convertInput(); @Override void updateModel(); }
Select2MultiChoice extends AbstractSelect2Choice<T, Collection<T>> { static List<String> splitInput(String input) { if (input.startsWith("{") && input.endsWith("}")) { List<String> result = new ArrayList<String>(); int openBracket = 0; Integer lastStartIdx = null; for (int i = 0; i < input.length(); i++) { char c = input.charAt(i); if (c == '{') { openBracket++; if (lastStartIdx == null) { lastStartIdx = i; } } if (c == '}') { openBracket--; if (openBracket == 0) { String substring = input.substring(lastStartIdx, i + 1); result.add(substring); lastStartIdx = null; } } } return result; } return Arrays.asList(input.split(",")); } Select2MultiChoice(String id, IModel<Collection<T>> model, ChoiceProvider<T> provider);  Select2MultiChoice(String id, IModel<Collection<T>> model);  Select2MultiChoice(String id); @Override void convertInput(); @Override void updateModel();  }