export default class JDLApplicationDefinition {
    optionValues;
    optionTypes;
    quotedOptionNames;
    constructor({ optionValues, optionTypes, quotedOptionNames }) {
        this.optionValues = optionValues;
        this.optionTypes = optionTypes;
        this.quotedOptionNames = quotedOptionNames;
    }
    getTypeForOption(optionName) {
        if (!optionName) {
            throw new Error('A name has to be passed to get the option type.');
        }
        if (!this.optionTypes[optionName]) {
            throw new Error(`Unrecognised application option name: ${optionName}.`);
        }
        return this.optionTypes[optionName].type;
    }
    doesOptionValueExist(name, value) {
        if (!this.doesOptionExist(name)) {
            return false;
        }
        const values = this.optionValues[name];
        if (typeof values !== 'object' || Array.isArray(values)) {
            return true;
        }
        if (Array.isArray(value)) {
            return value.every(val => values[val] != null);
        }
        return values[value] != null;
    }
    doesOptionExist(optionName) {
        return Boolean(optionName && optionName in this.optionTypes);
    }
    shouldTheValueBeQuoted(optionName) {
        if (!optionName) {
            throw new Error('An option name has to be passed to know whether it is quoted.');
        }
        return this.quotedOptionNames.includes(optionName);
    }
}
