All Downloads are FREE. Search and download functionalities are using the official Maven repository.

brooklyn.util.CommandLineUtil Maven / Gradle / Ivy

Go to download

Utility classes and methods developed for Brooklyn but not dependendent on Brooklyn or much else

There is a newer version: 0.7.0-M1
Show newest version
package brooklyn.util;

import java.util.List;

public class CommandLineUtil {

    public static String getCommandLineOption (List args, String param){
        return getCommandLineOption(args, param, null);
    }

    /** given a list of args, e.g. --name Foo --parent Bob
     * will return "Foo" as param name, and remove those entries from the args list
     */
    public static String getCommandLineOption(List args, String param, String defaultValue) {
        int i = args.indexOf(param);
        if (i >= 0) {
            String result = args.get(i + 1);
            args.remove(i + 1);
            args.remove(i);
            return result;
        } else {
            return defaultValue;
        }
    }

    public static int getCommandLineOptionInt(List args, String param, int defaultValue) {
        String s = getCommandLineOption(args, param,null);
        if (s == null) return defaultValue;
        return Integer.parseInt(s);
    }

    //we don't want instances.
    private CommandLineUtil(){}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy