class SQLiteUtils {

    @NonNull
    public static List<String> createIndexDefinition(TableInfo tableInfo) {
        ArrayList<String> definitions = new ArrayList<>();
        SparseArray<IndexGroupInfo> indexGroups = tableInfo.getIndexGroups();
        for (int i = 0; i < indexGroups.size(); i++) {
            int key = indexGroups.keyAt(i);
            IndexGroupInfo indexGroupInfo = indexGroups.get(key);
            String name = indexGroupInfo.name != null ? indexGroupInfo.name : tableInfo.getTableName();
            if (indexGroupInfo.columns.size() > 0) {
                definitions.add(String.format("CREATE INDEX IF NOT EXISTS %s on %s(%s);",
                        "index_" + tableInfo.getTableName() + "_" + name,
                        tableInfo.getTableName(),
                        join(indexGroupInfo.columns)));
            }
        }
        return definitions;
    }

}