package com.knecon.fforesight.service.layoutparser.processor.model.graph;

import com.knecon.fforesight.service.layoutparser.processor.model.graph.nodes.Document;
import com.knecon.fforesight.service.layoutparser.processor.model.graph.nodes.Footer;
import com.knecon.fforesight.service.layoutparser.processor.model.graph.nodes.Header;
import com.knecon.fforesight.service.layoutparser.processor.model.graph.nodes.Headline;
import com.knecon.fforesight.service.layoutparser.processor.model.graph.nodes.Image;
import com.knecon.fforesight.service.layoutparser.processor.model.graph.nodes.Paragraph;
import com.knecon.fforesight.service.layoutparser.processor.model.graph.nodes.Section;
import com.knecon.fforesight.service.layoutparser.processor.model.graph.nodes.SemanticNode;
import com.knecon.fforesight.service.layoutparser.processor.model.graph.nodes.SuperSection;
import com.knecon.fforesight.service.layoutparser.processor.model.graph.nodes.Table;
import com.knecon.fforesight.service.layoutparser.processor.model.graph.nodes.TableCell;

public abstract class AbstractNodeVisitor implements NodeVisitor {

    @Override
    public void visit(Document document) {

        visitChildren(document);
    }


    @Override
    public void visit(SuperSection superSection) {

        visitChildren(superSection);
    }


    @Override
    public void visit(Section section) {

        visitChildren(section);
    }


    @Override
    public void visit(Headline headline) {

        visitChildren(headline);
    }


    @Override
    public void visit(Paragraph paragraph) {

        visitChildren(paragraph);
    }


    @Override
    public void visit(Footer footer) {

        visitChildren(footer);
    }


    @Override
    public void visit(Header header) {

        visitChildren(header);
    }


    @Override
    public void visit(Image image) {

        visitChildren(image);
    }


    @Override
    public void visit(Table table) {

        visitChildren(table);
    }


    @Override
    public void visit(TableCell tableCell) {

        visitChildren(tableCell);
    }


    protected void visitChildren(SemanticNode semanticNode) {

        semanticNode.streamChildren()
                .forEach(node -> node.accept(this));

    }

}
