it.jnrpe.yaclp.AbstractOption Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of cli-parser Show documentation
Show all versions of cli-parser Show documentation
A java command line parser
package it.jnrpe.yaclp;
import java.util.ArrayList;
import java.util.List;
abstract class AbstractOption implements IOption {
private boolean mandatory = false;
private boolean repeatable = false;
private List requiredOptions = new ArrayList<>();
private Argument optionArgs = null;
/**
* Consumes the passed in command line by parsing the option and removing it.
*
* @param args the command line. It gets changed by the method.
* @param res the result of the parsing
* @throws ParsingException on any error parsing the command line
*/
abstract void consume(List args, CommandLine res) throws ParsingException;
void setMandatory(boolean mandatory) {
this.mandatory = mandatory;
}
void addRequiredOption(AbstractOption option) {
requiredOptions.add(option);
}
List getRequiredOptions() {
return requiredOptions;
}
/**
* Configures the arguments of this option.
* @param arg the arguments of this option
*/
void setArgument(Argument arg) {
this.optionArgs = arg;
}
Argument getArgument() {
return optionArgs;
}
void setRepeatable(boolean repeatable) {
this.repeatable = repeatable;
}
public boolean isRepeatable() {
return repeatable;
}
public boolean isMandatory() {
return mandatory;
}
public abstract boolean isPresent(List args);
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy