package innovimax.mixthem.arguments;

import java.util.EnumSet;

/**
* <p>This is a detailed enumeration of rules used to mix files.</p>
* <p>Some rules may not be implemented yet.<.p>
* <p>(Also used to print usage.)</p>
* @author Innovimax
* @version 1.0
*/
public enum Rule { 
    _1(              "1",               "1",               "will output file1", true, EnumSet.noneOf(RuleParam.class)),
    _2(              "2",               "2",               "will output file2", true, EnumSet.noneOf(RuleParam.class)),
    _ADD(            "+",               "add",             "will output file1+file2", true, EnumSet.noneOf(RuleParam.class)),
    _ALT_LINE(       "alt-line",        "altline",         "will output one line of each starting with first line of file1", true, EnumSet.noneOf(RuleParam.class)), 
    _ALT_CHAR(       "alt-char",        "altchar",         "will output one char of each starting with first char of file1", true, EnumSet.noneOf(RuleParam.class)),
    _RANDOM_ALT_LINE("random-alt-line", "random-altline",  "will output one line of each code randomly based on a seed for reproducability", true, EnumSet.of(RuleParam._RANDOM_SEED)),
    _JOIN(           "join",            "join",            "will output merging of lines that have common occurrence", true, EnumSet.of(RuleParam._JOIN_COL1, RuleParam._JOIN_COL2)),
    _ZIP(            "zip",             "zip",             "will output zip of the file", false, EnumSet.noneOf(RuleParam.class));

    private final String name, extension, description;
    private final boolean implemented;
    private final EnumSet<RuleParam> params;

    private Rule(String name, String extension, String description, boolean implemented, EnumSet<RuleParam> params) {
        this.name = name;
        this.extension = extension;
        this.description = description;
        this.implemented = implemented;
        this.params = params;
    }

    /**
    * Returns true if the rule is currently implemented.
    * @return True if the rule is currently implemented
    */
    public boolean isImplemented() {
        return this.implemented;
    }

    /**
    * Returns the name of this rule on command line.
    * @return The name of the rule on command line
    */
    public String getName() {
        return this.name;
    }

    /**
    * Returns the file extension used for outputting.
    * @return The file extension for the rule
    */ 
    public String getExtension() {
        return this.extension;
    }

    /**
    * Returns the description of this rule.
    * @return The description of the rule
    */ 
    public String getDescription() {
        return this.description;
    }

    /**
    * Returns an iterator over the additional parameters in this rule.
    * @return An iterator over the additional parameters in this rule
    */ 
    public Iterable<RuleParam> getParams() {
        return this.params;
    }

    /**
    * Finds the Rule object correponding to a name
    * @param name The name of the rule in command line
    * @return The {@link Rule} object
    */    
    public static Rule findByName(String name) {
        for(Rule rule : values()){
            if (rule.getName().equals(name)) {
                return rule;
            }
        }
        return null;
    }

}

@@ -1335,16 +1335,20 @@
 _COL2)),
+    
 %0A    _ZI
@@ -1352,33 +1352,57 @@
 _ZIP
+_LINE
 (      
+ %22zip-line%22,
       
+  
 %22zip
+-line
 %22,      
     
@@ -1389,32 +1389,136 @@
 zip-line%22,      
+  %22will output zip of line from file1 and file2%22, false, EnumSet.of(RuleParam._ZIP_SEP)),%0A    _ZIP_CHAR(
        %22zip%22,   
@@ -1512,23 +1512,42 @@
     %22zip
+-char
 %22,     
+   %22zip-char%22,
         
@@ -1566,24 +1566,41 @@
  zip of 
-the
+char from file1 and
  file
+2
 %22, false
@@ -1601,37 +1601,33 @@
  false, EnumSet.
-noneO
+o
 f(RuleParam.clas
@@ -1622,21 +1622,171 @@
 leParam.
-class
+_ZIP_SEP)),%0A    _ZIP_CELL(       %22zip-cell%22,        %22zip-cell%22,        %22will output zip of cell from file1 and file2%22, false, EnumSet.of(RuleParam._ZIP_SEP
 ));%0A%0A   

add new zip rules to enum