package org.crunchytorch.coddy.snippet.elasticsearch.query;

import org.elasticsearch.index.query.BoolQueryBuilder;
import org.elasticsearch.index.query.QueryBuilder;

import java.util.LinkedList;
import java.util.List;

public abstract class AbstractSnippetQueryFieldBuilder<T> implements SnippetQueryFieldBuilder<T> {

    protected List<String> words;

    protected List<QueryBuilder> queryBuilderList;

    protected BoolOperand operand;

    protected AbstractSnippetQueryFieldBuilder() {
        this.words = new LinkedList<>();
        this.queryBuilderList = new LinkedList<>();
    }

    @Override
    public void appendQueryBuilder(BoolQueryBuilder queryBuilder) {
        if (BoolOperand.AND.equals(this.getOperand())) {
            this.queryBuilderList.forEach(queryBuilder::must);
        } else {
            this.queryBuilderList.forEach(queryBuilder::should);
        }
    }

    @Override
    public BoolOperand getOperand() {
        return operand;
    }
}
@@ -580,32 +580,212 @@
 ist%3C%3E();%0A    %7D%0A%0A
+    public T useAndBoolOperand() %7B%0A        return this.setOperand(BoolOperand.AND);%0A    %7D%0A%0A    public T useOrBoolOperand() %7B%0A        return this.setOperand(BoolOperand.OR);%0A    %7D%0A%0A
     @Override%0A  

add high level bool setter