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

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

import com.knecon.fforesight.service.layoutparser.processor.model.image.ClassifiedImage;
import com.knecon.fforesight.service.layoutparser.processor.model.table.TablePageBlock;

import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@NoArgsConstructor
public class ClassificationSection {

    private List<AbstractPageBlock> pageBlocks = new ArrayList<>();
    private List<ClassifiedImage> images = new ArrayList<>();
    private String headline;


    public List<TablePageBlock> getTables() {

        List<TablePageBlock> tables = new ArrayList<>();
        pageBlocks.forEach(block -> {
            if (block instanceof TablePageBlock) {
                tables.add((TablePageBlock) block);
            }
        });
        return tables;
    }


    public List<AbstractPageBlock> getNonEmptyPageBlocks() {

        return pageBlocks.stream().filter(pageBlock -> !pageBlock.isEmpty()).collect(Collectors.toList());
    }

}
