Arguments { static List<String> combineAdjacentIfReasonable(String[] args) { List<String> joinedArgs = new ArrayList<>(); for (int i = 0; i < args.length; i++) { String arg = args[i]; if (looksLikeKey(arg) && endsWithJoinOperator(arg)&& i+1 < args.length && !looksLikeKey(args[i+1])) { joinedArgs.add(args[i]+args[i+1]); i++; } else { joinedArgs.add(args[i]); } } return joinedArgs; }  static Parameters parse(String[] args);  }
@Test public void testCombineAdjacentIfReasonable() throws Exception { assertEquals( Arrays.asList( "--foo=1", "--bar=2", "--baz+3", "--zed+"), Arguments.combineAdjacentIfReasonable(new String[] { "--foo=", "1", "--bar=2", "--baz+", "3", "--zed+"})); assertEquals( Arrays.asList( "--bar=", "--baz"), Arguments.combineAdjacentIfReasonable(new String[] { "--bar=", "--baz"})); }