.getRequiredOptionsNotSet(optionInstances, reqOptions);
for (CmdLineOption unsetReqOption : unsetReqOptions) {
if (unsetReqOption.getRequiredOptions().size() > 0) {
for (RequiredOption reqOption : unsetReqOption
.getRequiredOptions()) {
CmdLineOptionInstance optionInst = getOptionInstanceByName(
reqOption.getOptionLongName(), optionInstances);
if (optionInst != null
&& ((reqOption.isRequireAllValues() && optionInst
.getValues().containsAll(
reqOption.getOptionValues())) || (!reqOption
.isRequireAllValues() && !Collections
.disjoint(optionInst.getValues(), reqOption
.getOptionValues()))))
throw new IOException("Option "
+ unsetReqOption.getId() + " is required");
}
} else
throw new IOException("Option " + unsetReqOption.getId()
+ " is required");
}
// validate options
for (CmdLineOptionInstance optionInst : optionInstances) {
for (CmdLineOptionValidator validator : optionInst.getOption()
.getValidators())
if (!validator.validate(optionInst))
throw new IOException("Option "
+ optionInst.getOption().getId()
+ " failed validation");
}
// if all looks good . . . handle options
for (CmdLineOptionInstance optionInst : optionInstances)
optionInst.getOption().getHandler().handleOption(
optionInst.getOption(), optionInst.getValues());
return optionInstances;
}