@Test public void testArgumentToArray() { final Map<String, String> arguments = Arguments.loadArguments(STRINGS); Assert.assertNotNull(arguments); final String[] result = Arguments.argumentToArray(arguments); Assert.assertNotNull(result); Assert.assertTrue("Array must be equals", result.length == STRINGS.length); for (int i = 0; i < STRINGS.length; i++) { Assert.assertTrue("Result must contains '" + STRINGS[i] + "'", lookup(result, STRINGS[i])); } }
public static String[] argumentToArray(final Map<String, String> arguments) { final List<String> result = new ArrayList<>(); arguments.entrySet().forEach( entry -> { if (entry.getKey().equals(entry.getValue())) { result.add(entry.getKey()); } else { if (entry.getValue().equals(Boolean.TRUE.toString())) { result.add("--" + entry.getKey()); } else { result.add("--" + entry.getKey() + "=" + entry.getValue()); } } } ); return result.toArray(new String[]{}); }
Arguments { public static String[] argumentToArray(final Map<String, String> arguments) { final List<String> result = new ArrayList<>(); arguments.entrySet().forEach( entry -> { if (entry.getKey().equals(entry.getValue())) { result.add(entry.getKey()); } else { if (entry.getValue().equals(Boolean.TRUE.toString())) { result.add("--" + entry.getKey()); } else { result.add("--" + entry.getKey() + "=" + entry.getValue()); } } } ); return result.toArray(new String[]{}); } }
Arguments { public static String[] argumentToArray(final Map<String, String> arguments) { final List<String> result = new ArrayList<>(); arguments.entrySet().forEach( entry -> { if (entry.getKey().equals(entry.getValue())) { result.add(entry.getKey()); } else { if (entry.getValue().equals(Boolean.TRUE.toString())) { result.add("--" + entry.getKey()); } else { result.add("--" + entry.getKey() + "=" + entry.getValue()); } } } ); return result.toArray(new String[]{}); }  }
Arguments { public static String[] argumentToArray(final Map<String, String> arguments) { final List<String> result = new ArrayList<>(); arguments.entrySet().forEach( entry -> { if (entry.getKey().equals(entry.getValue())) { result.add(entry.getKey()); } else { if (entry.getValue().equals(Boolean.TRUE.toString())) { result.add("--" + entry.getKey()); } else { result.add("--" + entry.getKey() + "=" + entry.getValue()); } } } ); return result.toArray(new String[]{}); }  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 String[] argumentToArray(final Map<String, String> arguments) { final List<String> result = new ArrayList<>(); arguments.entrySet().forEach( entry -> { if (entry.getKey().equals(entry.getValue())) { result.add(entry.getKey()); } else { if (entry.getValue().equals(Boolean.TRUE.toString())) { result.add("--" + entry.getKey()); } else { result.add("--" + entry.getKey() + "=" + entry.getValue()); } } } ); return result.toArray(new String[]{}); }  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);  }