class DefaultLinkTypeParser implements LinkTypeParser {

    private final TermTypeParser parser = new DefaultTermTypeParser();


    @Override
    public void process(List<Term> terms,
                                    Consumer<Term> consumer,
                                    BoolQueryBuilder queryBuilders) {<FILL_FUNCTION_BODY>}

    private void handleOr(BoolQueryBuilder queryBuilders,
                          Term term,
                          Consumer<Term> consumer) {
        consumer.accept(term);
        if (term.getTerms().isEmpty() && term.getValue() != null) {
            parser.process(() -> term, queryBuilders::should);
        } else if (!term.getTerms().isEmpty()){
            BoolQueryBuilder nextQuery = QueryBuilders.boolQuery();
            process(term.getTerms(), consumer, nextQuery);
            queryBuilders.should(nextQuery);
        }
    }

    private void handleAnd(BoolQueryBuilder queryBuilders,
                           Term term,
                           Consumer<Term> consumer) {
        consumer.accept(term);
        if (term.getTerms().isEmpty() && term.getValue() != null) {
            parser.process(() -> term, queryBuilders::must);
        } else if (!term.getTerms().isEmpty()){
            BoolQueryBuilder nextQuery = QueryBuilders.boolQuery();
            process(term.getTerms(), consumer, nextQuery);
            queryBuilders.must(nextQuery);
        }
    }

}


        if (CollectionUtils.isEmpty(terms)) {
            return;
        }
        for (TermsHandler.TermGroup group : TermsHandler.groupTerms(terms)) {
            if (group.type == Term.Type.or) {
                for (Term groupTerm : group.getTerms()) {
                    handleOr(queryBuilders, groupTerm, consumer);
                }
            } else {
                BoolQueryBuilder andQuery = QueryBuilders.boolQuery();
                for (Term groupTerm : group.getTerms()) {
                    handleAnd(andQuery, groupTerm, consumer);
                }
                if (!CollectionUtils.isEmpty(andQuery.must())){
                    queryBuilders.should(andQuery);
                }
            }
        }
    
<no_super_class>