/* This file was generated by SableCC's ObjectMacro. */

package org.sablecc.objectmacro.errormessage;

import java.util.*;

public class MCannotCreateDirectory
        extends Macro {

    private DSeparator LocationSeparator;

    private DBeforeFirst LocationBeforeFirst;

    private DAfterLast LocationAfterLast;

    private DNone LocationNone;

    final List<String> list_Location;

    final Context LocationContext = new Context();

    final StringValue LocationValue;

    MCannotCreateDirectory(
            Macros macros) {

        setMacros(macros);
        this.list_Location = new LinkedList<>();

        this.LocationValue
                = new StringValue(this.list_Location, this.LocationContext);
    }

    public void addAllLocation(
            List<String> strings) {

        if (this.macros == null) {
            throw ObjectMacroException.parameterNull("Location");
        }
        if (this.cacheBuilder != null) {
            throw ObjectMacroException
                    .cannotModify(this.getClass().getSimpleName());
        }
        for (String string : strings) {
            if (string == null) {
                throw ObjectMacroException.parameterNull("Location");
            }

            this.list_Location.add(string);
        }
    }

    public void addLocation(
            String string) {

        if (string == null) {
            throw ObjectMacroException.parameterNull("Location");
        }
        if (this.cacheBuilder != null) {
            throw ObjectMacroException
                    .cannotModify(this.getClass().getSimpleName());
        }

        this.list_Location.add(string);
    }

    private String buildLocation() {

        StringBuilder sb = new StringBuilder();
        List<String> strings = this.list_Location;

        int i = 0;
        int nb_strings = strings.size();

        if (this.LocationNone != null) {
            sb.append(this.LocationNone.apply(i, "", nb_strings));
        }

        for (String string : strings) {

            if (this.LocationBeforeFirst != null) {
                string = this.LocationBeforeFirst.apply(i, string, nb_strings);
            }

            if (this.LocationAfterLast != null) {
                string = this.LocationAfterLast.apply(i, string, nb_strings);
            }

            if (this.LocationSeparator != null) {
                string = this.LocationSeparator.apply(i, string, nb_strings);
            }

            sb.append(string);
            i++;
        }

        return sb.toString();
    }

    StringValue getLocation() {

        return this.LocationValue;
    }

    private void initLocationDirectives() {

    }

    @Override
    void apply(
            InternalsInitializer internalsInitializer) {

        internalsInitializer.setCannotCreateDirectory(this);
    }

    public String build() {

        CacheBuilder cache_builder = this.cacheBuilder;

        if (cache_builder == null) {
            cache_builder = new CacheBuilder();
        }
        else if (cache_builder.getExpansion() == null) {
            throw new InternalException("Cycle detection detected lately");
        }
        else {
            return cache_builder.getExpansion();
        }
        this.cacheBuilder = cache_builder;
        List<String> indentations = new LinkedList<>();

        initLocationDirectives();

        StringBuilder sb0 = new StringBuilder();

        MCommandLineErrorHead m1 = getMacros().newCommandLineErrorHead();

        sb0.append(m1.build(null));
        sb0.append(LINE_SEPARATOR);
        sb0.append(LINE_SEPARATOR);
        sb0.append("The directory \"");
        sb0.append(buildLocation());
        sb0.append("\" could not be created.");
        sb0.append(LINE_SEPARATOR);
        sb0.append(LINE_SEPARATOR);
        MCommandLineErrorTail m2 = getMacros().newCommandLineErrorTail();

        sb0.append(m2.build(null));

        cache_builder.setExpansion(sb0.toString());
        return sb0.toString();
    }

    @Override
    String build(
            Context context) {

        return build();
    }

    private void setMacros(
            Macros macros) {

        if (macros == null) {
            throw new InternalException("macros cannot be null");
        }

        this.macros = macros;
    }
}
