@Test public void testGetArgument01() { Optional<String> v = ArgumentParseUtil.getArgument(new String[]{"-a", "value"}, "-a", "--a"); assertTrue(v.isPresent()); assertEquals("value", v.get()); }
static Optional<String> getArgument(String[] args, String shortName, String longName) { int i = 0; while (i < args.length && args[i].startsWith("-")) { String arg = args[i++]; if (arg.equals(shortName) || arg.equals(longName)) if (i < args.length) return Optional.fromNullable(args[i]); } return Optional.absent(); }
ArgumentParseUtil { static Optional<String> getArgument(String[] args, String shortName, String longName) { int i = 0; while (i < args.length && args[i].startsWith("-")) { String arg = args[i++]; if (arg.equals(shortName) || arg.equals(longName)) if (i < args.length) return Optional.fromNullable(args[i]); } return Optional.absent(); } }
ArgumentParseUtil { static Optional<String> getArgument(String[] args, String shortName, String longName) { int i = 0; while (i < args.length && args[i].startsWith("-")) { String arg = args[i++]; if (arg.equals(shortName) || arg.equals(longName)) if (i < args.length) return Optional.fromNullable(args[i]); } return Optional.absent(); }  }
ArgumentParseUtil { static Optional<String> getArgument(String[] args, String shortName, String longName) { int i = 0; while (i < args.length && args[i].startsWith("-")) { String arg = args[i++]; if (arg.equals(shortName) || arg.equals(longName)) if (i < args.length) return Optional.fromNullable(args[i]); } return Optional.absent(); }  static String getZooKeeperURL(String[] args); static boolean isAutoRegister(String[] args); static void printUsageHelp(int exitCode); }
ArgumentParseUtil { static Optional<String> getArgument(String[] args, String shortName, String longName) { int i = 0; while (i < args.length && args[i].startsWith("-")) { String arg = args[i++]; if (arg.equals(shortName) || arg.equals(longName)) if (i < args.length) return Optional.fromNullable(args[i]); } return Optional.absent(); }  static String getZooKeeperURL(String[] args); static boolean isAutoRegister(String[] args); static void printUsageHelp(int exitCode);  }