package innovimax.mixthem;

import innovimax.mixthem.exceptions.ArgumentException;

import java.io.File;
import java.util.ArrayList;
import java.util.List;

/**
* <p>Mix-them command line arguments management.</p>
* @author Innovimax
* @version 1.0
*/
class Arguments {
    
    private Rule rule = null;
    private List<String> ruleParams = null;
    private File file1 = null;
    private File file2 = null;

    void setRule(Rule rule) {
        this.rule = rule;
    }

    Rule getRule() {
        return this.rule;
    }

    void setRuleParameters(List<String> ruleParams) {
        this.ruleParams = ruleParams;
    }

    List<String> getRuleParameters() {
        return this.ruleParams;
    }

    void setFirstFile(File file1) {
        this.file1 = file1;
    }

    File getFirstFile() {
        return this.file1;
    }

    void setSecondFile(File file2) {
        this.file2 = file2;
    }

    File getSecondFile() {
        return this.file2;
    }

    private static Rule getRuleArgument(String[] args, int index, String name) throws ArgumentException {        
        Rule rule = null;
        if (args.length >= 1) {
            final String ruleString = args[index];
            if (ruleString.startsWith("-")) {
                rule = Rule.findByName(ruleString);
                if (rule == null) {
                    throw new ArgumentException(name + " argument is incorrect: " + ruleString);
                }
            }
        }
        return rule;
    }

    private static List<String> getRuleParameters(String[] args, int index, Rule rule) throws ArgumentException {
        List<String> params = new ArrayList<String>();        
        // TODO
        return params;
    }

}

@@ -1710,10 +1710,702 @@
 %0A    %7D%0A%0A
+    private static File getFileArgument(String%5B%5D args, int index, String name) throws ArgumentException %7B%0A        File file = null;%0A        if (args.length %3C index+1) %7B%0A            throw new ArgumentException(name + %22 argument missing.%22);%0A        %7D else %7B%0A            String filepath = args%5Bindex%5D;%0A            file = new File(filepath);%0A            if (file.exists()) %7B%0A                if (!file.canRead()) %7B                    %0A                    throw new ArgumentException(name + %22 cannot be read: %22 + filepath);    %0A                %7D%0A            %7D else %7B%0A                throw new ArgumentException(name + %22 not found: %22 + filepath);%0A            %7D%0A        %7D%0A        return file;%0A    %7D%0A%0A
 %7D%0A

Update Arguments.java