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

package org.sablecc.objectmacro.errormessage;

import java.util.*;

class StringValue
        extends Value {

    private final List<String> strings;

    StringValue(
            List<String> strings,
            Context context) {

        super(context);
        this.strings = strings;
    }

    @Override
    String build() {

        if (this.cache != null) {
            return this.cache;
        }

        StringBuilder sb = new StringBuilder();
        int i = 0;
        int nb_strings = this.strings.size();

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

        for (String string : this.strings) {

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

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

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

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

        this.cache = sb.toString();
        return this.cache;
    }
}
