All Downloads are FREE. Search and download functionalities are using the official Maven repository.

it.jnrpe.yaclp.AbstractOption Maven / Gradle / Ivy

There is a newer version: 1.0.4
Show newest version
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