package edu.ntnu.grouprec.util;

import java.util.List;

public class QueryUtil {

    public static String buildParams(int size) {
        StringBuilder inClause = new StringBuilder();

        for (int i = 0; i < size; i++) {
            inClause.append('?');
            if (i != size - 1)
                inClause.append(',');
        }
        String params = inClause.toString();
        return params;
    }

    public static String getFullQueryString(int numberOfEntities, int entitySize) {
        StringBuilder b = new StringBuilder();

        for (int i = 0; i < numberOfEntities; i++) {
            b.append("(");
            b.append(buildParams(entitySize));
            b.append(")");
            if (i < numberOfEntities - 1)
                b.append(", ");
        }
        return b.toString();
    }

    public static String getCommaDelimList(List<?> artists) {
        String delim = "";
        StringBuilder b = new StringBuilder();
        for (Object q : artists) {
            b.append(delim).append(q);
            delim = ",";
        }
        return b.toString();
    }
}
