package lc.sips;

import lc.mecha.util.StringAccumulatorV2;
import lc.sips.schema.ColumnDefinition;

import java.util.Set;

public class QueryAccumulator {
    private final StringBuffer buffer = new StringBuffer();

    public void append(String value) {
        buffer.append(value);
    }

    public void append(Set<String> names) {
        var sa = new StringAccumulatorV2(",");
        sa.push(names);
        buffer.append(sa.asString());
    }

    public void appendQuestions(int count) {
        var sa = new StringAccumulatorV2(",");
        for (var i = 0; i < count; i++) {
            sa.push("?");
        }
        buffer.append(sa.asString());
    }

    public void appendDefs(Set<ColumnDefinition> columns) {
        var sa = new StringAccumulatorV2(",");
        for (var cd : columns) {
            sa.push(cd.name());
        }
        buffer.append(sa.toString());
    }

    public String toString() {
        return buffer.toString();
    }
}
