package de.frajul.endlessroll.sqlDatabase;

public class SQLTable {

    private final String name;
    private final String columnsAsText;

    public SQLTable(String name, SQLTableColumn... columns) {
        this.name = name;
        StringBuilder builder = new StringBuilder();
        for (int i = 0; i < columns.length; i++) {
            builder.append(columns[i].toString());
            if (i != columns.length - 1)
                builder.append(", ");
        }
        columnsAsText = builder.toString();
    }

    public String getName() {
        return name;
    }

    public String getSqlCreateTable() {
        return "CREATE TABLE " + name + "(" + columnsAsText + ");";
    }

    public String getSqlDeleteTable() {
        return "DROP TABLE IF EXISTS " + name;
    }

    public String getSqlClearTable() {
        return "DELETE FROM " + name;
    }

    public String getSqlGetCursor() {
        return "SELECT * FROM " + name;
    }
}