title: Validation Factory Class Design
body: <p>I want to accomplish one task, my work flow is input (args + configuration) -> validation (after validation,return operation) -> processing on operation -> output. Now i am working in input and validation section. args is command line arguments. I can grab the configuration details after loading configuration file and this file path will be supplied from command line. Now i am going to design one Validation Factory class which will return me an instance of validator based on the operation type specified from command line arguments, may be it will be content validator or state change validator etc. Now i am stuck with one step, i.e. how can i fit configuration loading process in the input step so that i can validate few required configuration in the validation steps. </p>
  
  <p>I am sharing my code-</p>
  
  <p>This is my validation factory class</p>
  
  <pre><code>public class ValidatorFactory {
  
      private ValidatorFactory() {
      }
  
      public static Validator getInstance(CommandLine cmd) throws BadArgumentException {
          String operationType = cmd.getOptionValue("op");
          ......
          switch (OperationType.valueOf(operationType.toUpperCase())) {
              case PUBLISH: validator = new StateChangeValidator(cmd);
              //here i want to pass configuration to the constructor, but i want to know how can i use my configuration loader which will load and returns me configuration. 
  
          }
          return validator;
      }
  
  }
  </code></pre>
  
  <p>Question 1) Can validation factory is meaning full context to load configuration file? I mean to say, can i use my loader in the getinstance() section? can it be meaning full? </p>
  
  <p>These are my Validation classes:-</p>
  
  <pre><code>public abstract class AbstractValidator
          implements Validator {
  
      protected CommandLine cmd;
  
      protected Properties configuration;
  
      public AbstractValidator(CommandLine cmd, Properties configuration) {
          this.configuration = configuration;
          this.cmd = cmd;
      }
  
      ......
  
  }
  
  public class StateChangeValidator extends AbstractValidator {
  
      public StateChangeValidator(CommandLine cmd, Properties properties) {
          super(cmd, properties);
      }
     ......
  }
  </code></pre>
  
  <p>and this is my loader class</p>
  
  <pre><code>public final class ConfigurationFileLoader {
  
      private static final Logger LOGGER = LoggerFactory.getLogger(ConfigurationFileLoader.class);
  
      public static final Properties getConfiguration(String filePath) throws BadFileException {
          //validate configuration file, load and return configuration
  
      }
  
  }
  </code></pre>
  
  <p>How can i design the flow? because loading of configuration file is depended on one input supplied from command line. </p>