Find the command-line arg corresponding to the parameter {@code arg}.

@param arg
@return The corresponding arg or null.
329261
private static CommandLineArgument findCommandLineOption(String arg) {
        for (CommandLineArgument commandLineArgument : CommandLineArgument.values()) {
            if (commandLineArgument.match(arg)) {
                return commandLineArgument;
            }
        }
        return null;
    }
738503
@SuppressWarnings("unchecked")
    public static <K, V> Long getFirstInteger(CommandArgs<K, V> commandArgs) {

        for (SingularArgument singularArgument : commandArgs.singularArguments) {

            if (singularArgument instanceof CommandArgs.IntegerArgument) {
                return ((CommandArgs.IntegerArgument) singularArgument).val;
            }
        }

        return null;
    }
715467
public static <T extends CharSequence> T checkArgNotNullOrEmptyOrBlank(final T arg, final String msg) {
        if (N.isNullOrEmptyOrBlank(arg)) {
            if (isNullErrorMsg(msg)) {
                throw new IllegalArgumentException(msg);
            } else {
                throw new IllegalArgumentException("'" + msg + "' can not be null or empty or blank");
            }
        }

        return arg;
    }
157984
private static String[] harvestApplicationWithArguments(String arg)
    {
        List<String> args = new ArrayList<>();

        if (arg.trim().length() >= 0)
        {
            String appl = "", data = "";

            /* Find the first occurrence of either '(' or ',' */
            int firstc = arg.indexOf(',');
            int firstp = arg.indexOf('(');

            if (firstc != -1 && (firstp == -1 || firstc < firstp))
            {
                /* comma found, no parenthesis */
                /* or both found, but comma found first */
                String[] split = arg.split(",");
                appl = split[0];
                for (int i = 1; i < split.length; i++)
                    data += split[i] + (i + 1 < split.length ? "," : "");
            }
            else if (firstc == -1 && firstp == -1)
            {
                /* Neither found */
                data = "";
            }
            else
            {
                /* Final remaining case is parenthesis found first */
                String[] split = arg.split("\\(");
                appl = split[0];
                for (int i = 1; i < split.length; i++)
                    data += split[i] + (i + 1 < split.length ? "(" : "");
                int end = data.lastIndexOf(')');
                if (end == -1)
                {
                    // ast_log(LOG_WARNING, "No closing parenthesis found?
                    // '%s(%s'\n", appl, data);
                }
                else if (end == data.length() - 1)
                {
                    data = data.substring(0, end);
                }
                data = processQuotesAndSlashes(data, ',', '|');
            }

            if (!appl.trim().equals(""))
            {
                args.add(appl.trim());
                if (!data.trim().equals(""))
                {
                    String[] dataSplit = data.split("\\|");
                    for (String aDataSplit : dataSplit)
                    {
                        args.add(aDataSplit.trim());
                    }
                }
            }
        }

        return args.toArray(new String[args.size()]);
    }
307630
static String getArgumentTypesAsString(Object... arguments) {
        StringBuilder argumentsAsString = new StringBuilder();
        final String noParameters = "<none>";
        if (arguments != null && arguments.length != 0) {
            for (int i = 0; i < arguments.length; i++) {
                String argumentName = null;
                Object argument = arguments[i];

                if (argument instanceof Class<?>) {
                    argumentName = ((Class<?>) argument).getName();
                } else if (argument instanceof Class<?>[] && arguments.length == 1) {
                    Class<?>[] argumentArray = (Class<?>[]) argument;
                    if (argumentArray.length > 0) {
                        for (int j = 0; j < argumentArray.length; j++) {
                            appendArgument(argumentsAsString, j,
                                    argumentArray[j] == null ? "null" : getUnproxyType(argumentArray[j]).getName(),
                                    argumentArray);
                        }
                        return argumentsAsString.toString();
                    } else {
                        argumentName = noParameters;
                    }
                } else if (argument == null) {
                    argumentName = "null";
                } else {
                    argumentName = getUnproxyType(argument).getName();
                }
                appendArgument(argumentsAsString, i, argumentName, arguments);
            }
        } else {
            argumentsAsString.append("<none>");
        }
        return argumentsAsString.toString();
    }
1186150
protected String getArgString(Object arg) {
        //if (arg instanceof LatLong) {
        //    return ((LatLong) arg).getVariableName();
        //} else 
        if (arg instanceof JavascriptObject) {
             return ((JavascriptObject) arg).getVariableName();
           // return ((JavascriptObject) arg).getPropertiesAsString();
        } else if( arg instanceof JavascriptEnum ) {
            return ((JavascriptEnum) arg).getEnumValue().toString();
        } else {
            return arg.toString();
        }
    }
862363
public static int getGCD(int... arg) throws Exception {
        if (arg == null || arg.length == 0) {
            throw new Exception("parameters must more than one.");
        }
        if (arg.length == 1) {
            return Math.abs(arg[0]);
        }

        int tmp = gcd(arg[0], arg[1]);

        for (int i = 2; i < arg.length; i++) {
            tmp = gcd(tmp, arg[i]);
        }

        return tmp;
    }
