@SuppressWarnings("unchecked") @Test public void testStringParsing() { message = "string should be parsed appropriately"; ArrayList<String> defaultTags = new ArrayList<String>(); defaultTags.add("TagName1"); defaultTags.add("TagName2"); defaultTags.add("TagName3"); Collection actual = formatter.parse("TagName1, TagName2, TagName3"); assertArrayEquals(message, defaultTags.toArray(), actual.toArray()); actual = formatter.parse("TagName1, TagName2, TagName3,, ,"); assertArrayEquals(message, defaultTags.toArray(), actual.toArray()); actual = formatter.parse(""); assertArrayEquals(message, new String[]{}, actual.toArray()); }
public Collection<String> parse(final String toParse) { String[] stringArray = toParse.split(DELIMITER); ArrayList<String> strings = new ArrayList<String>(); for (String stringName : stringArray) { String name = stringName.trim(); if (name.length() > 0) { strings.add(name); } } return strings; }
CollectionFormat { public Collection<String> parse(final String toParse) { String[] stringArray = toParse.split(DELIMITER); ArrayList<String> strings = new ArrayList<String>(); for (String stringName : stringArray) { String name = stringName.trim(); if (name.length() > 0) { strings.add(name); } } return strings; } }
CollectionFormat { public Collection<String> parse(final String toParse) { String[] stringArray = toParse.split(DELIMITER); ArrayList<String> strings = new ArrayList<String>(); for (String stringName : stringArray) { String name = stringName.trim(); if (name.length() > 0) { strings.add(name); } } return strings; } CollectionFormat(); }
CollectionFormat { public Collection<String> parse(final String toParse) { String[] stringArray = toParse.split(DELIMITER); ArrayList<String> strings = new ArrayList<String>(); for (String stringName : stringArray) { String name = stringName.trim(); if (name.length() > 0) { strings.add(name); } } return strings; } CollectionFormat(); Collection<String> parse(final String toParse); @SuppressWarnings("unchecked") String format(final Collection elements); }
CollectionFormat { public Collection<String> parse(final String toParse) { String[] stringArray = toParse.split(DELIMITER); ArrayList<String> strings = new ArrayList<String>(); for (String stringName : stringArray) { String name = stringName.trim(); if (name.length() > 0) { strings.add(name); } } return strings; } CollectionFormat(); Collection<String> parse(final String toParse); @SuppressWarnings("unchecked") String format(final Collection elements); static final String DELIMITER; }