validateDefinition method

  1. @mustCallSuper
void validateDefinition()
inherited

Validates the configuration option definition.

This method is called by prepareOptionsForParsing to validate the configuration option definition. Throws an error if the definition is invalid.

Subclasses may override this method to perform specific validations. If they do, they must also call the super implementation.

Implementation

@mustCallSuper
void validateDefinition() {
  if (argName == null && argAbbrev != null) {
    throw OptionDefinitionError(this,
        "An argument option can't have an abbreviation but not a full name");
  }

  if ((fromDefault != null || defaultsTo != null) && mandatory) {
    throw OptionDefinitionError(
        this, "Mandatory options can't have default values");
  }
}