Argument { public static List<Argument> split(String... typesAndNames) { List<Argument> arguments = new ArrayList<Argument>(); if (typesAndNames.length == 1) { String line = typesAndNames[0].trim(); if (line.length() == 0) { return arguments; } int last = 0; int parenCount = 0; int current = 0; for (; current < line.length(); current++) { if (line.charAt(current) == '<') { parenCount++; } else if (line.charAt(current) == '>') { parenCount--; } else if (line.charAt(current) == ',' && parenCount == 0) { arguments.add(new Argument(line.substring(last, current))); last = current + 1; } } arguments.add(new Argument(line.substring(last, current))); } else { for (String typeAndName : typesAndNames) { arguments.add(new Argument(typeAndName)); } } return arguments; } Argument(String typeAndName);  Argument(String type, String name); static Argument arg(Class<?> type, String name); static Argument arg(String type, String name); static List<Argument> split(String... typesAndNames); Argument importIfPossible(GClass gclass); String toString(); final String type; final String name; }
@Test public void testSplit() { final String[] e1 = { "Foo f", "Bar f" }; final String[] i1 = { "Foo f", "Bar f" }; this.assertSplit(e1, i1); final String[] e2 = { "Foo f", "Bar f" }; final String[] i2 = { "Foo f, Bar f" }; this.assertSplit(e2, i2); final String[] e3 = { "Foo<String, String> f", "Bar<Integer, Integer> b" }; final String[] i3 = { "Foo<String, String> f, Bar<Integer, Integer> b" }; this.assertSplit(e3, i3); final String[] e4 = { "Foo<String,String> f", "Bar<Integer,Integer> b" }; final String[] i4 = { "Foo<String,String> f,Bar<Integer,Integer> b" }; this.assertSplit(e4, i4); }