Source:
<code>public Map<String, Object> parse(List<String> args) throws Exception { List<String> others = new ArrayList<>(); Map<String, Object> argMap = new HashMap<>(); args.addAll(defaults); while(!args.isEmpty()) { String arg = args.remove(0); if(arg.equals(LONG_PREFIX)) { break; } if(!arg.startsWith(LONG_PREFIX)) { others.add(arg); break; } <START> String[] argVal = parseArgument(arg.substring(2)); <END> ParserArgument parserArgument = arguments.get(argVal[0]); if(parserArgument == null) { throw new IllegalArgumentException( String.format("Argument %1$s is not valid", arg) ); } if(parserArgument.getType() == ArgumentType.required_argument && argVal[1] == null) { throw new IllegalArgumentException( String.format("Argument's '%1$s' value is required", argVal[0]) ); } Matcher m = parserArgument.getMatcher().matcher(argVal[1]); if (!m.find()) { throw new IllegalArgumentException( String.format( "Argument's '%1$s' value don't match pattern: ", parserArgument.getMatcher().pattern() ) ); } if(!argMap.containsKey(argVal[0])) { argMap.put( argVal[0], Util.getObjectValueByString(parserArgument.getConvert(), argVal[1]) ); } } mandatory.removeAll(argMap.keySet()); if(!mandatory.isEmpty()) { throw new IllegalArgumentException( String.format("Argument(s) '%1$s' required", StringUtils.join(mandatory, ", ")) ); } others.addAll(args); argMap.put("__other__", others); return argMap; }</code><technical_language>please set key name indexes over</technical_language>

Target:
public Map<String, Object> parse(List<String> args) throws Exception { List<Object> others = new ArrayList<>(); Map<String, Object> argMap = new HashMap<>(); args.addAll(defaults); while(!args.isEmpty()) { String arg = args.remove(0); if(arg.equals(LONG_PREFIX)) { break; } if(!arg.startsWith(LONG_PREFIX)) { others.add(arg); break; } String[] argVal = parseArgument(arg.substring(2)); String key = argVal[0]; String value = argVal[1]; ParserArgument parserArgument = arguments.get(key); if(parserArgument == null) { throw new IllegalArgumentException( String.format("Argument %1$s is not valid", arg) ); } if ( value == null && parserArgument.getType() == ArgumentType.optional_argument || parserArgument.getType() == ArgumentType.required_argument ) { value = args.remove(0); if(value.equals(LONG_PREFIX)) { break; } } if(parserArgument.getType() == ArgumentType.required_argument && value == null) { throw new IllegalArgumentException( String.format("Argument's '%1$s' value is required", key) ); } Matcher m = parserArgument.getMatcher().matcher(value); if (!m.find()) { throw new IllegalArgumentException( String.format( "Argument's '%1$s' value don't match pattern: ", m.pattern() ) ); } Object convertedValue = Util.getObjectValueByString(parserArgument.getConvert(), value); if(!argMap.containsKey(key)) { argMap.put(key, convertedValue); } else { List<Object> objects = new ArrayList<>(); objects.add(argMap.get(key)); objects.add(convertedValue); argMap.put(key, objects); } } mandatory.removeAll(argMap.keySet()); if(!mandatory.isEmpty()) { throw new IllegalArgumentException( String.format("Argument(s) '%1$s' required", StringUtils.join(mandatory, ", ")) ); } others.addAll(args); argMap.put("__other__", others); return argMap; }