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._SEED)),
    _JOIN(           "join",            "join",            "will output merging of lines that have common occurrence", true, EnumSet.of(RuleParam._COL1, RuleParam._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.
    * @param name The name of the rule in command line
    * @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;
    }

}

@@ -48,22 +48,100 @@
 va.util.
-EnumSe
+Arrays;%0Aimport java.util.Collections;%0Aimport java.util.EnumSet;%0Aimport java.util.Lis
 t;%0A%0A/**%0A
@@ -460,32 +460,57 @@
 RuleParam.class)
+, Collections.emptyList()
 ),%0A    _2(      
@@ -605,32 +605,57 @@
 RuleParam.class)
+, Collections.emptyList()
 ),%0A    _ADD(    
@@ -756,32 +756,57 @@
 RuleParam.class)
+, Collections.emptyList()
 ),%0A    _ALT_LINE
@@ -838,24 +838,25 @@
   %22altline%22,
+ 
         %22wil
@@ -950,26 +950,52 @@
 Param.class)
+, Collections.emptyList()
 ),
+ 
 %0A    _ALT_CH
@@ -1029,24 +1029,25 @@
   %22altchar%22,
+ 
         %22wil
@@ -1145,16 +1145,41 @@
 m.class)
+, Collections.emptyList()
 ),%0A    _
@@ -1230,16 +1230,17 @@
 ltline%22,
+ 
  %22will o
@@ -1347,16 +1347,51 @@
 m._SEED)
+, Collections.singletonList(%221789%22)
 ),%0A    _
@@ -1554,16 +1554,43 @@
 m._COL2)
+, Arrays.asList(%221%22, %222 1%22)
 ),%0A    _
@@ -1716,12 +1716,39 @@
 ass)
+, Collections.emptyList()
 );%0A%0A
+  
   pr
@@ -1879,16 +1879,59 @@
  params;
+%0A    private final List%3CString%3E testValues;
 %0A%0A    pr
@@ -2038,16 +2038,41 @@
 %3E params
+, List%3CString%3E testValues
 ) %7B%0A    
@@ -2231,32 +2231,70 @@
 arams = params;%0A
+        this.testValues = testValues;%0A
     %7D%0A%0A    /**%0A 
@@ -3122,63 +3122,8 @@
 le.%0A
-    * @param name The name of the rule in command line%0A
     
@@ -3268,32 +3268,290 @@
 .params;%0A    %7D%0A%0A
+    /**%0A    * Returns an iterator over the additional parameters values for testing%0A    * @return An iterator over the additional parameters values for testing%0A    */ %0A    public Iterable%3CString%3E getParamTestValues() %7B%0A        return this.testValues;%0A    %7D%0A%0A
     /**%0A    * Fi

Update Rule.java