src/main/java/Parser.java
public static List<Object> parseArgs(String[] args){
        double eps = 0.005;
        ModelType type = null;
        String path = null;
        String saveLocation = "jAlergiaModel";
        OptimizeFor optimizeFor = OptimizeFor.ACCURACY;

        HashSet<String> argNames = new HashSet<>(Arrays.asList("-eps", "-input", "-type", "-save", "-optim"));
        if(args.length == 0 || args[0].equals("-help") || args[0].equals("-h") || args[0].equals("--help")){
            System.out.println(helpDisplayMessage);
            System.exit(0);
        }
        for (int i = 0; i < args.length - 1; i+=2) {
            if(!argNames.contains(args[i])) {
                System.out.println("Unrecognized option '" + args[i] + "'.\nRun Use -help to see all arguments.");
                System.exit(1);
            }

            if(args[i].equals("-eps")){
                try {
                    eps = Double.parseDouble(args[i+1]);
                    if(eps > 2 || eps <= 0){
                        if(eps != -1) {
                            System.out.println("Epsilon values must be a double in range of [2,0> " +
                                    "or -1 for automatic computation of epsilon.");
                            System.exit(1);
                        }
                    }
                } catch (NumberFormatException e) {
                    System.out.println("Epsilon values must be a double in range of [2,0>");
                    e.printStackTrace();
                }
            }
            if(args[i].equals("-input"))
                path = args[i+1];
            if(args[i].equals("-type")){
                switch (args[i + 1]) {
                    case "mdp":
                        type = ModelType.MDP;
                        break;
                    case "smm":
                        type = ModelType.SMM;
                        break;
                    case "mc":
                        type = ModelType.MC;
                        break;
                    default:
                        System.out.println("Invalid -type option. Make sure it is either mdp, smm, or mc.");
                        System.exit(1);
                }
            }
            if(args[i].equals("-save"))
                saveLocation = args[i+1];
            if(args[i].equals("-optim")){
                if(args[i+1].equals("mem"))
                    optimizeFor = OptimizeFor.MEMORY;
                else if (args[i+1].equals("acc"))
                    optimizeFor = OptimizeFor.ACCURACY;
                else {
                    System.out.println("Invalid optimize for option, set to accuracy optimization.");
                    optimizeFor = OptimizeFor.ACCURACY;
                }
            }
        }

        if(path==null) {
            System.out.println("Input file not specified. For more details use -h option.");
            System.exit(1);
        }
        if(type==null){
            System.out.println("Automaton type not specified. For more details use -h option.");
            System.exit(1);
        }
        return Arrays.asList(path, eps, type, saveLocation, optimizeFor);
    }
/**
     * Parses the arguments as defined in helpDisplayMessage;
     * @param args list of arguments
     * @return List of argument values
     */
Parses the arguments as defined in helpDisplayMessage;
@param args list of arguments
@return List of argument values
Parses the arguments as defined in helpDisplayMessage ; @param args list of arguments @return List of argument values
public static List<Object> parseArgs(String[] args){
        double eps = 0.005;
        ModelType type = null;
        String path = null;
        String saveLocation = "jAlergiaModel";
        OptimizeFor optimizeFor = OptimizeFor.ACCURACY;
        HashSet<String> argNames = new HashSet<>(Arrays.asList("-eps", "-input", "-type", "-save", "-optim"));
        if(args.length == 0 || args[0].equals("-help") || args[0].equals("-h") || args[0].equals("--help")){
            System.out.println(helpDisplayMessage);
            System.exit(0);
        }
        for (int i = 0; i < args.length - 1; i+=2) {
            if(!argNames.contains(args[i])) {
                System.out.println("Unrecognized option '" + args[i] + "'.\nRun Use -help to see all arguments.");
                System.exit(1);
            }
            if(args[i].equals("-eps")){
                try {
                    eps = Double.parseDouble(args[i+1]);
                    if(eps > 2 || eps <= 0){
                        if(eps != -1) {
                            System.out.println("Epsilon values must be a double in range of [2,0> " +
                                    "or -1 for automatic computation of epsilon.");
                            System.exit(1);
                        }
                    }
                } catch (NumberFormatException e) {
                    System.out.println("Epsilon values must be a double in range of [2,0>");
                    e.printStackTrace();
                }
            }
            if(args[i].equals("-input"))
                path = args[i+1];
            if(args[i].equals("-type")){
                switch (args[i + 1]) {
                    case "mdp":
                        type = ModelType.MDP;
                        break;
                    case "smm":
                        type = ModelType.SMM;
                        break;
                    case "mc":
                        type = ModelType.MC;
                        break;
                    default:
                        System.out.println("Invalid -type option. Make sure it is either mdp, smm, or mc.");
                        System.exit(1);
                }
            }
            if(args[i].equals("-save"))
                saveLocation = args[i+1];
            if(args[i].equals("-optim")){
                if(args[i+1].equals("mem"))
                    optimizeFor = OptimizeFor.MEMORY;
                else if (args[i+1].equals("acc"))
                    optimizeFor = OptimizeFor.ACCURACY;
                else {
                    System.out.println("Invalid optimize for option, set to accuracy optimization.");
                    optimizeFor = OptimizeFor.ACCURACY;
                }
            }
        }
        if(path==null) {
            System.out.println("Input file not specified. For more details use -h option.");
            System.exit(1);
        }
        if(type==null){
            System.out.println("Automaton type not specified. For more details use -h option.");
            System.exit(1);
        }
        return Arrays.asList(path, eps, type, saveLocation, optimizeFor);
    }
