@Test public void testLoadArgumentKeyValue() { final Map<String, String> arguments = Arguments.loadArguments(STRINGS); Assert.assertNotNull("Expected 'name' titi", arguments.get("titi")); Assert.assertEquals("Expected 'tutu'", arguments.get("titi"), "tutu"); }
public static Map<String, String> loadArguments(final String[] argv) { final Map<String, String> result = new HashMap<>(); if (argv != null) { for (int i = 0; i < argv.length; i++) { final String option = argv[i]; if (option.startsWith("--")) { final int equalPos = option.indexOf('='); final String paramName = option.substring(2, equalPos == -1 ? option.length() : equalPos); if (equalPos != -1) { result.put(paramName, option.substring(equalPos + 1)); } else { result.put(paramName, Boolean.TRUE.toString()); } } else { result.put(option, option); } } } return result; }
Arguments { public static Map<String, String> loadArguments(final String[] argv) { final Map<String, String> result = new HashMap<>(); if (argv != null) { for (int i = 0; i < argv.length; i++) { final String option = argv[i]; if (option.startsWith("--")) { final int equalPos = option.indexOf('='); final String paramName = option.substring(2, equalPos == -1 ? option.length() : equalPos); if (equalPos != -1) { result.put(paramName, option.substring(equalPos + 1)); } else { result.put(paramName, Boolean.TRUE.toString()); } } else { result.put(option, option); } } } return result; } }
Arguments { public static Map<String, String> loadArguments(final String[] argv) { final Map<String, String> result = new HashMap<>(); if (argv != null) { for (int i = 0; i < argv.length; i++) { final String option = argv[i]; if (option.startsWith("--")) { final int equalPos = option.indexOf('='); final String paramName = option.substring(2, equalPos == -1 ? option.length() : equalPos); if (equalPos != -1) { result.put(paramName, option.substring(equalPos + 1)); } else { result.put(paramName, Boolean.TRUE.toString()); } } else { result.put(option, option); } } } return result; }  }
Arguments { public static Map<String, String> loadArguments(final String[] argv) { final Map<String, String> result = new HashMap<>(); if (argv != null) { for (int i = 0; i < argv.length; i++) { final String option = argv[i]; if (option.startsWith("--")) { final int equalPos = option.indexOf('='); final String paramName = option.substring(2, equalPos == -1 ? option.length() : equalPos); if (equalPos != -1) { result.put(paramName, option.substring(equalPos + 1)); } else { result.put(paramName, Boolean.TRUE.toString()); } } else { result.put(option, option); } } } return result; }  static Map<String, String> loadArguments(final String[] argv); static String[] argumentToArray(final Map<String, String> arguments); static Map<String, String> loadArguments(final String[] argv, final String name); static Boolean getBooleanArgument(final Map<String, String> args, final String name, final Boolean defaultTrue); static String getStringArgument(final Map<String, String> args, final String name, final String defaultValue); static Integer getIntegerArgument(final Map<String, String> args, final String name, final Integer defaultValue); }
Arguments { public static Map<String, String> loadArguments(final String[] argv) { final Map<String, String> result = new HashMap<>(); if (argv != null) { for (int i = 0; i < argv.length; i++) { final String option = argv[i]; if (option.startsWith("--")) { final int equalPos = option.indexOf('='); final String paramName = option.substring(2, equalPos == -1 ? option.length() : equalPos); if (equalPos != -1) { result.put(paramName, option.substring(equalPos + 1)); } else { result.put(paramName, Boolean.TRUE.toString()); } } else { result.put(option, option); } } } return result; }  static Map<String, String> loadArguments(final String[] argv); static String[] argumentToArray(final Map<String, String> arguments); static Map<String, String> loadArguments(final String[] argv, final String name); static Boolean getBooleanArgument(final Map<String, String> args, final String name, final Boolean defaultTrue); static String getStringArgument(final Map<String, String> args, final String name, final String defaultValue); static Integer getIntegerArgument(final Map<String, String> args, final String name, final Integer defaultValue);  }