Home | History | Annotate | Download | only in jcommander
      1 package com.beust.jcommander;
      2 
      3 import com.beust.jcommander.converters.FileConverter;
      4 
      5 import java.io.File;
      6 
      7 public class ArgsValidate2 {
      8   public static class FailingValidator implements IValueValidator<File> {
      9 
     10     public void validate(String name, File value) throws ParameterException {
     11       throw new ParameterException("Validation will always fail:" + name + " " + value);
     12     }
     13 
     14   }
     15 
     16   public static final String POSSIBLE_TEMPLATE_FILE = "mayOrMayNotExist.template";
     17 
     18   @Parameter(names = { "-template"},
     19       description = "The default file may or may not exist",
     20       converter = FileConverter.class,
     21       validateValueWith = FailingValidator.class
     22       )
     23   public File template = new File(POSSIBLE_TEMPLATE_FILE);
     24 }
     25