public static List < Object > parseArgs ( String [ ] args ) { double eps = 0.005 ; ModelType type = null ; String path = null ; String saveLocation = "jAlergiaModel" ; OptimizeFor optimizeFor = OptimizeFor . ACCURACY ; HashSet < String > argNames = new HashSet < > ( Arrays . asList ( "-eps" , "-input" , "-type" , "-save" , "-optim" ) ) ; if ( args . length == 0 || args [ 0 ] . equals ( "-help" ) || args [ 0 ] . equals ( "-h" ) || args [ 0 ] . equals ( "--help" ) ) { System . out . println ( helpDisplayMessage ) ; System . exit ( 0 ) ; } for ( int i = 0 ; i < args . length - 1 ; i += 2 ) { if ( ! argNames . contains ( args [ i ] ) ) { System . out . println ( "Unrecognized option '" + args [ i ] + "'.\nRun Use -help to see all arguments." ) ; System . exit ( 1 ) ; } if ( args [ i ] . equals ( "-eps" ) ) { try { eps = Double . parseDouble ( args [ i + 1 ] ) ; if ( eps > 2 || eps <= 0 ) { if ( eps != - 1 ) { System . out . println ( "Epsilon values must be a double in range of [2,0> " + "or -1 for automatic computation of epsilon." ) ; System . exit ( 1 ) ; } } } catch ( NumberFormatException e ) { System . out . println ( "Epsilon values must be a double in range of [2,0>" ) ; e . printStackTrace ( ) ; } } if ( args [ i ] . equals ( "-input" ) ) path = args [ i + 1 ] ; if ( args [ i ] . equals ( "-type" ) ) { switch ( args [ i + 1 ] ) { case "mdp" : type = ModelType . MDP ; break ; case "smm" : type = ModelType . SMM ; break ; case "mc" : type = ModelType . MC ; break ; default : System . out . println ( "Invalid -type option. Make sure it is either mdp, smm, or mc." ) ; System . exit ( 1 ) ; } } if ( args [ i ] . equals ( "-save" ) ) saveLocation = args [ i + 1 ] ; if ( args [ i ] . equals ( "-optim" ) ) { if ( args [ i + 1 ] . equals ( "mem" ) ) optimizeFor = OptimizeFor . MEMORY ; else if ( args [ i + 1 ] . equals ( "acc" ) ) optimizeFor = OptimizeFor . ACCURACY ; else { System . out . println ( "Invalid optimize for option, set to accuracy optimization." ) ; optimizeFor = OptimizeFor . ACCURACY ; } } } if ( path == null ) { System . out . println ( "Input file not specified. For more details use -h option." ) ; System . exit ( 1 ) ; } if ( type == null ) { System . out . println ( "Automaton type not specified. For more details use -h option." ) ; System . exit ( 1 ) ; } return Arrays . asList ( path , eps , type , saveLocation , optimizeFor ) ; }
Parses the arguments as defined in helpDisplayMessage;
 @param args list of arguments
 @return List of argument values
Parses the arguments as defined in helpDisplayMessage ; @param args list of arguments @return List of argument values