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