package com.capgemini.reports.definition.r07report.checker;

import com.capgemini.reports.exceptions.UserInputErrorEnum;
import com.capgemini.reports.reports.parameters.ProductUnit;
import com.capgemini.reports.reports.parameters.checker.ProductUnitChecker;

/**
 * This class checks if a a given Product-Unit is valid for a R07 report.
 */
public class R07ProductUnitChecker extends ProductUnitChecker {

    private final R07Configuration conf;

    /**
     * Constructor.
     *
     * @param productUnit {@link ProductUnit} - the product unit
     * @param isConf1     boolean - Is true if it is the configuration 1. Else false.
     */
    public R07ProductUnitChecker(final ProductUnit productUnit, final boolean isConf1) {
        super(productUnit);
        this.conf = isConf1 ? R07Configuration.CONF_1 : R07Configuration.CONF_2;
    }

    @Override
    protected UserInputErrorEnum getErrorMessage() {
        switch (conf) {
            case CONF_1:
                return UserInputErrorEnum.THE_UNIT_1_IS_NOT_ASSOCIATED_TO_THE_PRODUCT_1;
            case CONF_2:
                return UserInputErrorEnum.THE_UNIT_2_IS_NOT_ASSOCIATED_TO_THE_PRODUCT_2;
            default:
                return UserInputErrorEnum.PRODUCT_AND_UNIT_DOES_NOT_EXIST;
        }
    }

    private enum R07Configuration {
        CONF_1,
        CONF_2
    }
}