1084193
@SafeVarargs
	public static <T> T firstNotNull(T... args) {
		for (T arg : args) {
			if (arg != null)
				return arg;
		}
		return null;
	}
493528
public static JUnitCommandLineParseResult parse(String[] args) {
        JUnitCommandLineParseResult result = new JUnitCommandLineParseResult();

        result.parseArgs(args);

        return result;
    }
535680
public CliCommandBuilder addCliArgument(final String arg) {
        if (arg != null) {
            final Argument argument = Arguments.parse(arg);
            final CliArgument cliArgument = CliArgument.find(argument.getKey());
            if (cliArgument != null) {
                // Remove the alternate key if required
                if (cliArgument.altKey != null) {
                    cliArgs.remove(cliArgument.altKey);
                }
            }
            cliArgs.set(argument);
        }
        return this;
    }
459538
@SuppressWarnings("unchecked")
    public static <K, V> String getFirstString(CommandArgs<K, V> commandArgs) {

        for (SingularArgument singularArgument : commandArgs.singularArguments) {

            if (singularArgument instanceof StringArgument) {
                return ((StringArgument) singularArgument).val;
            }
        }

        return null;
    }
458896
boolean parseCmdLineArgs(String[] args) throws IllegalArgumentException {
        for (int i = 0; i < args.length; i++) {
            if (args[i].toLowerCase().contains("help") || args[i].toLowerCase().contains("usage")) {
                // print the usage information and exit.
                printUsage();
                return true;
            }
            boolean accepted = false;
            for (Option option : options) {
                if (args[i].equalsIgnoreCase(option.name)) {
                    if (i + option.nargs < args.length) {
                        i += option.accept(args, i + 1);
                    } else {
                        throw new IllegalArgumentException(getLocalizedParmString("CWTRA0022E",
                                                                                  new Object[] { option.name, option.nargs }));
                    }
                    accepted = true;
                    break;
                }
            }
            if (!accepted) {
                throw new IllegalArgumentException(getLocalizedParmString("CWTRA0023E", new Object[] { args[i] }));
            }
        }
        return false;
    }
1241530
public CommandLine parse(String[] args) throws ParseException {
        // create the command line parser
        GnuParser parser = new GnuParser();
        Options buildCommandLineOptions = buildCommandLineOptions();
        CommandLine cmd = null;
        try {
            cmd = parser.parse(buildCommandLineOptions, args);
            if (cmd.getOptions().length == 0 || cmd.hasOption("h")) {
                printHelp(buildCommandLineOptions);
                return null;
            }
            if (cmd.getArgList().isEmpty()) {
                throw new MissingOptionException("The 'inputPage' is mandatory! No page to run given");
            }
            return cmd;
        } catch (MissingOptionException e) {
            if (args == null || args.length == 0) {
                logger.debug("option --help has been set. Ignoring Missing Option exception");
                printHelp(buildCommandLineOptions);
                return cmd;
            }
            for (String arg : args) {
                if (StringUtils.equals("-h", arg) || StringUtils.equals("--help", arg)) {
                    logger.debug("option --help has been set. Ignoring Missing Option exception");
                    printHelp(buildCommandLineOptions);
                    return null;
                }
            }
            handleParseException(buildCommandLineOptions, e);
            throw e;
        } catch (ParseException e) {
            handleParseException(buildCommandLineOptions, e);
            throw e;
        }
    }
685572
public static CliArguments parse(String[] args) {
        CliArguments arguments = new CliArguments();
        if (args != null) {
            CmdLineParser parser = new CmdLineParser(arguments);
            try {
                parser.parseArgument(args);
            } catch (CmdLineException e) {
                // ignore
            }

            arguments.usageMode = false;
            for (String arg : args) {
                for (int i = 0; i < USAGE_TOKENS.length; i++) {
                    String usageToken = USAGE_TOKENS[i];
                    if (usageToken.equalsIgnoreCase(arg)) {
                        arguments.usageMode = true;
                        break;
                    }
                }
            }
        }
        return arguments;
    }
1066205
public static <T> T get(Class<T> clazz, String sql, Object... arg) {
        List<T> list = DBUtils.getList(clazz, sql, arg);
        if (list.isEmpty()) {
            return null;
        }
        return list.get(0);
    }
876602
public String getString(final String key, final Object... args) {
        String value = getString(key);
        if (value == null) {
            value = key;
        }

        MessageFormat mf = new MessageFormat(value);
        mf.setLocale(locale);
        return mf.format(args, new StringBuffer(), null).toString();
    }
903155
protected String getValue(String arg) {
        String[] split = arg.split("=");
        if (split.length == 1) {
            return null;
        } else if (split.length == 2) {
            return split[1];
        } else {
            // Handle DN case with multiple =s
            StringBuffer value = new StringBuffer();
            for (int i = 1; i < split.length; i++) {
                value.append(split[i]);
                if (i < (split.length - 1)) {
                    value.append("=");
                }
            }
            return value.toString();
        }
    }