@Test public void testLoadArgumentOther() { final Map<String, String> arguments = Arguments.loadArguments(STRINGS); Assert.assertNotNull("Expected 'single' key", arguments.get("single")); Assert.assertEquals("Expected 'single'", arguments.get("single"), "single"); Assert.assertNotNull("Expected '-dummy' key", arguments.get("-dummy")); Assert.assertNull("Expected no key 'dummy' ", arguments.get("dummy")); Assert.assertEquals("Expected '-dummy'", arguments.get("-dummy"), "-dummy"); Assert.assertNotNull("Expected '-other=value' key", arguments.get("-other=value")); Assert.assertNull("Expected no key 'other' ", arguments.get("other")); Assert.assertEquals("Expected '-other=value'", arguments.get("-other=value"), "-other=value"); }
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);  }